main, forget about the switch title fanciness for now, will make them different rows in a future version and handle minutes dynamically.
This commit is contained in:
1 parent
b02a6ff80a
commit
4f15f94629
1 file changed
+32
-35
+32
-35
@@ -20,6 +20,8 @@ import 'package:flutter/services.dart' show rootBundle;
|
||||
/// TBD:
|
||||
/// - Add other languages (Spanish, Croatian)
|
||||
/// v1.1.0
|
||||
/// - Move the switchtile back to its own row so that it handles titles better.
|
||||
/// v1.2.0
|
||||
/// - Change sunset grabber to checkbox and retrieve it each alarm or open.
|
||||
/// v2.0.0
|
||||
/// - Add sunrise section and change app name to Sunshine Alarm?
|
||||
@@ -270,11 +272,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
);
|
||||
} 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.
|
||||
@@ -492,10 +493,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
'${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,14 +523,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
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) {
|
||||
@@ -553,7 +552,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
children: [
|
||||
if (!_alarmEnabled)
|
||||
Expanded(
|
||||
flex: _validTime ? 6 : 4,
|
||||
flex: 1, // _validTime ? 3 : 2,
|
||||
child: TextField(
|
||||
controller: _minutesController,
|
||||
keyboardType: TextInputType.number,
|
||||
@@ -587,24 +586,24 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
// --- Toggle ---
|
||||
Expanded(
|
||||
flex: _validTime ? 7 : 5,
|
||||
flex: 1, //_validTime ? 2 : 5,
|
||||
child: SwitchListTile(
|
||||
title: Center(
|
||||
child: Text(
|
||||
_validTime
|
||||
? _alarmEnabled
|
||||
? "Sunset Alarm Enabled"
|
||||
: "Enable"
|
||||
: "Disabled",
|
||||
? "Sunset Alarm Enabled"
|
||||
: "" //"Enable"
|
||||
: "", // "Disabled",
|
||||
),
|
||||
),
|
||||
subtitle: Center(
|
||||
child: Text(
|
||||
_validTime
|
||||
? _alarmEnabled
|
||||
? "${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime"
|
||||
: "Sunset Alarm"
|
||||
: "Enter Time",
|
||||
? "${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime"
|
||||
: "" //"Sunset Alarm"
|
||||
: "", //"Enter Valid Time",
|
||||
),
|
||||
),
|
||||
value: _validTime ? _alarmEnabled : false,
|
||||
@@ -640,11 +639,10 @@ final _plugin = FlutterLocalNotificationsPlugin();
|
||||
|
||||
Future<void> 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();
|
||||
@@ -654,8 +652,7 @@ Future<void> requestPermissions() async {
|
||||
}
|
||||
}
|
||||
|
||||
final android =
|
||||
_plugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin
|
||||
>();
|
||||
final android = _plugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin
|
||||
>();
|
||||
Reference in new issue
Block a user