@@ -114,7 +114,7 @@ class _HomeScreenState extends State<HomeScreen> {
114
114
backgroundColor: AppStyle .textInputColorLight,
115
115
),
116
116
onPressed: () {
117
- resetAllFields ( );
117
+ showConformationDialog (context );
118
118
},
119
119
child: const Text (
120
120
'Reset All Fields' ,
@@ -198,6 +198,7 @@ class _HomeScreenState extends State<HomeScreen> {
198
198
));
199
199
}
200
200
201
+ /// Resets all fields that the user has put information into
201
202
void resetAllFields () {
202
203
setState (() {
203
204
TeamAndMatchData .initials = "" ;
@@ -242,6 +243,42 @@ class _HomeScreenState extends State<HomeScreen> {
242
243
});
243
244
}
244
245
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
+
245
282
void toggleTeleopBalanceStopwatch () {
246
283
setState (() {
247
284
if (TeleopScoutingData .teleopBalanceIsRunning) {
0 commit comments