Skip to content

Commit fdd92d3

Browse files
HoodieRocksnoah-nm
andauthored
Teleop Split (#41)
* initial teleop refactor * add missing initial states * fix index counts * separate far and near coral, separate teleop/endgame and auto routes * fix layout errors caused by bad dpi * finish endgame data * comment code --------- Co-authored-by: Noah Mills <[email protected]>
1 parent 8694d90 commit fdd92d3

20 files changed

+647
-143
lines changed

lib/components/navigation/NavigationSidebar.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import 'package:flutter/material.dart';
33
import 'package:flutter/services.dart';
44
import 'package:scouting_platform/components/navigation/components/SidebarItem.dart';
55
import 'package:scouting_platform/routes/comments/CommentsRoute.dart';
6-
import 'package:scouting_platform/routes/data/DataRoute.dart';
6+
import 'package:scouting_platform/routes/auto/AutoRoute.dart';
77
import 'package:scouting_platform/routes/qrcode/QRCodeRoute.dart';
88
import 'package:scouting_platform/routes/settings/SettingsRoute.dart';
99
import 'package:scouting_platform/routes/prematch/PrematchRoute.dart';
10+
import 'package:scouting_platform/routes/teleop/TeleopRoute.dart';
1011

1112
class NavigationSidebar extends StatelessWidget {
1213
const NavigationSidebar({super.key});
@@ -32,9 +33,13 @@ class NavigationSidebar extends StatelessWidget {
3233
itemName: "Prematch Data",
3334
route: PrematchRoute(title: 'Prematch Data')),
3435
const SidebarItem(
35-
icon: Icon(Icons.draw),
36-
itemName: "Data Input",
37-
route: DataRoute(title: 'Data Input')),
36+
icon: Icon(Icons.auto_awesome),
37+
itemName: "Auto Data",
38+
route: AutoRoute(title: 'Auto Input')),
39+
const SidebarItem(
40+
icon: Icon(Icons.gamepad),
41+
itemName: "Teleop Data",
42+
route: TeleopRoute(title: 'Teleop Input')),
3843
const SidebarItem(
3944
icon: Icon(Icons.chat_bubble),
4045
itemName: "Comments",

lib/routes/data/DataRoute.dart renamed to lib/routes/auto/AutoRoute.dart

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
// ignore_for_file: file_names
22
import 'package:flutter/material.dart';
33
import 'package:scouting_platform/builders/PlatformRoute.dart';
4-
import 'package:scouting_platform/routes/comments/CommentsRoute.dart';
5-
import 'package:scouting_platform/routes/data/fields/AutonomousFields.dart';
6-
import 'package:scouting_platform/routes/data/fields/TeleoperatedFields.dart';
7-
import 'package:scouting_platform/routes/data/fields/EndgameFields.dart';
8-
import 'package:scouting_platform/routes/data/labels/AutonomousLabels.dart';
9-
import 'package:scouting_platform/routes/data/labels/TeleoperatedLabels.dart';
10-
import 'package:scouting_platform/routes/data/labels/EndgameLabels.dart';
4+
import 'package:scouting_platform/routes/auto/fields/AutonomousFields.dart';
5+
import 'package:scouting_platform/routes/auto/labels/AutonomousLabels.dart';
116
import 'package:scouting_platform/routes/prematch/PrematchRoute.dart';
7+
import 'package:scouting_platform/routes/teleop/TeleopRoute.dart';
128
import 'package:scouting_platform/styles/components/TitleStyle.dart';
139
import 'package:scouting_platform/styles/AppStyle.dart';
1410
import 'package:scouting_platform/utils/helpers/ScheduleHelper.dart';
@@ -20,15 +16,15 @@ import 'package:scouting_platform/utils/data/values/SettingValues.dart';
2016
import 'package:scouting_platform/utils/data/values/TeleoperatedValues.dart';
2117
import 'package:scouting_platform/utils/helpers/UIHelper.dart';
2218

23-
class DataRoute extends StatefulWidget {
24-
const DataRoute({super.key, required this.title});
19+
class AutoRoute extends StatefulWidget {
20+
const AutoRoute({super.key, required this.title});
2521
final String title;
2622

2723
@override
28-
State<DataRoute> createState() => _DataRouteState();
24+
State<AutoRoute> createState() => _AutoRouteState();
2925
}
3026

31-
class _DataRouteState extends State<DataRoute> {
27+
class _AutoRouteState extends State<AutoRoute> {
3228
@override
3329
void initState() {
3430
super.initState();
@@ -80,10 +76,10 @@ class _DataRouteState extends State<DataRoute> {
8076
onPressed: () {
8177
Navigator.push(context,
8278
MaterialPageRoute(builder: (context) {
83-
return const CommentsRoute(title: "Comments");
79+
return const TeleopRoute(title: "Teleop/Endgame");
8480
}));
8581
},
86-
child: const Text("Comments >",
82+
child: const Text("Teleop/Endgame >",
8783
style: TextStyle(
8884
fontSize: 16.0,
8985
fontFamily: "Helvetica",
@@ -93,21 +89,6 @@ class _DataRouteState extends State<DataRoute> {
9389
),
9490
const AutonomousLabels(),
9591
const AutonomousFields(),
96-
const TitleStyle(
97-
text: "Teleop Data",
98-
padding: EdgeInsets.only(top: 20.0, left: 20.0)),
99-
const TeleoperatedLabels(),
100-
const TeleoperatedFields(),
101-
const Row(
102-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
103-
children: [
104-
TitleStyle(
105-
text: "Endgame Data",
106-
padding: EdgeInsets.only(top: 20.0, left: 20.0)),
107-
],
108-
),
109-
const EndgameLabels(),
110-
const EndgameFields(),
11192
]),
11293
),
11394
);
@@ -146,16 +127,24 @@ class _DataRouteState extends State<DataRoute> {
146127
AutonomousValues.autoSpeakerMissed.text = "0";
147128
AutonomousValues.autoAmpMissed.text = "0";
148129
AutonomousValues.autoAmpScored.text = "0";
149-
TeleoperatedValues.speaker.text = "0";
150-
TeleoperatedValues.speakerMissed.text = "0";
151-
TeleoperatedValues.amp.text = "0";
152-
TeleoperatedValues.ampMissed.text = "0";
130+
TeleoperatedValues.coralNearL1.text = "0";
131+
TeleoperatedValues.coralNearL2.text = "0";
132+
TeleoperatedValues.coralNearL3.text = "0";
133+
TeleoperatedValues.coralNearL4.text = "0";
134+
TeleoperatedValues.coralFarL1.text = "0";
135+
TeleoperatedValues.coralFarL2.text = "0";
136+
TeleoperatedValues.coralFarL3.text = "0";
137+
TeleoperatedValues.coralFarL4.text = "0";
138+
TeleoperatedValues.coralMissed.text = "0";
139+
TeleoperatedValues.algaeRemoved.text = "0";
140+
TeleoperatedValues.algaeProcessor.text = "0";
141+
TeleoperatedValues.algaeBarge.text = "0";
142+
TeleoperatedValues.humanPlayerMisses.text = "0";
143+
TeleoperatedValues.fieldCrosses.text = "0";
153144
AutonomousValues.autoMobility.text = "No";
154145
EndgameValues.endgame.text = "No"; // was climb, now endgame
155146
EndgameValues.climbTime.text = "0"; // parked was below
156147
EndgameValues.stopwatchState.text = "0";
157-
TeleoperatedValues.passes.text = "0";
158-
EndgameValues.trap.text = "0";
159148
EndgameValues.stopwatch.stop();
160149
EndgameValues.stopwatch.reset();
161150
CommentValues.autoComments.text = "";

lib/routes/comments/fields/CommentsFields.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@ class _CommentsFields extends State<CommentsFields> {
3939
height: 90.0,
4040
maxLines: 10,
4141
),
42-
const TitleStyle(
43-
text: "Auto Note Order",
44-
padding: EdgeInsets.only(top: 10.0, left: 18.0)),
45-
TextInputField(
46-
onChanged: (value) {
47-
setState(() {
48-
CommentValues.autoOrder.text = value;
49-
});
50-
},
51-
textAlign: TextAlign.left,
52-
hintText:
53-
"1, 2, 3, 4, 5. One being the top of the field from your point of view and five being the bottom",
54-
controller: CommentValues.autoOrder,
55-
margin: const EdgeInsets.only(left: 18, top: 10),
56-
width: 880,
57-
height: 45.0,
58-
maxLines: 10,
59-
),
6042
const TitleStyle(
6143
text: "Teleop Comments",
6244
padding: EdgeInsets.only(top: 10.0, left: 18.0)),

lib/routes/prematch/fields/PrematchFields.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import 'package:flutter/material.dart';
33
import 'package:scouting_platform/builders/bases/NumberInputField.dart';
44
import 'package:scouting_platform/builders/bases/TextInputField.dart';
5-
import 'package:scouting_platform/routes/data/DataRoute.dart';
5+
import 'package:scouting_platform/routes/auto/AutoRoute.dart';
66
import 'package:scouting_platform/styles/AppStyle.dart';
77
import 'package:scouting_platform/utils/helpers/AppDataHelper.dart';
88
import 'package:scouting_platform/utils/helpers/ScheduleHelper.dart';
@@ -154,7 +154,7 @@ class _PrematchFieldsState extends State<PrematchFields> {
154154
onPressed: () {
155155
Navigator.push(context,
156156
MaterialPageRoute(builder: (context) {
157-
return const DataRoute(title: "Data Input");
157+
return const AutoRoute(title: "Auto Input");
158158
}));
159159
},
160160
child: const Text("Auto/Teleop >",

lib/routes/teleop/TeleopRoute.dart

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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+
}

lib/routes/data/fields/EndgameFields.dart renamed to lib/routes/teleop/fields/EndgameFields.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// ignore_for_file: file_names
22
import 'package:flutter/material.dart';
3-
import 'package:scouting_platform/builders/bases/CounterNumberField.dart';
43
import 'package:scouting_platform/builders/bases/PlatformDropdownMenu.dart';
54
import 'package:scouting_platform/builders/bases/StopwatchButton.dart';
65
import 'package:scouting_platform/utils/data/constants/OptionConstants.dart';
@@ -58,11 +57,6 @@ class _EndgameFieldsState extends State<EndgameFields> {
5857
state: EndgameValues.stopwatchState,
5958
timer: EndgameValues.stopwatch,
6059
),
61-
//trap
62-
CounterNumberField(
63-
controller: EndgameValues.trap,
64-
onTapDecrement: () => decrementNumber(EndgameValues.trap),
65-
onTapIncrement: () => incrementNumber(EndgameValues.trap)),
6660
],
6761
);
6862
}

0 commit comments

Comments
 (0)