1.0.0 #2
+23
-6
@@ -12,9 +12,6 @@ import 'package:alarm/alarm.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
/// TBD:
|
||||
/// v0.2.1
|
||||
/// - Fix time to get 0 prefixed if before 10:00 (5:30 becomes 05:30).
|
||||
/// - Fix time to validate properly rather than allowing garbage (error 530).
|
||||
/// v0.3.0
|
||||
/// - Add sunrise section and change app name to Sunshine Alarm?
|
||||
/// v1.0.0
|
||||
@@ -312,7 +309,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
// Alarm Method
|
||||
await Alarm.stop(_alarmId);
|
||||
}
|
||||
_showSnack('Alarm cancelled.');
|
||||
_showSnack('Alarm Cancelled');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,6 +326,17 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
String? _validateTime(String? value) {
|
||||
if (value == null || !RegExp(r'^\d{2}:\d{2}$').hasMatch(value)) {
|
||||
return 'Use HH:MM Format';
|
||||
}
|
||||
final h = int.parse(value.substring(0, 2));
|
||||
final m = int.parse(value.substring(3, 5));
|
||||
if (h > 23) return 'Hour Must Be 0–23';
|
||||
if (m > 59) return 'Minute Must Be 0–59';
|
||||
return null; // valid
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -396,11 +404,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _sunsetController,
|
||||
decoration: const InputDecoration(
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Sunset Time (HH:MM)',
|
||||
border: OutlineInputBorder(),
|
||||
errorText: _sunsetErrorText,
|
||||
),
|
||||
onChanged: (_) => _savePrefs(),
|
||||
onChanged: (v) {
|
||||
final val = _validateTime(v);
|
||||
if (val == null) {
|
||||
_savePrefs();
|
||||
}
|
||||
setState(() {
|
||||
_sunsetErrorText = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
Reference in new issue
Block a user