use settings in timer page

main
Julian Gegner 2023-02-16 02:08:15 +01:00
parent d14dafe61f
commit 3348505490
1 changed files with 15 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:smoke_cess_app/service/settings_service.dart';
import 'package:smoke_cess_app/widgets/timer_button.dart';
class StopWatchTimerPage extends StatefulWidget {
@ -10,15 +11,26 @@ class StopWatchTimerPage extends StatefulWidget {
}
class StopWatchTimerPageState extends State<StopWatchTimerPage> {
static const countdownDuration = Duration(minutes: 1);
Duration duration = countdownDuration;
SettingsService settings = SettingsService();
Duration duration = const Duration(minutes: 1);
Timer? timer;
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() {
if (countDown) {
setState(() => duration = countdownDuration);
setDurationWithSetting();
} else {
setState(() => duration = const Duration());
}