mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-01-27 04:29:33 +00:00
feat: add shake detection functionality (#36)
* feat: add shake detection functionality and integrate vibration support * feat: add shake detector settings page
This commit is contained in:
parent
2e3b1de529
commit
b229c4f2f5
25 changed files with 1423 additions and 158 deletions
|
|
@ -6,6 +6,7 @@ import 'package:vaani/settings/app_settings_provider.dart';
|
|||
import 'package:vaani/settings/models/app_settings.dart';
|
||||
import 'package:vaani/settings/view/buttons.dart';
|
||||
import 'package:vaani/settings/view/simple_settings_page.dart';
|
||||
import 'package:vaani/shared/extensions/enum.dart';
|
||||
|
||||
class NotificationSettingsPage extends HookConsumerWidget {
|
||||
const NotificationSettingsPage({
|
||||
|
|
@ -16,7 +17,7 @@ class NotificationSettingsPage extends HookConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final appSettings = ref.watch(appSettingsProvider);
|
||||
final notificationSettings = appSettings.notificationSettings;
|
||||
|
||||
final primaryColor = Theme.of(context).colorScheme.primary;
|
||||
return SimpleSettingsPage(
|
||||
title: const Text('Notification Settings'),
|
||||
sections: [
|
||||
|
|
@ -37,7 +38,10 @@ class NotificationSettingsPage extends HookConsumerWidget {
|
|||
children: [
|
||||
TextSpan(
|
||||
text: notificationSettings.primaryTitle,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
@ -72,7 +76,10 @@ class NotificationSettingsPage extends HookConsumerWidget {
|
|||
children: [
|
||||
TextSpan(
|
||||
text: notificationSettings.secondaryTitle,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
@ -151,19 +158,17 @@ class NotificationSettingsPage extends HookConsumerWidget {
|
|||
title: const Text('Media Controls'),
|
||||
leading: const Icon(Icons.control_camera),
|
||||
// description: const Text('Select the media controls to display'),
|
||||
description: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Select the media controls to display'),
|
||||
Wrap(
|
||||
spacing: 8.0,
|
||||
children: notificationSettings.mediaControls
|
||||
.map(
|
||||
(control) => Icon(control.icon),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
description: const Text('Select the media controls to display'),
|
||||
trailing: Wrap(
|
||||
spacing: 8.0,
|
||||
children: notificationSettings.mediaControls
|
||||
.map(
|
||||
(control) => Icon(
|
||||
control.icon,
|
||||
color: primaryColor,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
onPressed: (context) async {
|
||||
final selectedControls =
|
||||
|
|
@ -225,7 +230,7 @@ class MediaControlsPicker extends HookConsumerWidget {
|
|||
OkButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(selectedMediaControls.value);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
// a list of chips to easily select the media controls to display
|
||||
|
|
@ -235,14 +240,8 @@ class MediaControlsPicker extends HookConsumerWidget {
|
|||
children: NotificationMediaControl.values
|
||||
.map(
|
||||
(control) => ChoiceChip(
|
||||
label: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(control.icon),
|
||||
const SizedBox(width: 4.0),
|
||||
Text(control.name),
|
||||
],
|
||||
),
|
||||
avatar: Icon(control.icon),
|
||||
label: Text(control.pascalCase),
|
||||
selected: selectedMediaControls.value.contains(control),
|
||||
onSelected: (selected) {
|
||||
if (selected) {
|
||||
|
|
@ -332,7 +331,7 @@ class NotificationTitlePicker extends HookConsumerWidget {
|
|||
OkButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(selectedTitle.value);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
// a list of chips to easily insert available fields into the text field
|
||||
|
|
@ -362,10 +361,10 @@ class NotificationTitlePicker extends HookConsumerWidget {
|
|||
children: NotificationTitleType.values
|
||||
.map(
|
||||
(type) => ActionChip(
|
||||
label: Text(type.stringValue),
|
||||
label: Text(type.pascalCase),
|
||||
onPressed: () {
|
||||
final text = controller.text;
|
||||
final newText = '$text\$${type.stringValue}';
|
||||
final newText = '$text\$${type.name}';
|
||||
controller.text = newText;
|
||||
selectedTitle.value = newText;
|
||||
},
|
||||
|
|
@ -378,16 +377,3 @@ class NotificationTitlePicker extends HookConsumerWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> showNotificationTitlePicker(
|
||||
BuildContext context, {
|
||||
required String initialValue,
|
||||
required String title,
|
||||
}) async {
|
||||
return showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return NotificationTitlePicker(initialValue: initialValue, title: title);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue