11// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously, file_names
22
33import 'dart:developer' ;
4-
4+ import 'package:another_flushbar/flushbar.dart' ;
55import 'package:flutter/material.dart' ;
66import 'package:get/get.dart' ;
77import 'package:google_fonts/google_fonts.dart' ;
@@ -12,7 +12,6 @@ import 'package:taskwarrior/config/taskwarriorcolors.dart';
1212import 'package:taskwarrior/config/taskwarriorfonts.dart' ;
1313import 'package:taskwarrior/controller/WidgetController.dart' ;
1414import 'package:taskwarrior/model/storage/storage_widget.dart' ;
15- import 'package:taskwarrior/utility/utilities.dart' ;
1615import 'package:taskwarrior/widgets/taskfunctions/taskparser.dart' ;
1716import 'package:taskwarrior/widgets/taskw.dart' ;
1817
@@ -31,6 +30,7 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
3130 String priority = 'M' ;
3231 final tagcontroller = TextEditingController ();
3332 List <String > tags = [];
33+ bool inThePast = false ;
3434
3535 @override
3636 void initState () {
@@ -47,10 +47,18 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
4747 @override
4848 Widget build (BuildContext context) {
4949 const title = 'Add Task' ;
50-
5150 return Center (
5251 child: SingleChildScrollView (
53- child: Utils .showAlertDialog (
52+ child: AlertDialog (
53+ surfaceTintColor: AppSettings .isDarkMode
54+ ? TaskWarriorColors .kdialogBackGroundColor
55+ : TaskWarriorColors .kLightDialogBackGroundColor,
56+ shadowColor: AppSettings .isDarkMode
57+ ? TaskWarriorColors .kdialogBackGroundColor
58+ : TaskWarriorColors .kLightDialogBackGroundColor,
59+ backgroundColor: AppSettings .isDarkMode
60+ ? TaskWarriorColors .kdialogBackGroundColor
61+ : TaskWarriorColors .kLightDialogBackGroundColor,
5462 title: Center (
5563 child: Text (
5664 title,
@@ -180,22 +188,26 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
180188 Expanded (
181189 child: GestureDetector (
182190 child: TextFormField (
183- style: TextStyle (
184- color: AppSettings .isDarkMode
185- ? TaskWarriorColors .white
186- : TaskWarriorColors .black,
187- ),
191+ style: inThePast
192+ ? TextStyle (color: TaskWarriorColors .red)
193+ : TextStyle (
194+ color: AppSettings .isDarkMode
195+ ? TaskWarriorColors .white
196+ : TaskWarriorColors .black,
197+ ),
188198 readOnly: true ,
189199 controller: TextEditingController (
190200 text: (due != null ) ? dueString : null ,
191201 ),
192202 decoration: InputDecoration (
193203 hintText: 'Select due date' ,
194- hintStyle: TextStyle (
195- color: AppSettings .isDarkMode
196- ? TaskWarriorColors .white
197- : TaskWarriorColors .black,
198- ),
204+ hintStyle: inThePast
205+ ? TextStyle (color: TaskWarriorColors .red)
206+ : TextStyle (
207+ color: AppSettings .isDarkMode
208+ ? TaskWarriorColors .white
209+ : TaskWarriorColors .black,
210+ ),
199211 ),
200212 onTap: () async {
201213 var date = await showDatePicker (
@@ -287,27 +299,24 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
287299 minutes: time.minute,
288300 ),
289301 );
290- if (dateTime.isAfter (DateTime .now ())) {
291- due = dateTime.toUtc ();
292-
293- dueString =
294- DateFormat ("dd-MM-yyyy HH:mm" ).format (dateTime);
295- setState (() {});
302+ due = dateTime.toUtc ();
303+ dueString =
304+ DateFormat ("dd-MM-yyyy HH:mm" ).format (dateTime);
305+ if (dateTime.isBefore (DateTime .now ())) {
306+ //Try changing the color. in the settings and Due display.
307+ setState (() {
308+ inThePast = true ;
309+ });
310+ //Replaced the snackBar to display message in the current context.
311+ // ignore: avoid_single_cascade_in_expression_statements
312+ Flushbar (
313+ message: 'The selected time is in the past' ,
314+ duration: const Duration (seconds: 3 ),
315+ )..show (context);
296316 } else {
297- ScaffoldMessenger .of (context).showSnackBar (SnackBar (
298- content: Text (
299- 'Please select a due date and time in the future.' ,
300- style: TextStyle (
301- color: AppSettings .isDarkMode
302- ? TaskWarriorColors .kprimaryTextColor
303- : TaskWarriorColors .kLightPrimaryTextColor,
304- ),
305- ),
306- backgroundColor: AppSettings .isDarkMode
307- ? TaskWarriorColors .ksecondaryBackgroundColor
308- : TaskWarriorColors
309- .kLightSecondaryBackgroundColor,
310- duration: const Duration (seconds: 2 )));
317+ setState (() {
318+ inThePast = false ;
319+ });
311320 }
312321 }
313322 }
0 commit comments