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:
|
/// TBD:
|
||||||
/// - Add other languages (Spanish, Croatian)
|
/// - Add other languages (Spanish, Croatian)
|
||||||
/// v1.1.0
|
/// 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.
|
/// - Change sunset grabber to checkbox and retrieve it each alarm or open.
|
||||||
/// v2.0.0
|
/// v2.0.0
|
||||||
/// - Add sunrise section and change app name to Sunshine Alarm?
|
/// - Add sunrise section and change app name to Sunshine Alarm?
|
||||||
@@ -270,11 +272,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
);
|
);
|
||||||
} else if (Platform.isAndroid) {
|
} else if (Platform.isAndroid) {
|
||||||
// Get the Notifications permission:
|
// Get the Notifications permission:
|
||||||
final android =
|
final android = _notifications
|
||||||
_notifications
|
.resolvePlatformSpecificImplementation<
|
||||||
.resolvePlatformSpecificImplementation<
|
AndroidFlutterLocalNotificationsPlugin
|
||||||
AndroidFlutterLocalNotificationsPlugin
|
>();
|
||||||
>();
|
|
||||||
await android?.requestNotificationsPermission();
|
await android?.requestNotificationsPermission();
|
||||||
|
|
||||||
// Ensure that Android has the correct alarm permissions.
|
// Ensure that Android has the correct alarm permissions.
|
||||||
@@ -492,10 +493,9 @@ 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(
|
||||||
_sunsetErrorText = _validateTime(
|
_sunsetController.text,
|
||||||
_sunsetController.text,
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
if (_alarmEnabled) {
|
if (_alarmEnabled) {
|
||||||
_scheduleAlarm();
|
_scheduleAlarm();
|
||||||
@@ -523,14 +523,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
IconButton.filledTonal(
|
IconButton.filledTonal(
|
||||||
icon:
|
icon: _loading
|
||||||
_loading
|
? const SizedBox(
|
||||||
? const SizedBox(
|
width: 20,
|
||||||
width: 20,
|
height: 20,
|
||||||
height: 20,
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
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) {
|
||||||
@@ -553,7 +552,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
children: [
|
children: [
|
||||||
if (!_alarmEnabled)
|
if (!_alarmEnabled)
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: _validTime ? 6 : 4,
|
flex: 1, // _validTime ? 3 : 2,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _minutesController,
|
controller: _minutesController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
@@ -587,24 +586,24 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
|
|
||||||
// --- Toggle ---
|
// --- Toggle ---
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: _validTime ? 7 : 5,
|
flex: 1, //_validTime ? 2 : 5,
|
||||||
child: SwitchListTile(
|
child: SwitchListTile(
|
||||||
title: Center(
|
title: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
_validTime
|
_validTime
|
||||||
? _alarmEnabled
|
? _alarmEnabled
|
||||||
? "Sunset Alarm Enabled"
|
? "Sunset Alarm Enabled"
|
||||||
: "Enable"
|
: "" //"Enable"
|
||||||
: "Disabled",
|
: "", // "Disabled",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
subtitle: Center(
|
subtitle: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
_validTime
|
_validTime
|
||||||
? _alarmEnabled
|
? _alarmEnabled
|
||||||
? "${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime"
|
? "${_minutesBefore} Minute${_plural} Before @ $_alarmDisplayTime"
|
||||||
: "Sunset Alarm"
|
: "" //"Sunset Alarm"
|
||||||
: "Enter Time",
|
: "", //"Enter Valid Time",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
value: _validTime ? _alarmEnabled : false,
|
value: _validTime ? _alarmEnabled : false,
|
||||||
@@ -640,11 +639,10 @@ final _plugin = FlutterLocalNotificationsPlugin();
|
|||||||
|
|
||||||
Future<void> requestPermissions() async {
|
Future<void> requestPermissions() async {
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
final android =
|
final android = _plugin
|
||||||
_plugin
|
.resolvePlatformSpecificImplementation<
|
||||||
.resolvePlatformSpecificImplementation<
|
AndroidFlutterLocalNotificationsPlugin
|
||||||
AndroidFlutterLocalNotificationsPlugin
|
>();
|
||||||
>();
|
|
||||||
|
|
||||||
// Android 13+ — standard notification permission (shows a dialog)
|
// Android 13+ — standard notification permission (shows a dialog)
|
||||||
await android?.requestNotificationsPermission();
|
await android?.requestNotificationsPermission();
|
||||||
@@ -654,8 +652,7 @@ Future<void> requestPermissions() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final android =
|
final android = _plugin
|
||||||
_plugin
|
.resolvePlatformSpecificImplementation<
|
||||||
.resolvePlatformSpecificImplementation<
|
AndroidFlutterLocalNotificationsPlugin
|
||||||
AndroidFlutterLocalNotificationsPlugin
|
>();
|
||||||
>();
|
|
||||||
Reference in new issue
Block a user