Skip to content

Commit

Permalink
Add wakelock for an active timer
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mabe committed Jan 4, 2025
1 parent a603bbd commit 46b1076
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 74 deletions.
4 changes: 4 additions & 0 deletions lib/pages/active_timer/workout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:openhiit/pages/active_timer/widgets/timer_complete.dart';
import 'package:openhiit/utils/functions.dart';
import 'package:openhiit/widgets/timer_card_item_animated.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

class RunTimer extends StatefulWidget {
final TimerType timer;
Expand Down Expand Up @@ -63,6 +64,7 @@ class RunTimerState extends State<RunTimer> {
@override
void dispose() {
_controllerCenter.dispose();
WakelockPlus.disable();
super.dispose();
}

Expand Down Expand Up @@ -119,6 +121,7 @@ class RunTimerState extends State<RunTimer> {
_paused = !_paused;
});
_paused ? _controller.pause() : _controller.resume();
_paused ? WakelockPlus.disable() : WakelockPlus.enable();
}

Color backgroundColor(String state) {
Expand All @@ -145,6 +148,7 @@ class RunTimerState extends State<RunTimer> {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarBrightness: Brightness.dark,
));
WakelockPlus.enable();
return Scaffold(body: OrientationBuilder(builder: (context, orientation) {
return Countdown(
controller: _controller,
Expand Down
Loading

0 comments on commit 46b1076

Please sign in to comment.