|
@@ -24,6 +24,7 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
|
|
|
// Settings
|
|
|
late TimerSettings _settings;
|
|
|
+ bool _settingsLoaded = false;
|
|
|
final AudioManager _audioManager = AudioManager();
|
|
|
|
|
|
// Wheel controllers
|
|
@@ -64,7 +65,9 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
|
|
|
Future<void> _loadSettings() async {
|
|
|
_settings = await TimerSettings.loadSettings();
|
|
|
- setState(() {});
|
|
|
+ setState(() {
|
|
|
+ _settingsLoaded = true;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
void _startTimer() {
|
|
@@ -122,7 +125,7 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
|
|
|
// If loop is enabled, restart the timer
|
|
|
if (_settings.loop) {
|
|
|
- Future.delayed(Duration(seconds: 2), () {
|
|
|
+ Future.delayed(Duration(seconds: 5), () {
|
|
|
_audioManager.stopSound();
|
|
|
_audioManager.stopVibration();
|
|
|
_startTimer();
|
|
@@ -139,6 +142,10 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
+ if (!_settingsLoaded) {
|
|
|
+ return Center(child: CircularProgressIndicator());
|
|
|
+ }
|
|
|
+
|
|
|
if (_isRunning || _isCompleted) {
|
|
|
return _buildCountdownView();
|
|
|
} else {
|
|
@@ -319,9 +326,13 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
children: [
|
|
|
_buildCircleButton(
|
|
|
- Icons.stop,
|
|
|
- Colors.red,
|
|
|
- () => _resetTimer(),
|
|
|
+ Icons.phone_android,
|
|
|
+ Colors.grey[600]!,
|
|
|
+ () {
|
|
|
+ ScreenManager.toggleWakeLock();
|
|
|
+ setState(() {});
|
|
|
+ },
|
|
|
+ isActive: ScreenManager.isWakeLockEnabled,
|
|
|
),
|
|
|
_isRunning
|
|
|
? _buildCircleButton(
|
|
@@ -335,21 +346,9 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
() => _startTimer(),
|
|
|
),
|
|
|
_buildCircleButton(
|
|
|
- Icons.settings,
|
|
|
- Colors.grey[600]!,
|
|
|
- () async {
|
|
|
- final result = await Navigator.push(
|
|
|
- context,
|
|
|
- MaterialPageRoute(
|
|
|
- builder: (context) =>
|
|
|
- TimerSettingsPage(settings: _settings)),
|
|
|
- );
|
|
|
- if (result != null) {
|
|
|
- setState(() {
|
|
|
- _settings = result;
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
+ Icons.stop,
|
|
|
+ Colors.red,
|
|
|
+ () => _resetTimer(),
|
|
|
),
|
|
|
],
|
|
|
),
|
|
@@ -392,25 +391,52 @@ class _TimerPageState extends State<TimerPage> with WidgetsBindingObserver {
|
|
|
return Column(
|
|
|
children: [
|
|
|
Expanded(
|
|
|
- child: ListWheelScrollView(
|
|
|
- controller: controller,
|
|
|
- physics: FixedExtentScrollPhysics(),
|
|
|
- diameterRatio: 1.5,
|
|
|
- itemExtent: 50,
|
|
|
- children: items.map((value) {
|
|
|
- return Center(
|
|
|
- child: Text(
|
|
|
- value.toString().padLeft(2, '0'),
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 30,
|
|
|
- color: Colors.black,
|
|
|
+ child: Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ border: Border(
|
|
|
+ top: BorderSide(color: Colors.grey.withOpacity(0.3), width: 1),
|
|
|
+ bottom:
|
|
|
+ BorderSide(color: Colors.grey.withOpacity(0.3), width: 1),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ child: Stack(
|
|
|
+ children: [
|
|
|
+ // Center highlight
|
|
|
+ Positioned.fill(
|
|
|
+ child: Center(
|
|
|
+ child: Container(
|
|
|
+ height: 50,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Colors.blue.withOpacity(0.1),
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- );
|
|
|
- }).toList(),
|
|
|
- onSelectedItemChanged: onChanged,
|
|
|
+ ListWheelScrollView(
|
|
|
+ controller: controller,
|
|
|
+ physics: FixedExtentScrollPhysics(),
|
|
|
+ diameterRatio: 1.5,
|
|
|
+ itemExtent: 50,
|
|
|
+ children: items.map((value) {
|
|
|
+ return Center(
|
|
|
+ child: Text(
|
|
|
+ value.toString().padLeft(2, '0'),
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 30,
|
|
|
+ color: Colors.black,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }).toList(),
|
|
|
+ onSelectedItemChanged: onChanged,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
+ SizedBox(height: 8),
|
|
|
Text(
|
|
|
unit,
|
|
|
style: TextStyle(
|