11// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously, file_names
22
33import 'dart:developer' ;
4-
54import 'package:flutter/material.dart' ;
65import 'package:get/get.dart' ;
76import 'package:google_fonts/google_fonts.dart' ;
@@ -12,7 +11,6 @@ import 'package:taskwarrior/config/taskwarriorcolors.dart';
1211import 'package:taskwarrior/config/taskwarriorfonts.dart' ;
1312import 'package:taskwarrior/controller/WidgetController.dart' ;
1413import 'package:taskwarrior/model/storage/storage_widget.dart' ;
15- import 'package:taskwarrior/utility/utilities.dart' ;
1614import 'package:taskwarrior/widgets/taskfunctions/taskparser.dart' ;
1715import 'package:taskwarrior/widgets/taskw.dart' ;
1816
@@ -31,6 +29,7 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
3129 String priority = 'M' ;
3230 final tagcontroller = TextEditingController ();
3331 List <String > tags = [];
32+ bool inThePast = false ;
3433
3534 @override
3635 void initState () {
@@ -47,42 +46,53 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
4746 @override
4847 Widget build (BuildContext context) {
4948 const title = 'Add Task' ;
50-
51- return Center (
52- child: SingleChildScrollView (
53- child: Utils .showAlertDialog (
54- title: Center (
55- child: Text (
56- title,
57- style: TextStyle (
58- color: AppSettings .isDarkMode
59- ? TaskWarriorColors .white
60- : TaskWarriorColors .black,
49+ return Scaffold (
50+ backgroundColor: Colors .transparent,
51+ body: Center (
52+ child: SingleChildScrollView (
53+ child: AlertDialog (
54+ surfaceTintColor: AppSettings .isDarkMode
55+ ? TaskWarriorColors .kdialogBackGroundColor
56+ : TaskWarriorColors .kLightDialogBackGroundColor,
57+ shadowColor: AppSettings .isDarkMode
58+ ? TaskWarriorColors .kdialogBackGroundColor
59+ : TaskWarriorColors .kLightDialogBackGroundColor,
60+ backgroundColor: AppSettings .isDarkMode
61+ ? TaskWarriorColors .kdialogBackGroundColor
62+ : TaskWarriorColors .kLightDialogBackGroundColor,
63+ title: Center (
64+ child: Text (
65+ title,
66+ style: TextStyle (
67+ color: AppSettings .isDarkMode
68+ ? TaskWarriorColors .white
69+ : TaskWarriorColors .black,
70+ ),
6171 ),
6272 ),
63- ),
64- content : Form (
65- key : formKey,
66- child : SizedBox (
67- width : MediaQuery . of (context).size.width * 0.8 ,
68- child : Column (
69- mainAxisSize : MainAxisSize .min,
70- children : < Widget > [
71- const SizedBox (height : 8 ),
72- buildName ( ),
73- const SizedBox (height : 12 ),
74- buildDueDate (context ),
75- const SizedBox (height : 8 ),
76- buildPriority (),
77- buildTags () ,
78- ] ,
73+ content : Form (
74+ key : formKey,
75+ child : SizedBox (
76+ width : MediaQuery . of (context).size.width * 0.8 ,
77+ child : Column (
78+ mainAxisSize : MainAxisSize .min,
79+ children : < Widget > [
80+ const SizedBox (height : 8 ),
81+ buildName ( ),
82+ const SizedBox (height : 12 ),
83+ buildDueDate (context ),
84+ const SizedBox (height : 8 ),
85+ buildPriority ( ),
86+ buildTags (),
87+ ] ,
88+ ) ,
7989 ),
8090 ),
91+ actions: < Widget > [
92+ buildCancelButton (context),
93+ buildAddButton (context),
94+ ],
8195 ),
82- actions: < Widget > [
83- buildCancelButton (context),
84- buildAddButton (context),
85- ],
8696 ),
8797 ),
8898 );
@@ -180,22 +190,26 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
180190 Expanded (
181191 child: GestureDetector (
182192 child: TextFormField (
183- style: TextStyle (
184- color: AppSettings .isDarkMode
185- ? TaskWarriorColors .white
186- : TaskWarriorColors .black,
187- ),
193+ style: inThePast
194+ ? TextStyle (color: TaskWarriorColors .red)
195+ : TextStyle (
196+ color: AppSettings .isDarkMode
197+ ? TaskWarriorColors .white
198+ : TaskWarriorColors .black,
199+ ),
188200 readOnly: true ,
189201 controller: TextEditingController (
190202 text: (due != null ) ? dueString : null ,
191203 ),
192204 decoration: InputDecoration (
193205 hintText: 'Select due date' ,
194- hintStyle: TextStyle (
195- color: AppSettings .isDarkMode
196- ? TaskWarriorColors .white
197- : TaskWarriorColors .black,
198- ),
206+ hintStyle: inThePast
207+ ? TextStyle (color: TaskWarriorColors .red)
208+ : TextStyle (
209+ color: AppSettings .isDarkMode
210+ ? TaskWarriorColors .white
211+ : TaskWarriorColors .black,
212+ ),
199213 ),
200214 onTap: () async {
201215 var date = await showDatePicker (
@@ -287,16 +301,18 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
287301 minutes: time.minute,
288302 ),
289303 );
290- if (dateTime.isAfter (DateTime .now ())) {
291- due = dateTime.toUtc ();
304+ due = dateTime.toUtc ();
305+ dueString =
306+ DateFormat ("dd-MM-yyyy HH:mm" ).format (dateTime);
307+ if (dateTime.isBefore (DateTime .now ())) {
308+ //Try changing the color. in the settings and Due display.
309+ setState (() {
310+ inThePast = true ;
311+ });
292312
293- dueString =
294- DateFormat ("dd-MM-yyyy HH:mm" ).format (dateTime);
295- setState (() {});
296- } else {
297313 ScaffoldMessenger .of (context).showSnackBar (SnackBar (
298314 content: Text (
299- 'Please select a due date and time in the future.' ,
315+ "The selected time is in the past." ,
300316 style: TextStyle (
301317 color: AppSettings .isDarkMode
302318 ? TaskWarriorColors .kprimaryTextColor
@@ -308,7 +324,13 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
308324 : TaskWarriorColors
309325 .kLightSecondaryBackgroundColor,
310326 duration: const Duration (seconds: 2 )));
327+ } else {
328+ setState (() {
329+ inThePast = false ;
330+ });
311331 }
332+
333+ // setState(() {});
312334 }
313335 }
314336 },
0 commit comments