|
| 1 | +// ignore_for_file: file_names |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | +import 'package:scouting_platform/builders/PlatformRoute.dart'; |
| 4 | +import 'package:scouting_platform/routes/comments/CommentsRoute.dart'; |
| 5 | +import 'package:scouting_platform/routes/teleop/fields/TeleoperatedFields.dart'; |
| 6 | +import 'package:scouting_platform/routes/teleop/fields/TeleoperatedFields2.dart'; |
| 7 | +import 'package:scouting_platform/routes/teleop/fields/TeleoperatedFields3.dart'; |
| 8 | +import 'package:scouting_platform/routes/teleop/labels/TeleoperatedLabels.dart'; |
| 9 | +import 'package:scouting_platform/routes/teleop/labels/TeleoperatedLabels2.dart'; |
| 10 | +import 'package:scouting_platform/routes/teleop/labels/TeleoperatedLabels3.dart'; |
| 11 | +import 'package:scouting_platform/routes/teleop/fields/EndgameFields.dart'; |
| 12 | +import 'package:scouting_platform/routes/teleop/labels/EndgameLabels.dart'; |
| 13 | +import 'package:scouting_platform/routes/prematch/PrematchRoute.dart'; |
| 14 | +import 'package:scouting_platform/styles/AppStyle.dart'; |
| 15 | +import 'package:scouting_platform/utils/helpers/ScheduleHelper.dart'; |
| 16 | +import 'package:scouting_platform/utils/data/values/AutonomousValues.dart'; |
| 17 | +import 'package:scouting_platform/utils/data/values/CommentValues.dart'; |
| 18 | +import 'package:scouting_platform/utils/data/values/EndgameValues.dart'; |
| 19 | +import 'package:scouting_platform/utils/data/values/PrematchValues.dart'; |
| 20 | +import 'package:scouting_platform/utils/data/values/SettingValues.dart'; |
| 21 | +import 'package:scouting_platform/utils/data/values/TeleoperatedValues.dart'; |
| 22 | +import 'package:scouting_platform/utils/helpers/UIHelper.dart'; |
| 23 | + |
| 24 | +class TeleopRoute extends StatefulWidget { |
| 25 | + const TeleopRoute({super.key, required this.title}); |
| 26 | + final String title; |
| 27 | + |
| 28 | + @override |
| 29 | + State<TeleopRoute> createState() => _TeleopRouteState(); |
| 30 | +} |
| 31 | + |
| 32 | +class _TeleopRouteState extends State<TeleopRoute> { |
| 33 | + @override |
| 34 | + void initState() { |
| 35 | + super.initState(); |
| 36 | + UIHelper.setBrightness(0.3); |
| 37 | + } |
| 38 | + |
| 39 | + @override |
| 40 | + Widget build(BuildContext context) { |
| 41 | + return PlatformRoute( |
| 42 | + title: widget.title, |
| 43 | + body: SingleChildScrollView( |
| 44 | + physics: const AlwaysScrollableScrollPhysics(), |
| 45 | + child: Column(children: [ |
| 46 | + Row( |
| 47 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 48 | + children: [ |
| 49 | + Padding( |
| 50 | + padding: |
| 51 | + const EdgeInsets.only(right: 50.0, top: 10.0, left: 125.0), |
| 52 | + child: ElevatedButton( |
| 53 | + style: ElevatedButton.styleFrom( |
| 54 | + minimumSize: const Size(150.0, 47.0), |
| 55 | + backgroundColor: AppStyle.textInputColor, |
| 56 | + ), |
| 57 | + onPressed: () { |
| 58 | + showConformationDialog(context); |
| 59 | + }, |
| 60 | + child: const Text("Reset", |
| 61 | + style: TextStyle( |
| 62 | + fontSize: 16.0, |
| 63 | + fontFamily: "Helvetica", |
| 64 | + color: Colors.white)), |
| 65 | + ), |
| 66 | + ), |
| 67 | + Align( |
| 68 | + alignment: Alignment.bottomRight, |
| 69 | + child: Container( |
| 70 | + padding: const EdgeInsets.only(top: 4.0, right: 60), |
| 71 | + // height: 47.0, |
| 72 | + child: ElevatedButton( |
| 73 | + style: ElevatedButton.styleFrom( |
| 74 | + minimumSize: const Size(150.0, 47.0), |
| 75 | + backgroundColor: AppStyle |
| 76 | + .textInputColor, // Set the background color here |
| 77 | + ), |
| 78 | + onPressed: () { |
| 79 | + Navigator.push(context, |
| 80 | + MaterialPageRoute(builder: (context) { |
| 81 | + return const CommentsRoute(title: "Comments"); |
| 82 | + })); |
| 83 | + }, |
| 84 | + child: const Text("Comments >", |
| 85 | + style: TextStyle( |
| 86 | + fontSize: 16.0, |
| 87 | + fontFamily: "Helvetica", |
| 88 | + color: Colors.white)), |
| 89 | + ))), |
| 90 | + ], |
| 91 | + ), |
| 92 | + const TeleoperatedLabels(), |
| 93 | + const TeleoperatedFields(), |
| 94 | + const TeleoperatedLabels2(), |
| 95 | + const TeleoperatedFields2(), |
| 96 | + const TeleoperatedLabels3(), |
| 97 | + const TeleoperatedFields3(), |
| 98 | + const EndgameLabels(), |
| 99 | + const EndgameFields(), |
| 100 | + ]), |
| 101 | + ), |
| 102 | + ); |
| 103 | + } |
| 104 | + |
| 105 | + showConformationDialog(BuildContext context) { |
| 106 | + // set up the buttons |
| 107 | + Widget cancelButton = TextButton( |
| 108 | + child: const Text("No"), |
| 109 | + onPressed: () { |
| 110 | + Navigator.of(context, rootNavigator: true).pop('dialog'); |
| 111 | + }, |
| 112 | + ); |
| 113 | + Widget continueButton = TextButton( |
| 114 | + child: const Text("Yes"), |
| 115 | + onPressed: () { |
| 116 | + // Increment the match number |
| 117 | + if (PrematchValues.matchNumber.text != "") { |
| 118 | + PrematchValues.matchNumber.text = |
| 119 | + (int.parse(PrematchValues.matchNumber.text) + 1).toString(); |
| 120 | + } else { |
| 121 | + PrematchValues.matchNumber.text = (2).toString(); |
| 122 | + } |
| 123 | + |
| 124 | + if (SettingValues.isTeamNumberReadOnly) { |
| 125 | + // Get the team number from the schedule and set the team number field to that |
| 126 | + Schedulehelper.getTeamNumberFromSchedule( |
| 127 | + int.parse(// Get the team number from the schedule |
| 128 | + PrematchValues.matchNumber.text)) |
| 129 | + .then((teamNumber) => |
| 130 | + PrematchValues.teamNumber.text = teamNumber.toString()); |
| 131 | + } |
| 132 | + |
| 133 | + setState(() { |
| 134 | + AutonomousValues.autoSpeakerScored.text = "0"; |
| 135 | + AutonomousValues.autoSpeakerMissed.text = "0"; |
| 136 | + AutonomousValues.autoAmpMissed.text = "0"; |
| 137 | + AutonomousValues.autoAmpScored.text = "0"; |
| 138 | + TeleoperatedValues.coralNearL1.text = "0"; |
| 139 | + TeleoperatedValues.coralNearL2.text = "0"; |
| 140 | + TeleoperatedValues.coralNearL3.text = "0"; |
| 141 | + TeleoperatedValues.coralNearL4.text = "0"; |
| 142 | + TeleoperatedValues.coralFarL1.text = "0"; |
| 143 | + TeleoperatedValues.coralFarL2.text = "0"; |
| 144 | + TeleoperatedValues.coralFarL3.text = "0"; |
| 145 | + TeleoperatedValues.coralFarL4.text = "0"; |
| 146 | + TeleoperatedValues.coralMissed.text = "0"; |
| 147 | + TeleoperatedValues.algaeRemoved.text = "0"; |
| 148 | + TeleoperatedValues.algaeProcessor.text = "0"; |
| 149 | + TeleoperatedValues.algaeBarge.text = "0"; |
| 150 | + TeleoperatedValues.humanPlayerMisses.text = "0"; |
| 151 | + TeleoperatedValues.fieldCrosses.text = "0"; |
| 152 | + AutonomousValues.autoMobility.text = "No"; |
| 153 | + EndgameValues.endgame.text = "No"; // was climb, now endgame |
| 154 | + EndgameValues.climbTime.text = "0"; // parked was below |
| 155 | + EndgameValues.stopwatchState.text = "0"; |
| 156 | + EndgameValues.stopwatch.stop(); |
| 157 | + EndgameValues.stopwatch.reset(); |
| 158 | + CommentValues.autoComments.text = ""; |
| 159 | + CommentValues.autoOrder.text = ""; |
| 160 | + CommentValues.teleopComments.text = ""; |
| 161 | + CommentValues.endgameComments.text = ""; |
| 162 | + }); |
| 163 | + Navigator.of(context, rootNavigator: true).pop('dialog'); |
| 164 | + Navigator.push(context, MaterialPageRoute(builder: (context) { |
| 165 | + return const PrematchRoute(title: "Prematch Data"); |
| 166 | + })); |
| 167 | + }, |
| 168 | + ); // set up the AlertDialog |
| 169 | + AlertDialog alert = AlertDialog( |
| 170 | + title: const Text("Confirmation: Reset ALL Fields"), |
| 171 | + content: const Text( |
| 172 | + "Would you like to reset all of the fields current inputted?"), |
| 173 | + actions: [ |
| 174 | + cancelButton, |
| 175 | + continueButton, |
| 176 | + ], |
| 177 | + ); // show the dialog |
| 178 | + showDialog( |
| 179 | + context: context, |
| 180 | + builder: (BuildContext context) { |
| 181 | + return alert; |
| 182 | + }, |
| 183 | + ); |
| 184 | + } |
| 185 | +} |
0 commit comments