Skip to content

Commit 66d3fdd

Browse files
snackbars
1 parent a4a87fd commit 66d3fdd

File tree

4 files changed

+74
-4
lines changed

4 files changed

+74
-4
lines changed

lib/services/task_details.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ class _DetailRouteState extends State<DetailRoute> {
118118
);
119119
setState(() {});
120120
Navigator.of(context).pop();
121+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
122+
content: const Text('Profile Updated'),
123+
backgroundColor: AppSettings.isDarkMode
124+
? const Color.fromARGB(255, 61, 61, 61)
125+
: const Color.fromARGB(255, 39, 39, 39),
126+
duration: const Duration(seconds: 2)));
121127
},
122128
child: const Text('Submit'),
123129
),

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
),

0 commit comments

Comments
 (0)