Skip to content

Commit c02c5bb

Browse files
committed
due time in the past - replacing snackbar
1 parent 0364e2a commit c02c5bb

File tree

3 files changed

+92
-42
lines changed

3 files changed

+92
-42
lines changed

lib/widgets/add_Task.dart

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously, file_names
22

33
import 'dart:developer';
4-
4+
import 'package:another_flushbar/flushbar.dart';
55
import 'package:flutter/material.dart';
66
import 'package:get/get.dart';
77
import 'package:google_fonts/google_fonts.dart';
@@ -12,7 +12,6 @@ import 'package:taskwarrior/config/taskwarriorcolors.dart';
1212
import 'package:taskwarrior/config/taskwarriorfonts.dart';
1313
import 'package:taskwarrior/controller/WidgetController.dart';
1414
import 'package:taskwarrior/model/storage/storage_widget.dart';
15-
import 'package:taskwarrior/utility/utilities.dart';
1615
import 'package:taskwarrior/widgets/taskfunctions/taskparser.dart';
1716
import '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
}

pubspec.lock

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ packages:
1717
url: "https://pub.dev"
1818
source: hosted
1919
version: "6.2.0"
20+
another_flushbar:
21+
dependency: "direct main"
22+
description:
23+
name: another_flushbar
24+
sha256: "19bf9520230ec40b300aaf9dd2a8fefcb277b25ecd1c4838f530566965befc2a"
25+
url: "https://pub.dev"
26+
source: hosted
27+
version: "1.12.30"
2028
ansicolor:
2129
dependency: transitive
2230
description:
@@ -624,6 +632,30 @@ packages:
624632
url: "https://pub.dev"
625633
source: hosted
626634
version: "4.8.1"
635+
leak_tracker:
636+
dependency: transitive
637+
description:
638+
name: leak_tracker
639+
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
640+
url: "https://pub.dev"
641+
source: hosted
642+
version: "10.0.0"
643+
leak_tracker_flutter_testing:
644+
dependency: transitive
645+
description:
646+
name: leak_tracker_flutter_testing
647+
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
648+
url: "https://pub.dev"
649+
source: hosted
650+
version: "2.0.1"
651+
leak_tracker_testing:
652+
dependency: transitive
653+
description:
654+
name: leak_tracker_testing
655+
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
656+
url: "https://pub.dev"
657+
source: hosted
658+
version: "2.0.1"
627659
lints:
628660
dependency: transitive
629661
description:
@@ -652,26 +684,26 @@ packages:
652684
dependency: transitive
653685
description:
654686
name: matcher
655-
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
687+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
656688
url: "https://pub.dev"
657689
source: hosted
658-
version: "0.12.16"
690+
version: "0.12.16+1"
659691
material_color_utilities:
660692
dependency: transitive
661693
description:
662694
name: material_color_utilities
663-
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
695+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
664696
url: "https://pub.dev"
665697
source: hosted
666-
version: "0.5.0"
698+
version: "0.8.0"
667699
meta:
668700
dependency: transitive
669701
description:
670702
name: meta
671-
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
703+
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
672704
url: "https://pub.dev"
673705
source: hosted
674-
version: "1.10.0"
706+
version: "1.11.0"
675707
mime:
676708
dependency: transitive
677709
description:
@@ -716,10 +748,10 @@ packages:
716748
dependency: transitive
717749
description:
718750
name: path
719-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
751+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
720752
url: "https://pub.dev"
721753
source: hosted
722-
version: "1.8.3"
754+
version: "1.9.0"
723755
path_parsing:
724756
dependency: transitive
725757
description:
@@ -1242,6 +1274,14 @@ packages:
12421274
url: "https://pub.dev"
12431275
source: hosted
12441276
version: "2.1.4"
1277+
vm_service:
1278+
dependency: transitive
1279+
description:
1280+
name: vm_service
1281+
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
1282+
url: "https://pub.dev"
1283+
source: hosted
1284+
version: "13.0.0"
12451285
watcher:
12461286
dependency: transitive
12471287
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies:
5656
crypto: ^3.0.1
5757
flutter_platform_widgets: ^6.0.2
5858
file_picker: ^6.1.1
59+
another_flushbar: ^1.12.30
5960

6061
dev_dependencies:
6162
build_runner: ^2.1.11

0 commit comments

Comments
 (0)