Skip to content

Commit b430928

Browse files
Merge branch 'main' into Minor-changes
2 parents d82ec5a + e888e8f commit b430928

File tree

5 files changed

+87
-12
lines changed

5 files changed

+87
-12
lines changed

lib/services/task_details.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import 'package:flutter/material.dart';
44
import 'package:built_collection/built_collection.dart';
55
import 'package:google_fonts/google_fonts.dart';
6+
import 'package:intl/intl.dart';
67
import 'package:taskwarrior/config/app_settings.dart';
78
import 'package:taskwarrior/model/storage/storage_widget.dart';
89
import 'package:taskwarrior/widgets/pallete.dart';
@@ -118,6 +119,12 @@ class _DetailRouteState extends State<DetailRoute> {
118119
);
119120
setState(() {});
120121
Navigator.of(context).pop();
122+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
123+
content: const Text('Task Updated'),
124+
backgroundColor: AppSettings.isDarkMode
125+
? const Color.fromARGB(255, 61, 61, 61)
126+
: const Color.fromARGB(255, 39, 39, 39),
127+
duration: const Duration(seconds: 2)));
121128
},
122129
child: const Text('Submit'),
123130
),
@@ -151,7 +158,8 @@ class AttributeWidget extends StatelessWidget {
151158
: DateTime.now().toUtc();
152159
var localValue = (value is DateTime)
153160
? // now = (value as DateTime).toLocal(),
154-
'${format.day}-${format.month}-${format.year} ${format.hour}:${format.minute}'
161+
// '${format.day}-${format.month}-${format.year} ${format.hour}:${format.minute}'
162+
DateFormat("dd-MM-yyyy HH:mm").format(value)
155163
: ((value is BuiltList) ? (value as BuiltList).toBuilder() : value);
156164
switch (name) {
157165
case 'description':

lib/views/profile/profile.dart

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,24 @@ class _ProfilePageState extends State<ProfilePage> {
7373
suggestedName: 'tasks-$now.txt',
7474
);
7575
},
76-
() => profilesWidget.copyConfigToNewProfile(currentProfile),
76+
() {
77+
try {
78+
profilesWidget.copyConfigToNewProfile(currentProfile);
79+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
80+
content: const Text('Profile Config Copied'),
81+
backgroundColor: AppSettings.isDarkMode
82+
? const Color.fromARGB(255, 61, 61, 61)
83+
: const Color.fromARGB(255, 39, 39, 39),
84+
duration: const Duration(seconds: 2)));
85+
} catch (e) {
86+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
87+
content: const Text('Profile Config Copy Failed'),
88+
backgroundColor: AppSettings.isDarkMode
89+
? const Color.fromARGB(255, 61, 61, 61)
90+
: const Color.fromARGB(255, 39, 39, 39),
91+
duration: const Duration(seconds: 2)));
92+
}
93+
},
7794
() => showDialog(
7895
context: context,
7996
builder: (context) => DeleteProfileDialog(
@@ -129,7 +146,24 @@ class ProfilesColumn extends StatelessWidget {
129146
height: 6,
130147
),
131148
ElevatedButton.icon(
132-
onPressed: addProfile,
149+
onPressed: () {
150+
try {
151+
addProfile();
152+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
153+
content: const Text('Profile Added Successfully'),
154+
backgroundColor: AppSettings.isDarkMode
155+
? const Color.fromARGB(255, 61, 61, 61)
156+
: const Color.fromARGB(255, 39, 39, 39),
157+
duration: const Duration(seconds: 2)));
158+
} catch (e) {
159+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
160+
content: const Text('Profile Additon Failed'),
161+
backgroundColor: AppSettings.isDarkMode
162+
? const Color.fromARGB(255, 61, 61, 61)
163+
: const Color.fromARGB(255, 39, 39, 39),
164+
duration: const Duration(seconds: 2)));
165+
}
166+
},
133167
icon: const Icon(Icons.add),
134168
label: const Text('Add new Profile'))
135169
],

lib/widgets/addTask.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
108108
);
109109
due = dateTime.toUtc();
110110
dueString = Jiffy(dateTime)
111-
.format('MMM do yyyy, h:mm:ss a');
111+
.format('dd/MM/yyyy HH:mm');
112112
}
113113
}
114114
setState(() {});
@@ -189,12 +189,12 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
189189
Widget buildAddButton(BuildContext context) {
190190
return TextButton(
191191
child: const Text("Add"),
192-
onPressed: () async {
192+
onPressed: () {
193193
try {
194-
formKey.currentState!.validate();
195-
var task = taskParser(namecontroller.text)
196-
.rebuild((b) => b..due = due)
197-
.rebuild((p) => p..priority = priority);
194+
if (formKey.currentState!.validate()) {
195+
var task = taskParser(namecontroller.text)
196+
.rebuild((b) => b..due = due)
197+
.rebuild((p) => p..priority = priority);
198198

199199
StorageWidget.of(context).mergeTask(task);
200200
//StorageWidget.of(context).mergeTask(prioritytask);
@@ -203,7 +203,19 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {
203203
priority = 'M';
204204
setState(() {});
205205
Navigator.of(context).pop();
206+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
207+
content: const Text('Task Added Successfully'),
208+
backgroundColor: AppSettings.isDarkMode
209+
? const Color.fromARGB(255, 61, 61, 61)
210+
: const Color.fromARGB(255, 39, 39, 39),
211+
duration: const Duration(seconds: 2)));
206212
} on FormatException catch (e) {
213+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
214+
content: const Text('Task Addition Failed'),
215+
backgroundColor: AppSettings.isDarkMode
216+
? const Color.fromARGB(255, 61, 61, 61)
217+
: const Color.fromARGB(255, 39, 39, 39),
218+
duration: const Duration(seconds: 2)));
207219
log(e.toString());
208220
}
209221
},

lib/widgets/profilefunctions/deleteprofiledialog.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:taskwarrior/config/app_settings.dart';
23
import 'package:taskwarrior/widgets/taskdetails/profiles_widget.dart';
34

45
class DeleteProfileDialog extends StatelessWidget {
@@ -25,8 +26,25 @@ class DeleteProfileDialog extends StatelessWidget {
2526
),
2627
ElevatedButton(
2728
onPressed: () {
28-
ProfilesWidget.of(context).deleteProfile(profile);
29-
Navigator.of(context).pop();
29+
try {
30+
ProfilesWidget.of(context).deleteProfile(profile);
31+
Navigator.of(context).pop();
32+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
33+
content: Text(
34+
'Profile: ${profile.characters} Deleted Successfully'),
35+
backgroundColor: AppSettings.isDarkMode
36+
? const Color.fromARGB(255, 61, 61, 61)
37+
: const Color.fromARGB(255, 39, 39, 39),
38+
duration: const Duration(seconds: 2)));
39+
} catch (e) {
40+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
41+
content:
42+
Text('Profile: ${profile.characters} Deletion Failed'),
43+
backgroundColor: AppSettings.isDarkMode
44+
? const Color.fromARGB(255, 61, 61, 61)
45+
: const Color.fromARGB(255, 39, 39, 39),
46+
duration: const Duration(seconds: 2)));
47+
}
3048
},
3149
child: const Text('Confirm'),
3250
),

lib/widgets/taskdetails/dateTimePicker.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ignore_for_file: file_names
22

33
import 'package:flutter/material.dart';
4+
import 'package:intl/intl.dart';
45
import 'package:taskwarrior/config/app_settings.dart';
56

67
class DateTimeWidget extends StatelessWidget {
@@ -36,7 +37,9 @@ class DateTimeWidget extends StatelessWidget {
3637
),
3738
),
3839
onTap: () async {
39-
var initialDate = DateTime.tryParse('$value') ?? DateTime.now();
40+
var initialDate = DateFormat("dd-MM-yyyy HH:mm").parse(
41+
value ?? DateFormat("dd-MM-yyyy HH:mm").format(DateTime.now()));
42+
// var initialDate = DateTime.tryParse('$value') ?? DateTime.now();
4043
var date = await showDatePicker(
4144
context: context,
4245
initialDate: initialDate,

0 commit comments

Comments
 (0)