main, change toast phrasing to be consistent.
This commit is contained in:
1 parent
65ce0f8135
commit
7f908a7fab
1 file changed
+17
-17
+17
-17
@@ -13,9 +13,9 @@ import 'dart:convert';
|
|||||||
|
|
||||||
/// TBD:
|
/// TBD:
|
||||||
/// v0.3.0
|
/// v0.3.0
|
||||||
/// - Add sunrise section and change app name to Sunshine Alarm?
|
/// - Change sunset grabber to checkbox and retrieve it each alarm or open.
|
||||||
/// v1.0.0
|
/// v1.0.0
|
||||||
/// - Follow system theme rather than using a custom theme.
|
/// - Add sunrise section and change app name to Sunshine Alarm?
|
||||||
/// :TBD
|
/// :TBD
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@@ -133,14 +133,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
try {
|
try {
|
||||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
if (!serviceEnabled) {
|
if (!serviceEnabled) {
|
||||||
_showSnack('Location services are disabled.');
|
_showSnack('Location Services Disabled');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LocationPermission permission = await Geolocator.checkPermission();
|
LocationPermission permission = await Geolocator.checkPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
permission = await Geolocator.requestPermission();
|
permission = await Geolocator.requestPermission();
|
||||||
if (permission == LocationPermission.denied) {
|
if (permission == LocationPermission.denied) {
|
||||||
_showSnack('Location permission denied.');
|
_showSnack('Location Permission Denied');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,9 +152,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
_lngController.text = position.longitude.toString();
|
_lngController.text = position.longitude.toString();
|
||||||
});
|
});
|
||||||
await _savePrefs();
|
await _savePrefs();
|
||||||
_showSnack('Location updated.');
|
_showSnack('Location Updated.');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_showSnack('GPS error: $e');
|
_showSnack('GPS Error: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
final lat = double.tryParse(_latController.text);
|
final lat = double.tryParse(_latController.text);
|
||||||
final lng = double.tryParse(_lngController.text);
|
final lng = double.tryParse(_lngController.text);
|
||||||
if (lat == null || lng == null) {
|
if (lat == null || lng == null) {
|
||||||
_showSnack('Enter valid latitude and longitude first.');
|
_showSnack('Enter Valid Latitude & Longitude');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,12 +180,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
final timePart = sunsetStr.split('T')[1];
|
final timePart = sunsetStr.split('T')[1];
|
||||||
setState(() => _sunsetController.text = timePart);
|
setState(() => _sunsetController.text = timePart);
|
||||||
await _savePrefs();
|
await _savePrefs();
|
||||||
_showSnack('Sunset: $timePart');
|
_showSnack('Sunset Time Retrieved: $timePart');
|
||||||
} else {
|
} else {
|
||||||
_showSnack('API error: ${response.statusCode}');
|
_showSnack('API Error: ${response.statusCode}');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_showSnack('Network error: $e');
|
_showSnack('Network Error: $e');
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => _loading = false);
|
setState(() => _loading = false);
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
// Ensure that Android has the correct alarm permissions.
|
// Ensure that Android has the correct alarm permissions.
|
||||||
final canSchedule = await android?.canScheduleExactNotifications();
|
final canSchedule = await android?.canScheduleExactNotifications();
|
||||||
if (canSchedule != true) {
|
if (canSchedule != true) {
|
||||||
_showSnack('Permissions not yet granted, requesting...');
|
_showSnack('Permissions Need Granted, Requesting...');
|
||||||
await android?.requestExactAlarmsPermission();
|
await android?.requestExactAlarmsPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
alarmTime = alarmTime.subtract(Duration(minutes: _minutesBefore));
|
alarmTime = alarmTime.subtract(Duration(minutes: _minutesBefore));
|
||||||
|
|
||||||
if (alarmTime.isBefore(now)) {
|
if (alarmTime.isBefore(now)) {
|
||||||
_showSnack('Alarm time is in the past. Will fire tomorrow.');
|
_showSnack('Alarm Time In Past - Will Start Tomorrow');
|
||||||
alarmTime = alarmTime.add(const Duration(days: 1));
|
alarmTime = alarmTime.add(const Duration(days: 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,13 +242,13 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
);
|
);
|
||||||
_notifications.show(
|
_notifications.show(
|
||||||
id: _alarmId,
|
id: _alarmId,
|
||||||
title: 'Sunset in ${_minutesBefore} min',
|
title: 'Sunset in ${_minutesBefore} min!',
|
||||||
body: 'The sun sets at $sunsetText. Time to get ready!',
|
body: 'The sun sets at $sunsetText.',
|
||||||
notificationDetails: const NotificationDetails(linux: linuxDetails),
|
notificationDetails: const NotificationDetails(linux: linuxDetails),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
_showSnack(
|
_showSnack(
|
||||||
'Alarm set for ${alarmTime.hour.toString().padLeft(2, '0')}:${alarmTime.minute.toString().padLeft(2, '0')} (app must stay open)',
|
'Alarm Enabled @ ${alarmTime.hour.toString().padLeft(2, '0')}:${alarmTime.minute.toString().padLeft(2, '0')} (App Must Stay Open!)',
|
||||||
);
|
);
|
||||||
} else if (Platform.isAndroid) {
|
} else if (Platform.isAndroid) {
|
||||||
/*** Notifcation Method - Works *** /
|
/*** Notifcation Method - Works *** /
|
||||||
@@ -300,7 +300,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
// End Alarm Method ***/
|
// End Alarm Method ***/
|
||||||
_showSnack('Alarm Scheduled @ ${alarmTime}');
|
_showSnack('Alarm Scheduled @ ${alarmTime}');
|
||||||
} else {
|
} else {
|
||||||
_showSnack('Platform not detected, unsure how to show alarm.');
|
_showSnack('Platform Not Detected - Contact Developer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,7 +462,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
)
|
)
|
||||||
: const Icon(Icons.cloud_done_outlined),
|
: const Icon(Icons.cloud_done_outlined),
|
||||||
tooltip: 'Fetch Sunset Time from Open-Meteo',
|
tooltip: 'Fetch Open-Meteo Sunset Data',
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (!_loading) {
|
if (!_loading) {
|
||||||
_fetchSunset();
|
_fetchSunset();
|
||||||
|
|||||||
Reference in new issue
Block a user