mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-21 18:39:30 +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
|
|
@ -11,6 +11,7 @@ import 'package:vaani/features/sleep_timer/core/sleep_timer.dart';
|
|||
import 'package:vaani/features/sleep_timer/providers/sleep_timer_provider.dart'
|
||||
show sleepTimerProvider;
|
||||
import 'package:vaani/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/shared/extensions/duration_format.dart';
|
||||
import 'package:vaani/shared/extensions/inverse_lerp.dart';
|
||||
import 'package:vaani/shared/widgets/not_implemented.dart';
|
||||
|
||||
|
|
@ -376,8 +377,8 @@ class RemainingSleepTimeDisplay extends HookConsumerWidget {
|
|||
),
|
||||
child: Text(
|
||||
timer.timer == null
|
||||
? timer.duration.formatSingleLargestUnit()
|
||||
: remainingTime?.formatSingleLargestUnit() ?? '',
|
||||
? timer.duration.smartBinaryFormat
|
||||
: remainingTime?.smartBinaryFormat ?? '',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
|
|
@ -385,17 +386,3 @@ class RemainingSleepTimeDisplay extends HookConsumerWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension DurationFormat on Duration {
|
||||
/// will return a number followed by h, m, or s depending on the duration
|
||||
/// only the largest unit will be shown
|
||||
String formatSingleLargestUnit() {
|
||||
if (inHours > 0) {
|
||||
return '${inHours}h';
|
||||
} else if (inMinutes > 0) {
|
||||
return '${inMinutes}m';
|
||||
} else {
|
||||
return '${inSeconds}s';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue