1
1
// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously, file_names
2
2
3
3
import 'dart:developer' ;
4
-
5
4
import 'package:flutter/material.dart' ;
6
5
import 'package:get/get.dart' ;
7
6
import 'package:google_fonts/google_fonts.dart' ;
@@ -12,7 +11,6 @@ import 'package:taskwarrior/config/taskwarriorcolors.dart';
12
11
import 'package:taskwarrior/config/taskwarriorfonts.dart' ;
13
12
import 'package:taskwarrior/controller/WidgetController.dart' ;
14
13
import 'package:taskwarrior/model/storage/storage_widget.dart' ;
15
- import 'package:taskwarrior/utility/utilities.dart' ;
16
14
import 'package:taskwarrior/widgets/taskfunctions/taskparser.dart' ;
17
15
import 'package:taskwarrior/widgets/taskw.dart' ;
18
16
@@ -31,6 +29,7 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
31
29
String priority = 'M' ;
32
30
final tagcontroller = TextEditingController ();
33
31
List <String > tags = [];
32
+ bool inThePast = false ;
34
33
35
34
@override
36
35
void initState () {
@@ -47,42 +46,53 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
47
46
@override
48
47
Widget build (BuildContext context) {
49
48
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
+ ),
61
71
),
62
72
),
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
+ ) ,
79
89
),
80
90
),
91
+ actions: < Widget > [
92
+ buildCancelButton (context),
93
+ buildAddButton (context),
94
+ ],
81
95
),
82
- actions: < Widget > [
83
- buildCancelButton (context),
84
- buildAddButton (context),
85
- ],
86
96
),
87
97
),
88
98
);
@@ -180,22 +190,26 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
180
190
Expanded (
181
191
child: GestureDetector (
182
192
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
+ ),
188
200
readOnly: true ,
189
201
controller: TextEditingController (
190
202
text: (due != null ) ? dueString : null ,
191
203
),
192
204
decoration: InputDecoration (
193
205
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
+ ),
199
213
),
200
214
onTap: () async {
201
215
var date = await showDatePicker (
@@ -287,16 +301,18 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
287
301
minutes: time.minute,
288
302
),
289
303
);
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
+ });
292
312
293
- dueString =
294
- DateFormat ("dd-MM-yyyy HH:mm" ).format (dateTime);
295
- setState (() {});
296
- } else {
297
313
ScaffoldMessenger .of (context).showSnackBar (SnackBar (
298
314
content: Text (
299
- 'Please select a due date and time in the future.' ,
315
+ "The selected time is in the past." ,
300
316
style: TextStyle (
301
317
color: AppSettings .isDarkMode
302
318
? TaskWarriorColors .kprimaryTextColor
@@ -308,7 +324,13 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
308
324
: TaskWarriorColors
309
325
.kLightSecondaryBackgroundColor,
310
326
duration: const Duration (seconds: 2 )));
327
+ } else {
328
+ setState (() {
329
+ inThePast = false ;
330
+ });
311
331
}
332
+
333
+ // setState(() {});
312
334
}
313
335
}
314
336
},
0 commit comments