diff --git a/lib/main.dart b/lib/main.dart index 734447d..bda138b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,8 +16,6 @@ import 'dart:convert'; /// - Add sunrise section and change app name to Sunshine Alarm? /// v1.0.0 /// - Follow system theme rather than using a custom theme. -/// v1.0.1 -/// - Use a timepicker if the user clicks on the sunset/sunrise time. /// :TBD void main() async { @@ -408,6 +406,26 @@ class _HomeScreenState extends State { labelText: 'Sunset Time (HH:MM)', border: OutlineInputBorder(), errorText: _sunsetErrorText, + suffixIcon: IconButton( + icon: Icon(Icons.access_time), + onPressed: () async { + final picked = await showTimePicker( + context: context, + initialTime: TimeOfDay.now(), + ); + if (picked != null) { + _sunsetController.text = + '${picked.hour.toString().padLeft(2, '0')}:' + '${picked.minute.toString().padLeft(2, '0')}'; + setState( + () => + _sunsetErrorText = _validateTime( + _sunsetController.text, + ), + ); + } + }, + ), ), onChanged: (v) { final val = _validateTime(v);