use settings in timer page
parent
d14dafe61f
commit
3348505490
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:smoke_cess_app/service/settings_service.dart';
|
||||||
import 'package:smoke_cess_app/widgets/timer_button.dart';
|
import 'package:smoke_cess_app/widgets/timer_button.dart';
|
||||||
|
|
||||||
class StopWatchTimerPage extends StatefulWidget {
|
class StopWatchTimerPage extends StatefulWidget {
|
||||||
|
@ -10,15 +11,26 @@ class StopWatchTimerPage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
class StopWatchTimerPageState extends State<StopWatchTimerPage> {
|
||||||
static const countdownDuration = Duration(minutes: 1);
|
SettingsService settings = SettingsService();
|
||||||
Duration duration = countdownDuration;
|
Duration duration = const Duration(minutes: 1);
|
||||||
Timer? timer;
|
Timer? timer;
|
||||||
|
|
||||||
bool countDown = true;
|
bool countDown = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
setDurationWithSetting();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDurationWithSetting() {
|
||||||
|
settings.getIntSetting('workout_duration_minutes').then((workoutMinutes) =>
|
||||||
|
{setState(() => duration = Duration(minutes: workoutMinutes ?? 10))});
|
||||||
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
if (countDown) {
|
if (countDown) {
|
||||||
setState(() => duration = countdownDuration);
|
setDurationWithSetting();
|
||||||
} else {
|
} else {
|
||||||
setState(() => duration = const Duration());
|
setState(() => duration = const Duration());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue