-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import 'package:spotube/utils/primitive_utils.dart'; | ||
|
||
extension DurationToHumanReadableString on Duration { | ||
toHumanReadableString() => | ||
String toHumanReadableString() => | ||
"${inMinutes.remainder(60)}:${PrimitiveUtils.zeroPadNumStr(inSeconds.remainder(60))}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
|
||
class SleepTimerNotifier extends StateNotifier<Duration?> { | ||
SleepTimerNotifier() : super(null); | ||
|
||
Timer? _timer; | ||
|
||
static final provider = StateNotifierProvider<SleepTimerNotifier, Duration?>( | ||
(ref) => SleepTimerNotifier(), | ||
); | ||
|
||
static AlwaysAliveRefreshable<SleepTimerNotifier> get notifier => | ||
provider.notifier; | ||
|
||
void setSleepTimer(Duration duration) { | ||
state = duration; | ||
|
||
_timer = Timer(duration, () { | ||
//! This can be a reason for app termination in iOS AppStore | ||
exit(0); | ||
}); | ||
} | ||
|
||
void cancelSleepTimer() { | ||
state = null; | ||
_timer?.cancel(); | ||
} | ||
} |