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()); }