Skip to content

Commit 521668f

Browse files
committed
Create a proper data preview screen after scanning
Fix brightness setting upon scanning screen Remove redundant brightness setting Fix team number being overriden when changing driverstation
1 parent 6877476 commit 521668f

File tree

5 files changed

+90
-115
lines changed

5 files changed

+90
-115
lines changed

lib/routes/qrcode/DriverStationScanStatusRoute.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:scouting_platform/styles/components/HeaderStyle.dart';
77
import 'package:scouting_platform/styles/components/TitleStyle.dart';
88
import 'package:scouting_platform/utils/helpers/ScanningHelper.dart';
99
import 'package:scouting_platform/utils/data/constants/OptionConstants.dart';
10+
import 'package:scouting_platform/utils/helpers/UIHelper.dart';
1011

1112
class DriverStationScanStatusRoute extends StatefulWidget {
1213
const DriverStationScanStatusRoute({super.key, required this.title});
@@ -19,6 +20,12 @@ class DriverStationScanStatusRoute extends StatefulWidget {
1920

2021
class _DriverStationScanStatusRouteState
2122
extends State<DriverStationScanStatusRoute> {
23+
@override
24+
void initState() {
25+
super.initState();
26+
UIHelper.setBrightness(0.3);
27+
}
28+
2229
@override
2330
Widget build(BuildContext context) {
2431
List<Widget> unscannedWidgets = []; // Unscanned devices widgets

lib/routes/qrcode/QRCodeScanningRoute.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:mobile_scanner/mobile_scanner.dart';
77
import 'package:scouting_platform/builders/PlatformRoute.dart';
88
import 'package:scouting_platform/routes/qrcode/ScannedDataPreviewRoute.dart';
99
import 'package:scouting_platform/utils/data/values/SettingValues.dart';
10-
import 'package:scouting_platform/utils/helpers/UIHelper.dart';
1110

1211
class QRCodeScanningRoute extends StatefulWidget {
1312
const QRCodeScanningRoute({super.key, required this.title});
@@ -21,9 +20,9 @@ class QRCodeScanningRoute extends StatefulWidget {
2120
class _QRCodeScanningRouteState extends State<QRCodeScanningRoute>
2221
with WidgetsBindingObserver {
2322
final MobileScannerController cameraController = MobileScannerController();
24-
23+
2524
// Make barcodeStrings a static property
26-
static List<String>? barcodeStrings;
25+
static List<String>? barcodeStrings;
2726
List<Barcode>? barcodes;
2827
String? fileName;
2928

@@ -32,9 +31,7 @@ class _QRCodeScanningRouteState extends State<QRCodeScanningRoute>
3231
WidgetsBinding.instance.addObserver(this);
3332
super.initState();
3433

35-
// Finally, start the scanner itself.
3634
unawaited(cameraController.start());
37-
UIHelper.setBrightness(0.3);
3835
}
3936

4037
@override
@@ -62,7 +59,8 @@ class _QRCodeScanningRouteState extends State<QRCodeScanningRoute>
6259
// Decode the scanned QR code data
6360
List<int> decodedBytes = base64.decode(barcode.rawValue!);
6461
String decodedBarcodeString = utf8.decode(decodedBytes);
65-
barcodeStrings = decodedBarcodeString.split("^"); // Assign to static property
62+
barcodeStrings = decodedBarcodeString
63+
.split("^"); // Assign to static property
6664
fileName = SettingValues.getCurrentSavingSpreadsheetName();
6765

6866
// Navigate to the preview route

lib/routes/qrcode/ScannedDataPreviewRoute.dart

Lines changed: 76 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -21,114 +21,83 @@ class _ScannedDataPreviewRouteState extends State<ScannedDataPreviewRoute> {
2121
@override
2222
Widget build(BuildContext context) {
2323
return PlatformRoute(
24-
title: widget.title,
25-
body: SingleChildScrollView(
26-
physics: const AlwaysScrollableScrollPhysics(),
27-
child: Column(children: [
28-
/**
29-
* PLEASE REFERENCE QRCodeHelper.dart FOR THE INDEXES OF THE DATA
30-
*/
31-
Row(
32-
children: [
33-
Text("Team Number: ${widget.data[0]}, ",
34-
style: const TextStyle(fontSize: 18)),
35-
Text("Match Number: ${widget.data[1]}, ",
36-
style: const TextStyle(fontSize: 18)),
37-
Text("Initials: ${widget.data[2]}, ",
38-
style: const TextStyle(fontSize: 18)),
39-
Text("Driverstation: ${widget.data[3]}",
40-
style: const TextStyle(fontSize: 18)),
41-
],
24+
title: widget.title,
25+
body: Padding(
26+
padding: const EdgeInsets.all(16.0),
27+
child: ListView(
28+
physics: const AlwaysScrollableScrollPhysics(),
29+
children: [
30+
_buildDataCard("Team Number: ${widget.data[0]}"),
31+
_buildDataCard("Match Number: ${widget.data[1]}"),
32+
_buildDataCard("Initials: ${widget.data[2]}"),
33+
_buildDataCard("Driver Station: ${widget.data[3]}"),
34+
_buildDataCard("Auto Speaker Scored: ${widget.data[4]}"),
35+
_buildDataCard("Auto Speaker Missed: ${widget.data[5]}"),
36+
_buildDataCard("Auto Amp Scored: ${widget.data[6]}"),
37+
_buildDataCard("Auto Amp Missed: ${widget.data[7]}"),
38+
_buildDataCard("Auto Mobility: ${widget.data[8]}"),
39+
_buildDataCard("Teleop Speaker Scored: ${widget.data[9]}"),
40+
_buildDataCard("Teleop Speaker Missed: ${widget.data[10]}"),
41+
_buildDataCard("Teleop Amp Scored: ${widget.data[11]}"),
42+
_buildDataCard("Teleop Amp Missed: ${widget.data[12]}"),
43+
_buildDataCard("Teleop Passes: ${widget.data[13]}"),
44+
_buildDataCard("Teleop Endgame: ${widget.data[14]}"),
45+
_buildDataCard("Teleop Climb Time: ${widget.data[15]}"),
46+
_buildDataCard("Teleop Trap: ${widget.data[16]}"),
47+
_buildDataCard("Auto Comments: ${widget.data[17]}"),
48+
_buildDataCard("Auto Order: ${widget.data[18]}"),
49+
_buildDataCard("Teleop Comments: ${widget.data[19]}"),
50+
_buildDataCard("Endgame Comments: ${widget.data[20]}"),
51+
const SizedBox(height: 20), // Space before the button
52+
ElevatedButton(
53+
style: ElevatedButton.styleFrom(
54+
backgroundColor: AppStyle.textInputColorLight,
55+
padding: const EdgeInsets.symmetric(
56+
vertical: 15.0, horizontal: 20.0),
57+
shape: RoundedRectangleBorder(
58+
borderRadius: BorderRadius.circular(30.0),
59+
),
60+
elevation: 5,
4261
),
43-
Row(
44-
children: [
45-
Text("Auto Speaker Scored: ${widget.data[4]}, ",
46-
style: const TextStyle(fontSize: 18)),
47-
Text("Auto Speaker Missed: ${widget.data[5]}, ",
48-
style: const TextStyle(fontSize: 18)),
49-
Text("Auto Amp Scored: ${widget.data[6]}, ",
50-
style: const TextStyle(fontSize: 18)),
51-
Text("Auto Amp Missed: ${widget.data[7]}, ",
52-
style: const TextStyle(fontSize: 18)),
53-
Text("Auto Mobility: ${widget.data[8]}",
54-
style: const TextStyle(fontSize: 18)),
55-
],
62+
onPressed: () async {
63+
setState(() {
64+
ScanningHelper.unscannedDevices = ScanningHelper
65+
.unscannedDevices
66+
.where((element) => !element.contains(widget.data[21]))
67+
.toList();
68+
if (!ScanningHelper.scannedDevices
69+
.contains(widget.data[21])) {
70+
ScanningHelper.scannedDevices.add(widget.data[21]);
71+
}
72+
});
73+
Navigator.push(context, MaterialPageRoute(builder: (context) {
74+
return const DriverStationScanStatusRoute(
75+
title: "Scanned Status",
76+
);
77+
}));
78+
await ScanningHelper.generateCsv(widget.data);
79+
},
80+
child: const Text(
81+
'Save QR Code Data',
82+
style: TextStyle(fontSize: 16.0, color: Colors.white),
5683
),
57-
Row(
58-
children: [
59-
Text("Teleop Speaker Scored: ${widget.data[9]}, ",
60-
style: const TextStyle(fontSize: 18)),
61-
Text("Teleop Speaker Missed: ${widget.data[10]}, ",
62-
style: const TextStyle(fontSize: 18)),
63-
Text("Teleop Amp Scored: ${widget.data[11]}, ",
64-
style: const TextStyle(fontSize: 18)),
65-
Text("Teleop Amp Missed: ${widget.data[12]}, ",
66-
style: const TextStyle(fontSize: 18)),
67-
],
68-
),
69-
Row(
70-
children: [
71-
Text("Teleop Passes: ${widget.data[13]}",
72-
style: const TextStyle(fontSize: 18)),
73-
Text("Teleop Endgame: ${widget.data[14]}",
74-
style: const TextStyle(fontSize: 18)),
75-
Text("Teleop Climb Time: ${widget.data[15]}, ",
76-
style: const TextStyle(fontSize: 18)),
77-
Text("Teleop Trap: ${widget.data[16]}, ",
78-
style: const TextStyle(fontSize: 18)),
79-
],
80-
),
81-
Row(
82-
children: [
83-
Text("Auto Comments: ${widget.data[17]}, ",
84-
style: const TextStyle(fontSize: 18)),
85-
Text("Auto Order: ${widget.data[18]}, ",
86-
style: const TextStyle(fontSize: 18)),
87-
Text("Teleop Comments: ${widget.data[19]}, ",
88-
style: const TextStyle(fontSize: 18)),
89-
Text("Endgame Comments: ${widget.data[20]}",
90-
style: const TextStyle(fontSize: 18))
91-
],
92-
),
93-
Row(
94-
children: [
95-
ElevatedButton(
96-
style: ElevatedButton.styleFrom(
97-
backgroundColor: AppStyle
98-
.textInputColorLight, // Set the background color here
99-
),
100-
onPressed: () async {
101-
setState(() {
102-
ScanningHelper.unscannedDevices = ScanningHelper
103-
.unscannedDevices
104-
.where((element) => !element.contains(
105-
widget.data[21]))
106-
.toList();
107-
if (!ScanningHelper.scannedDevices.contains(
108-
widget.data[21])) {
109-
ScanningHelper.scannedDevices
110-
.add(widget.data[21]);
111-
}
112-
});
113-
Navigator.push(context,
114-
MaterialPageRoute(builder: (context) {
115-
return const DriverStationScanStatusRoute(
116-
title: "Scanned Status",
117-
);
118-
}));
119-
await ScanningHelper.generateCsv(
120-
widget.data);
121-
},
122-
child: const Text(
123-
'Save QR Code Data',
124-
style: TextStyle(
125-
fontSize: 16.0,
126-
fontFamily: "Helvetica",
127-
color: Colors.white),
128-
),
129-
),
130-
],
131-
)
132-
])));
84+
),
85+
],
86+
),
87+
),
88+
);
89+
}
90+
91+
Widget _buildDataCard(String text) {
92+
return Card(
93+
margin: const EdgeInsets.symmetric(vertical: 8.0),
94+
child: Padding(
95+
padding: const EdgeInsets.all(16.0),
96+
child: Text(
97+
text,
98+
style: const TextStyle(fontSize: 18),
99+
),
100+
),
101+
);
133102
}
134103
}

lib/routes/settings/SettingsRoute.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ class _SettingsRoute extends State<SettingsRoute> {
6464
value;
6565
AppDataHelper
6666
.saveCurrentEventIDAndCurrentDriverStation();
67-
if (PrematchValues.matchNumber.text != "") {
67+
if (PrematchValues.matchNumber.text != "" &&
68+
SettingValues.isTeamNumberEditable !=
69+
"Yes") {
6870
// If it isn't null
6971
Schedulehelper.getTeamNumberFromSchedule(
7072
int.parse(

lib/utils/helpers/ScanningHelper.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class ScanningHelper {
6363

6464
bool fileExists = await file.exists();
6565

66-
6766
List<List<String>> data = [];
6867

6968
if (!fileExists) {

0 commit comments

Comments
 (0)