main, put switch back on its own row. Yay!
This commit is contained in:
1 parent
21f7236957
commit
77e964a4c7
1 file changed
+69
-83
+69
-83
@@ -272,10 +272,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
);
|
);
|
||||||
} else if (Platform.isAndroid) {
|
} else if (Platform.isAndroid) {
|
||||||
// Get the Notifications permission:
|
// Get the Notifications permission:
|
||||||
final android = _notifications
|
final android =
|
||||||
.resolvePlatformSpecificImplementation<
|
_notifications
|
||||||
AndroidFlutterLocalNotificationsPlugin
|
.resolvePlatformSpecificImplementation<
|
||||||
>();
|
AndroidFlutterLocalNotificationsPlugin
|
||||||
|
>();
|
||||||
await android?.requestNotificationsPermission();
|
await android?.requestNotificationsPermission();
|
||||||
|
|
||||||
// Ensure that Android has the correct alarm permissions.
|
// Ensure that Android has the correct alarm permissions.
|
||||||
@@ -493,9 +494,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
'${picked.hour.toString().padLeft(2, '0')}:'
|
'${picked.hour.toString().padLeft(2, '0')}:'
|
||||||
'${picked.minute.toString().padLeft(2, '0')}';
|
'${picked.minute.toString().padLeft(2, '0')}';
|
||||||
setState(
|
setState(
|
||||||
() => _sunsetErrorText = _validateTime(
|
() =>
|
||||||
_sunsetController.text,
|
_sunsetErrorText = _validateTime(
|
||||||
),
|
_sunsetController.text,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (_alarmEnabled) {
|
if (_alarmEnabled) {
|
||||||
_scheduleAlarm();
|
_scheduleAlarm();
|
||||||
@@ -523,13 +525,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
IconButton.filledTonal(
|
IconButton.filledTonal(
|
||||||
icon: _loading
|
icon:
|
||||||
? const SizedBox(
|
_loading
|
||||||
width: 20,
|
? const SizedBox(
|
||||||
height: 20,
|
width: 20,
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
height: 20,
|
||||||
)
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
: const Icon(Icons.cloud_done_outlined),
|
)
|
||||||
|
: const Icon(Icons.cloud_done_outlined),
|
||||||
tooltip: 'Fetch Open-Meteo Sunset Data',
|
tooltip: 'Fetch Open-Meteo Sunset Data',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (!_loading) {
|
if (!_loading) {
|
||||||
@@ -548,69 +551,50 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// --- Minutes before ---
|
// --- Minutes before ---
|
||||||
Row(
|
TextField(
|
||||||
children: [
|
controller: _minutesController,
|
||||||
if (!_alarmEnabled)
|
keyboardType: TextInputType.number,
|
||||||
Expanded(
|
decoration: InputDecoration(
|
||||||
flex: 1, // _validTime ? 3 : 2,
|
border: OutlineInputBorder(),
|
||||||
child: TextField(
|
labelText: 'Minutes Before Sunset',
|
||||||
controller: _minutesController,
|
errorText: _minuteErrorText,
|
||||||
keyboardType: TextInputType.number,
|
),
|
||||||
decoration: InputDecoration(
|
onChanged: (v) {
|
||||||
border: OutlineInputBorder(),
|
final val = int.tryParse(v);
|
||||||
labelText: 'Minutes Before Sunset',
|
setState(() {
|
||||||
errorText: _minuteErrorText,
|
if (val != null) {
|
||||||
),
|
_minuteErrorText = null;
|
||||||
onChanged: (v) {
|
_minutesBefore = val;
|
||||||
final val = int.tryParse(v);
|
} else {
|
||||||
setState(() {
|
_minuteErrorText = 'Invalid Minute Value';
|
||||||
if (val != null) {
|
}
|
||||||
_minuteErrorText = null;
|
_calcPlural();
|
||||||
_minutesBefore = val;
|
});
|
||||||
} else {
|
},
|
||||||
_minuteErrorText = 'Invalid Minute Value';
|
),
|
||||||
}
|
|
||||||
_calcPlural();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
//Expanded(
|
// --- Toggle ---
|
||||||
// flex: 3,
|
SwitchListTile(
|
||||||
// child: Center(
|
title: Center(
|
||||||
// child:
|
child: Text(
|
||||||
// _validTime ? Text("") : Text("Sunset Time Needed") ,
|
_validTime
|
||||||
// ),
|
? _alarmEnabled
|
||||||
//),
|
? "Sunset Alarm Enabled"
|
||||||
|
: "Enable"
|
||||||
// --- Toggle ---
|
: "Disabled",
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
|
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<void> requestPermissions() async {
|
Future<void> requestPermissions() async {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
final android = _plugin
|
final android =
|
||||||
.resolvePlatformSpecificImplementation<
|
_plugin
|
||||||
AndroidFlutterLocalNotificationsPlugin
|
.resolvePlatformSpecificImplementation<
|
||||||
>();
|
AndroidFlutterLocalNotificationsPlugin
|
||||||
|
>();
|
||||||
|
|
||||||
// Android 13+ — standard notification permission (shows a dialog)
|
// Android 13+ — standard notification permission (shows a dialog)
|
||||||
await android?.requestNotificationsPermission();
|
await android?.requestNotificationsPermission();
|
||||||
@@ -652,7 +637,8 @@ Future<void> requestPermissions() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final android = _plugin
|
final android =
|
||||||
.resolvePlatformSpecificImplementation<
|
_plugin
|
||||||
AndroidFlutterLocalNotificationsPlugin
|
.resolvePlatformSpecificImplementation<
|
||||||
>();
|
AndroidFlutterLocalNotificationsPlugin
|
||||||
|
>();
|
||||||
Reference in new issue
Block a user