main, swap the switch with text rather than disabling, allows giving a better error message.

This commit is contained in:
me committed 2026-09-29 13:29:24 -07:00
1 parent 436c96285c
commit 0e481f13cc
1 file changed
+16 -11
+16 -11
View File
@@ -79,8 +79,8 @@ class HomeScreen extends StatefulWidget {
class _HomeScreenState extends State<HomeScreen> { class _HomeScreenState extends State<HomeScreen> {
final _latController = TextEditingController(); final _latController = TextEditingController();
final _lngController = TextEditingController(); final _lngController = TextEditingController();
final _sunsetController = TextEditingController(); final _sunsetController = TextEditingController(text: "18:00");
final _minutesController = TextEditingController(text: '30'); final _minutesController = TextEditingController(text: "30");
final FlutterLocalNotificationsPlugin _notifications = final FlutterLocalNotificationsPlugin _notifications =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();
@@ -559,18 +559,23 @@ class _HomeScreenState extends State<HomeScreen> {
// --- Toggle --- // --- Toggle ---
Expanded( Expanded(
child: SwitchListTile( child:
//title: const Text('Enable Sunset Alarm'), _validTime
title: Text(_alarmEnabled ? 'Sunset Alarm Enabled' : ""), ? SwitchListTile(
title: Text(
_alarmEnabled ? 'Sunset Alarm Enabled' : "",
),
subtitle: Text( subtitle: Text(
_alarmEnabled _validTime
? _alarmEnabled
? '${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime' ? '${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime'
: "", : ""
: "Add Time",
), ),
value: _validTime ? _alarmEnabled : false, value: _alarmEnabled,
// If _isDataLoaded is false, onChanged is null, disabling the switch onChanged: _toggleAlarm,
onChanged: _validTime ? _toggleAlarm : null, )
), : Center(child: Text("Sunset Time Invalid")),
), ),
], ],
), ),