Compare commits
12
Commits
810788e30e
...
0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
952c0449d5 | ||
|
|
4b2f295fe7 | ||
|
|
0f979d3d31 | ||
|
|
4ba8777ca9 | ||
|
|
1064a0b33f | ||
|
|
718992eb42 | ||
|
|
bb396abe20 | ||
|
|
50cb05f3c9 | ||
|
|
e47c85b3d9 | ||
|
|
71e6f4e13d | ||
|
|
0e46307815 | ||
|
|
dc15af60dd |
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
# flutter_sunset_alarm
|
# sunset_alarm
|
||||||
|
|
||||||
Android app to set off an alarm a set number of hours before sunset if enabled
|
Android app to set off an alarm a set number of hours before sunset if enabled
|
||||||
manually or if the user has wandered a set distance away from the sunset
|
manually or if the user has wandered a set distance away from the sunset
|
||||||
|
|||||||
@@ -1 +1,10 @@
|
|||||||
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
- build/**
|
||||||
|
- android/**
|
||||||
|
- ios/**
|
||||||
|
- web/**
|
||||||
|
- windows/**
|
||||||
|
- macos/**
|
||||||
|
- linux/**
|
||||||
include: package:flutter_lints/flutter.yaml
|
include: package:flutter_lints/flutter.yaml
|
||||||
@@ -1,27 +1,36 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("kotlin-android")
|
|
||||||
|
// This will need removed in Gradle/AGP 9.
|
||||||
|
id("org.jetbrains.kotlin.android") // id("kotlin-android")
|
||||||
|
|
||||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||||
id("dev.flutter.flutter-gradle-plugin")
|
id("dev.flutter.flutter-gradle-plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.example.flutter_sunset_alarm"
|
namespace = "com.hyperling.sunset_alarm"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
isCoreLibraryDesugaringEnabled = true
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
// This will need removed in Gradle/AGP 9.
|
||||||
jvmTarget = JavaVersion.VERSION_11.toString()
|
kotlin {
|
||||||
|
compilerOptions {
|
||||||
|
jvmTarget.set(JvmTarget.JVM_17)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "com.example.flutter_sunset_alarm"
|
applicationId = "com.hyperling.sunset_alarm"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdk = flutter.minSdkVersion
|
minSdk = flutter.minSdkVersion
|
||||||
@@ -39,6 +48,10 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
|
||||||
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
source = "../.."
|
source = "../.."
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<application
|
<application
|
||||||
android:label="flutter_sunset_alarm"
|
android:label="sunset_alarm"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
@@ -46,5 +46,5 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
|
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.example.flutter_sunset_alarm
|
package com.hyperling.sunset_alarm
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
# This builtInKotlin flag was added automatically by Flutter migrator
|
||||||
|
android.builtInKotlin=false
|
||||||
|
# This newDsl flag was added automatically by Flutter migrator
|
||||||
|
android.newDsl=false
|
||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
|
#Sat Sep 12 19:36:23 MST 2026
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
|
||||||
|
#distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
|
|
||||||
@@ -18,8 +18,12 @@ pluginManagement {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||||
id("com.android.application") version "8.7.0" apply false
|
|
||||||
id("org.jetbrains.kotlin.android") version "1.8.22" apply false
|
id("com.android.application") version "9.4.0" apply false
|
||||||
|
//id("com.android.application") version "9.0.1" apply false
|
||||||
|
|
||||||
|
// This will need removed in Gradle/AGP 9.
|
||||||
|
id("org.jetbrains.kotlin.android") version "2.4.20" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>flutter_sunset_alarm</string>
|
<string>sunset_alarm</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
|
|||||||
+111
-69
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
@@ -41,6 +42,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
final _latController = TextEditingController();
|
final _latController = TextEditingController();
|
||||||
final _lngController = TextEditingController();
|
final _lngController = TextEditingController();
|
||||||
final _sunsetController = TextEditingController();
|
final _sunsetController = TextEditingController();
|
||||||
|
final _minutesController = TextEditingController(text: '30');
|
||||||
|
|
||||||
final FlutterLocalNotificationsPlugin _notifications =
|
final FlutterLocalNotificationsPlugin _notifications =
|
||||||
FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin();
|
||||||
@@ -59,13 +61,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initNotifications() async {
|
Future<void> _initNotifications() async {
|
||||||
const androidInit =
|
const androidInit = AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||||
AndroidInitializationSettings('@mipmap/ic_launcher');
|
const iosInit = DarwinInitializationSettings();
|
||||||
const linuxInit = DarwinInitializationSettings();
|
const linuxInit = LinuxInitializationSettings(
|
||||||
|
defaultActionName: 'Sunset Alarm',
|
||||||
|
);
|
||||||
await _notifications.initialize(
|
await _notifications.initialize(
|
||||||
const InitializationSettings(
|
const InitializationSettings(
|
||||||
android: androidInit,
|
android: androidInit,
|
||||||
iOS: linuxInit,
|
iOS: iosInit,
|
||||||
|
linux: linuxInit,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -81,6 +86,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
if (lat != null) _latController.text = lat.toString();
|
if (lat != null) _latController.text = lat.toString();
|
||||||
if (lng != null) _lngController.text = lng.toString();
|
if (lng != null) _lngController.text = lng.toString();
|
||||||
if (sunset != null) _sunsetController.text = sunset;
|
if (sunset != null) _sunsetController.text = sunset;
|
||||||
|
_minutesController.text = '$_minutesBefore';
|
||||||
});
|
});
|
||||||
if (_alarmEnabled && _sunsetController.text.isNotEmpty) {
|
if (_alarmEnabled && _sunsetController.text.isNotEmpty) {
|
||||||
_scheduleAlarm();
|
_scheduleAlarm();
|
||||||
@@ -148,7 +154,6 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = jsonDecode(response.body);
|
final data = jsonDecode(response.body);
|
||||||
final sunsetStr = data['daily']['sunset'][0] as String;
|
final sunsetStr = data['daily']['sunset'][0] as String;
|
||||||
// "2026-09-12T19:42" -> "19:42"
|
|
||||||
final timePart = sunsetStr.split('T')[1];
|
final timePart = sunsetStr.split('T')[1];
|
||||||
setState(() => _sunsetController.text = timePart);
|
setState(() => _sunsetController.text = timePart);
|
||||||
await _savePrefs();
|
await _savePrefs();
|
||||||
@@ -163,6 +168,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer? _alarmTimer;
|
||||||
|
|
||||||
Future<void> _scheduleAlarm() async {
|
Future<void> _scheduleAlarm() async {
|
||||||
final sunsetText = _sunsetController.text.trim();
|
final sunsetText = _sunsetController.text.trim();
|
||||||
if (sunsetText.isEmpty) return;
|
if (sunsetText.isEmpty) return;
|
||||||
@@ -175,12 +182,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
final m = int.parse(parts[1]);
|
final m = int.parse(parts[1]);
|
||||||
var alarmTime = DateTime(now.year, now.month, now.day, h, m);
|
var alarmTime = DateTime(now.year, now.month, now.day, h, m);
|
||||||
|
|
||||||
// If the alarm time has already passed today, schedule for tomorrow
|
|
||||||
if (alarmTime.isBefore(now)) {
|
if (alarmTime.isBefore(now)) {
|
||||||
alarmTime = alarmTime.add(const Duration(days: 1));
|
alarmTime = alarmTime.add(const Duration(days: 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subtract the "minutes before" offset
|
|
||||||
alarmTime = alarmTime.subtract(Duration(minutes: _minutesBefore));
|
alarmTime = alarmTime.subtract(Duration(minutes: _minutesBefore));
|
||||||
|
|
||||||
if (alarmTime.isBefore(now)) {
|
if (alarmTime.isBefore(now)) {
|
||||||
@@ -188,33 +192,50 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
alarmTime = alarmTime.add(const Duration(days: 1));
|
alarmTime = alarmTime.add(const Duration(days: 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
final tzAlarm = tz.TZDateTime.from(alarmTime, tz.local);
|
if (Platform.isLinux) {
|
||||||
|
// Linux: use a Timer (app must stay open)
|
||||||
const androidDetails = AndroidNotificationDetails(
|
_alarmTimer?.cancel();
|
||||||
'sunset_alarm',
|
final delay = alarmTime.difference(now);
|
||||||
'Sunset Alarm',
|
_alarmTimer = Timer(delay, () {
|
||||||
channelDescription: 'Alarm X minutes before sunset',
|
const linuxDetails = LinuxNotificationDetails(
|
||||||
importance: Importance.max,
|
urgency: LinuxNotificationUrgency.critical,
|
||||||
priority: Priority.high,
|
resident: true,
|
||||||
fullScreenIntent: true,
|
timeout: LinuxNotificationTimeout.expiresNever(),
|
||||||
category: AndroidNotificationCategory.alarm,
|
);
|
||||||
);
|
_notifications.show(
|
||||||
const linuxDetails = DarwinNotificationDetails(
|
_alarmId,
|
||||||
presentAlert: true,
|
'Sunset in ${_minutesBefore} min',
|
||||||
presentBadge: true,
|
'The sun sets at $sunsetText. Time to get ready!',
|
||||||
presentSound: true,
|
const NotificationDetails(linux: linuxDetails),
|
||||||
);
|
);
|
||||||
|
});
|
||||||
await _notifications.zonedSchedule(
|
_showSnack(
|
||||||
_alarmId,
|
'Alarm set for ${alarmTime.hour.toString().padLeft(2, '0')}:${alarmTime.minute.toString().padLeft(2, '0')} (app must stay open)',
|
||||||
'Sunset in ${_minutesBefore} min',
|
);
|
||||||
'The sun sets at $sunsetText. Time to get ready!',
|
} else {
|
||||||
tzAlarm,
|
// Android: use zonedSchedule (works in background)
|
||||||
NotificationDetails(android: androidDetails, iOS: linuxDetails),
|
final tzAlarm = tz.TZDateTime.from(alarmTime, tz.local);
|
||||||
androidScheduleMode: AndroidScheduleMode.alarmClock,
|
const androidDetails = AndroidNotificationDetails(
|
||||||
uiLocalNotificationDateInterpretation:
|
'sunset_alarm',
|
||||||
UILocalNotificationDateInterpretation.absoluteTime,
|
'Sunset Alarm',
|
||||||
);
|
channelDescription: 'Alarm X minutes before sunset',
|
||||||
|
importance: Importance.max,
|
||||||
|
priority: Priority.high,
|
||||||
|
fullScreenIntent: true,
|
||||||
|
category: AndroidNotificationCategory.alarm,
|
||||||
|
);
|
||||||
|
await _notifications.zonedSchedule(
|
||||||
|
_alarmId,
|
||||||
|
'Sunset in ${_minutesBefore} min',
|
||||||
|
'The sun sets at $sunsetText. Time to get ready!',
|
||||||
|
tzAlarm,
|
||||||
|
const NotificationDetails(android: androidDetails),
|
||||||
|
androidScheduleMode: AndroidScheduleMode.alarmClock,
|
||||||
|
uiLocalNotificationDateInterpretation:
|
||||||
|
UILocalNotificationDateInterpretation.absoluteTime,
|
||||||
|
);
|
||||||
|
_showSnack('Alarm scheduled.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _toggleAlarm(bool value) async {
|
Future<void> _toggleAlarm(bool value) async {
|
||||||
@@ -222,9 +243,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
await _savePrefs();
|
await _savePrefs();
|
||||||
if (value) {
|
if (value) {
|
||||||
await _scheduleAlarm();
|
await _scheduleAlarm();
|
||||||
_showSnack('Alarm scheduled.');
|
|
||||||
} else {
|
} else {
|
||||||
await _notifications.cancel(_alarmId);
|
_alarmTimer?.cancel();
|
||||||
|
if (!Platform.isLinux) {
|
||||||
|
await _notifications.cancel(_alarmId);
|
||||||
|
}
|
||||||
_showSnack('Alarm cancelled.');
|
_showSnack('Alarm cancelled.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,6 +261,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
_latController.dispose();
|
_latController.dispose();
|
||||||
_lngController.dispose();
|
_lngController.dispose();
|
||||||
_sunsetController.dispose();
|
_sunsetController.dispose();
|
||||||
|
_minutesController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,16 +275,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// --- Location section ---
|
// --- Location section ---
|
||||||
const Text('Location',
|
const Text(
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
'Location',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _latController,
|
controller: _latController,
|
||||||
keyboardType:
|
keyboardType: const TextInputType.numberWithOptions(
|
||||||
const TextInputType.numberWithOptions(signed: true, decimal: true),
|
signed: true,
|
||||||
|
decimal: true,
|
||||||
|
),
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Latitude',
|
labelText: 'Latitude',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
@@ -272,8 +300,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _lngController,
|
controller: _lngController,
|
||||||
keyboardType:
|
keyboardType: const TextInputType.numberWithOptions(
|
||||||
const TextInputType.numberWithOptions(signed: true, decimal: true),
|
signed: true,
|
||||||
|
decimal: true,
|
||||||
|
),
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Longitude',
|
labelText: 'Longitude',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
@@ -292,8 +322,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// --- Sunset time section ---
|
// --- Sunset time section ---
|
||||||
const Text('Sunset',
|
const Text(
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
'Sunset',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -309,13 +341,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 sunset from Open-Meteo',
|
tooltip: 'Fetch sunset from Open-Meteo',
|
||||||
onPressed: _loading ? null : _fetchSunset,
|
onPressed: _loading ? null : _fetchSunset,
|
||||||
),
|
),
|
||||||
@@ -324,8 +357,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// --- Minutes before ---
|
// --- Minutes before ---
|
||||||
const Text('Alert Before Sunset',
|
const Text(
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
'Alert Before Sunset',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -333,16 +368,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 80,
|
width: 80,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: TextEditingController(text: '$_minutesBefore'),
|
controller: _minutesController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
decoration:
|
decoration: const InputDecoration(
|
||||||
const InputDecoration(border: OutlineInputBorder()),
|
border: OutlineInputBorder(),
|
||||||
onEditingComplete: () async {
|
),
|
||||||
final val = int.tryParse(
|
onChanged: (v) {
|
||||||
(findContextController() as TextEditingController?)?.text ?? '');
|
final val = int.tryParse(v);
|
||||||
if (val != null && val > 0) {
|
if (val != null && val > 0) {
|
||||||
setState(() => _minutesBefore = val);
|
_minutesBefore = val;
|
||||||
await _savePrefs();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -356,7 +390,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
title: const Text('Enable Sunset Alarm'),
|
title: const Text('Enable Sunset Alarm'),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
_alarmEnabled
|
_alarmEnabled
|
||||||
? 'Will alert ${_minutesBefore} min before sunset'
|
? 'Will alert ${_minutesBefore} min before sunset. ($_alarmDisplayTime)'
|
||||||
: 'Alarm is off',
|
: 'Alarm is off',
|
||||||
),
|
),
|
||||||
value: _alarmEnabled,
|
value: _alarmEnabled,
|
||||||
@@ -368,10 +402,18 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to avoid recreating TextEditingController on each build
|
String get _alarmDisplayTime {
|
||||||
TextEditingController? _minutesController;
|
final sunsetText = _sunsetController.text.trim();
|
||||||
TextEditingController? findContextController() {
|
if (sunsetText.isEmpty) return '—';
|
||||||
_minutesController ??= TextEditingController(text: '$_minutesBefore');
|
final parts = sunsetText.split(':');
|
||||||
return _minutesController;
|
if (parts.length < 2) return '—';
|
||||||
|
final h = int.tryParse(parts[0]);
|
||||||
|
final m = int.tryParse(parts[1]);
|
||||||
|
if (h == null || m == null) return '—';
|
||||||
|
final alarmMinutes = h * 60 + m - _minutesBefore;
|
||||||
|
final displayMin = alarmMinutes % (24 * 60);
|
||||||
|
final dh = (displayMin ~/ 60) % 24;
|
||||||
|
final dm = displayMin % 60;
|
||||||
|
return '${dh.toString().padLeft(2, '0')}:${dm.toString().padLeft(2, '0')}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,10 @@ project(runner LANGUAGES CXX)
|
|||||||
|
|
||||||
# The name of the executable created for the application. Change this to change
|
# The name of the executable created for the application. Change this to change
|
||||||
# the on-disk name of your application.
|
# the on-disk name of your application.
|
||||||
set(BINARY_NAME "flutter_sunset_alarm")
|
set(BINARY_NAME "sunset_alarm")
|
||||||
# The unique GTK application identifier for this application. See:
|
# The unique GTK application identifier for this application. See:
|
||||||
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
|
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
|
||||||
set(APPLICATION_ID "com.example.flutter_sunset_alarm")
|
set(APPLICATION_ID "com.hyperling.sunset_alarm")
|
||||||
|
|
||||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||||
# versions of CMake.
|
# versions of CMake.
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ static void my_application_activate(GApplication* application) {
|
|||||||
if (use_header_bar) {
|
if (use_header_bar) {
|
||||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||||
gtk_header_bar_set_title(header_bar, "flutter_sunset_alarm");
|
gtk_header_bar_set_title(header_bar, "sunset_alarm");
|
||||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||||
} else {
|
} else {
|
||||||
gtk_window_set_title(window, "flutter_sunset_alarm");
|
gtk_window_set_title(window, "sunset_alarm");
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_default_size(window, 1280, 720);
|
gtk_window_set_default_size(window, 1280, 720);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
|
331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
|
||||||
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
|
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
|
||||||
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
|
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
|
||||||
33CC10ED2044A3C60003C045 /* flutter_sunset_alarm.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "flutter_sunset_alarm.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
33CC10ED2044A3C60003C045 /* sunset_alarm.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "sunset_alarm.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
|
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
|
||||||
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
33CC10EE2044A3C60003C045 /* Products */ = {
|
33CC10EE2044A3C60003C045 /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
33CC10ED2044A3C60003C045 /* flutter_sunset_alarm.app */,
|
33CC10ED2044A3C60003C045 /* sunset_alarm.app */,
|
||||||
331C80D5294CF71000263BE5 /* RunnerTests.xctest */,
|
331C80D5294CF71000263BE5 /* RunnerTests.xctest */,
|
||||||
);
|
);
|
||||||
name = Products;
|
name = Products;
|
||||||
@@ -217,7 +217,7 @@
|
|||||||
);
|
);
|
||||||
name = Runner;
|
name = Runner;
|
||||||
productName = Runner;
|
productName = Runner;
|
||||||
productReference = 33CC10ED2044A3C60003C045 /* flutter_sunset_alarm.app */;
|
productReference = 33CC10ED2044A3C60003C045 /* sunset_alarm.app */;
|
||||||
productType = "com.apple.product-type.application";
|
productType = "com.apple.product-type.application";
|
||||||
};
|
};
|
||||||
/* End PBXNativeTarget section */
|
/* End PBXNativeTarget section */
|
||||||
@@ -388,7 +388,7 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm.RunnerTests;
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm.RunnerTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_sunset_alarm.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_sunset_alarm";
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sunset_alarm.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sunset_alarm";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
};
|
};
|
||||||
@@ -402,7 +402,7 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm.RunnerTests;
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm.RunnerTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_sunset_alarm.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_sunset_alarm";
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sunset_alarm.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sunset_alarm";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
@@ -416,7 +416,7 @@
|
|||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm.RunnerTests;
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm.RunnerTests;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/flutter_sunset_alarm.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/flutter_sunset_alarm";
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sunset_alarm.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sunset_alarm";
|
||||||
};
|
};
|
||||||
name = Profile;
|
name = Profile;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "flutter_sunset_alarm.app"
|
BuildableName = "sunset_alarm.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "flutter_sunset_alarm.app"
|
BuildableName = "sunset_alarm.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "flutter_sunset_alarm.app"
|
BuildableName = "sunset_alarm.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "flutter_sunset_alarm.app"
|
BuildableName = "sunset_alarm.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
// 'flutter create' template.
|
// 'flutter create' template.
|
||||||
|
|
||||||
// The application's name. By default this is also the title of the Flutter window.
|
// The application's name. By default this is also the title of the Flutter window.
|
||||||
PRODUCT_NAME = flutter_sunset_alarm
|
PRODUCT_NAME = sunset_alarm
|
||||||
|
|
||||||
// The application's bundle identifier
|
// The application's bundle identifier
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterSunsetAlarm
|
||||||
|
|||||||
+2
-2
@@ -23,13 +23,13 @@
|
|||||||
<!-- iOS meta tags & icons -->
|
<!-- iOS meta tags & icons -->
|
||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
<meta name="apple-mobile-web-app-title" content="flutter_sunset_alarm">
|
<meta name="apple-mobile-web-app-title" content="sunset_alarm">
|
||||||
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
||||||
|
|
||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
<link rel="icon" type="image/png" href="favicon.png"/>
|
<link rel="icon" type="image/png" href="favicon.png"/>
|
||||||
|
|
||||||
<title>flutter_sunset_alarm</title>
|
<title>sunset_alarm</title>
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="manifest.json">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "flutter_sunset_alarm",
|
"name": "sunset_alarm",
|
||||||
"short_name": "flutter_sunset_alarm",
|
"short_name": "sunset_alarm",
|
||||||
"start_url": ".",
|
"start_url": ".",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"background_color": "#0175C2",
|
"background_color": "#0175C2",
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# Project-level configuration.
|
# Project-level configuration.
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(flutter_sunset_alarm LANGUAGES CXX)
|
project(sunset_alarm LANGUAGES CXX)
|
||||||
|
|
||||||
# The name of the executable created for the application. Change this to change
|
# The name of the executable created for the application. Change this to change
|
||||||
# the on-disk name of your application.
|
# the on-disk name of your application.
|
||||||
set(BINARY_NAME "flutter_sunset_alarm")
|
set(BINARY_NAME "sunset_alarm")
|
||||||
|
|
||||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||||
# versions of CMake.
|
# versions of CMake.
|
||||||
|
|||||||
@@ -90,12 +90,12 @@ BEGIN
|
|||||||
BLOCK "040904e4"
|
BLOCK "040904e4"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "com.example" "\0"
|
VALUE "CompanyName", "com.example" "\0"
|
||||||
VALUE "FileDescription", "flutter_sunset_alarm" "\0"
|
VALUE "FileDescription", "sunset_alarm" "\0"
|
||||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||||
VALUE "InternalName", "flutter_sunset_alarm" "\0"
|
VALUE "InternalName", "sunset_alarm" "\0"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0"
|
VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0"
|
||||||
VALUE "OriginalFilename", "flutter_sunset_alarm.exe" "\0"
|
VALUE "OriginalFilename", "sunset_alarm.exe" "\0"
|
||||||
VALUE "ProductName", "flutter_sunset_alarm" "\0"
|
VALUE "ProductName", "sunset_alarm" "\0"
|
||||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
FlutterWindow window(project);
|
FlutterWindow window(project);
|
||||||
Win32Window::Point origin(10, 10);
|
Win32Window::Point origin(10, 10);
|
||||||
Win32Window::Size size(1280, 720);
|
Win32Window::Size size(1280, 720);
|
||||||
if (!window.Create(L"flutter_sunset_alarm", origin, size)) {
|
if (!window.Create(L"sunset_alarm", origin, size)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
window.SetQuitOnClose(true);
|
window.SetQuitOnClose(true);
|
||||||
|
|||||||
Reference in new issue
Block a user