From 77e964a4c7b0caee1cd9c93f50aa467a7fc6f4eb Mon Sep 17 00:00:00 2001 From: Hyperling Date: Tue, 29 Sep 2026 18:31:56 -0700 Subject: [PATCH] main, put switch back on its own row. Yay! --- lib/main.dart | 152 +++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 83 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 8bd76ef..b0452e7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -272,10 +272,11 @@ class _HomeScreenState extends State { ); } else if (Platform.isAndroid) { // Get the Notifications permission: - final android = _notifications - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin - >(); + final android = + _notifications + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin + >(); await android?.requestNotificationsPermission(); // Ensure that Android has the correct alarm permissions. @@ -493,9 +494,10 @@ class _HomeScreenState extends State { '${picked.hour.toString().padLeft(2, '0')}:' '${picked.minute.toString().padLeft(2, '0')}'; setState( - () => _sunsetErrorText = _validateTime( - _sunsetController.text, - ), + () => + _sunsetErrorText = _validateTime( + _sunsetController.text, + ), ); if (_alarmEnabled) { _scheduleAlarm(); @@ -523,13 +525,14 @@ class _HomeScreenState extends State { ), const SizedBox(width: 8), IconButton.filledTonal( - icon: _loading - ? const SizedBox( - width: 20, - height: 20, - child: CircularProgressIndicator(strokeWidth: 2), - ) - : const Icon(Icons.cloud_done_outlined), + icon: + _loading + ? const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator(strokeWidth: 2), + ) + : const Icon(Icons.cloud_done_outlined), tooltip: 'Fetch Open-Meteo Sunset Data', onPressed: () { if (!_loading) { @@ -548,69 +551,50 @@ class _HomeScreenState extends State { const SizedBox(height: 8), // --- Minutes before --- - Row( - children: [ - if (!_alarmEnabled) - Expanded( - flex: 1, // _validTime ? 3 : 2, - child: TextField( - controller: _minutesController, - keyboardType: TextInputType.number, - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Minutes Before Sunset', - errorText: _minuteErrorText, - ), - onChanged: (v) { - final val = int.tryParse(v); - setState(() { - if (val != null) { - _minuteErrorText = null; - _minutesBefore = val; - } else { - _minuteErrorText = 'Invalid Minute Value'; - } - _calcPlural(); - }); - }, - ), - ), + TextField( + controller: _minutesController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Minutes Before Sunset', + errorText: _minuteErrorText, + ), + onChanged: (v) { + final val = int.tryParse(v); + setState(() { + if (val != null) { + _minuteErrorText = null; + _minutesBefore = val; + } else { + _minuteErrorText = 'Invalid Minute Value'; + } + _calcPlural(); + }); + }, + ), - //Expanded( - // flex: 3, - // child: Center( - // child: - // _validTime ? Text("") : Text("Sunset Time Needed") , - // ), - //), - - // --- Toggle --- - Expanded( - flex: 1, //_validTime ? 2 : 5, - child: SwitchListTile( - title: Center( - child: Text( - _validTime - ? _alarmEnabled - ? "Sunset Alarm Enabled" - : "" //"Enable" - : "", // "Disabled", - ), - ), - subtitle: Center( - child: Text( - _validTime - ? _alarmEnabled - ? "${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime" - : "" //"Sunset Alarm" - : "", //"Enter Valid Time", - ), - ), - value: _validTime ? _alarmEnabled : false, - onChanged: _validTime ? _toggleAlarm : null, - ), + // --- Toggle --- + SwitchListTile( + title: Center( + child: Text( + _validTime + ? _alarmEnabled + ? "Sunset Alarm Enabled" + : "Enable" + : "Disabled", ), - ], + ), + subtitle: Center( + child: Text( + _validTime + ? _alarmEnabled + ? "${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime" + : "Sunset Alarm" + : "Enter Valid Time", + ), + ), + value: _validTime ? _alarmEnabled : false, + onChanged: _validTime ? _toggleAlarm : null, ), ], ), @@ -639,10 +623,11 @@ final _plugin = FlutterLocalNotificationsPlugin(); Future requestPermissions() async { if (Platform.isAndroid) { - final android = _plugin - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin - >(); + final android = + _plugin + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin + >(); // Android 13+ — standard notification permission (shows a dialog) await android?.requestNotificationsPermission(); @@ -652,7 +637,8 @@ Future requestPermissions() async { } } -final android = _plugin - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin - >(); +final android = + _plugin + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin + >();