From 33485054903fa46dd66ca78a17a1ace9861f45b3 Mon Sep 17 00:00:00 2001 From: Crondung <1922635@stud.hs-mannheim.de> Date: Thu, 16 Feb 2023 02:08:15 +0100 Subject: [PATCH] use settings in timer page --- lib/pages/timer_page.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/pages/timer_page.dart b/lib/pages/timer_page.dart index 899f862..691d15d 100644 --- a/lib/pages/timer_page.dart +++ b/lib/pages/timer_page.dart @@ -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 { - 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()); }