Skip to content

Commit c8f81c9

Browse files
author
IanTapply22
committed
Version 1.0.1 final
- Made a show conformation dialog when resetting all fields.
1 parent 2bc6156 commit c8f81c9

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

lib/main.dart

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class _HomeScreenState extends State<HomeScreen> {
114114
backgroundColor: AppStyle.textInputColorLight,
115115
),
116116
onPressed: () {
117-
resetAllFields();
117+
showConformationDialog(context);
118118
},
119119
child: const Text(
120120
'Reset All Fields',
@@ -198,6 +198,7 @@ class _HomeScreenState extends State<HomeScreen> {
198198
));
199199
}
200200

201+
/// Resets all fields that the user has put information into
201202
void resetAllFields() {
202203
setState(() {
203204
TeamAndMatchData.initials = "";
@@ -242,6 +243,42 @@ class _HomeScreenState extends State<HomeScreen> {
242243
});
243244
}
244245

246+
/// Shows alert dialog for resetting all fields
247+
showConformationDialog(BuildContext context) {
248+
// set up the buttons
249+
Widget cancelButton = TextButton(
250+
child: const Text("No"),
251+
onPressed: () {
252+
Navigator.of(context, rootNavigator: true).pop('dialog');
253+
},
254+
);
255+
Widget continueButton = TextButton(
256+
child: const Text("Yes"),
257+
onPressed: () {
258+
resetAllFields();
259+
Navigator.of(context, rootNavigator: true).pop('dialog');
260+
Navigator.push(context, MaterialPageRoute(builder: (context) {
261+
return const TeamAndMatchInformation();
262+
}));
263+
},
264+
); // set up the AlertDialog
265+
AlertDialog alert = AlertDialog(
266+
title: const Text("Reset All Fields"),
267+
content: const Text(
268+
"Would you like to reset all of the fields to their default values?"),
269+
actions: [
270+
cancelButton,
271+
continueButton,
272+
],
273+
); // show the dialog
274+
showDialog(
275+
context: context,
276+
builder: (BuildContext context) {
277+
return alert;
278+
},
279+
);
280+
}
281+
245282
void toggleTeleopBalanceStopwatch() {
246283
setState(() {
247284
if (TeleopScoutingData.teleopBalanceIsRunning) {

0 commit comments

Comments
 (0)