Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ GeneratedPluginRegistrant.java
key.properties
**/*.keystore
**/*.jks
/app/.cxx
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.4.2" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"
24 changes: 23 additions & 1 deletion lib/builders/PlatformRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import 'package:flutter/material.dart';
import 'package:scouting_platform/components/navigation/NavigationSidebar.dart';
import 'package:scouting_platform/styles/AppStyle.dart';
import 'package:scouting_platform/utils/data/values/SettingValues.dart';
import 'package:scouting_platform/utils/helpers/UIHelper.dart';
import 'package:scouting_platform/utils/data/constants/AppConstants.dart';

Expand All @@ -20,6 +21,27 @@ class PlatformRoute extends StatefulWidget {

class _PlatformRouteState extends State<PlatformRoute> {
final scaffoldKey = GlobalKey<ScaffoldState>();
Color appBarColor = AppStyle.textInputColor;

@override
void initState() {
super.initState();
_loadColor();
if(!SettingValues.isTeamListenerRegistered) {
SettingValues.isTeamListenerRegistered = true;
Stream.periodic(Duration(seconds: 1)).listen((_) {
_loadColor();
});
}
}

void _loadColor() async {
appBarColor = await UIHelper.getAppBarColour();
setState(() {
appBarColor = appBarColor;
});
}

@override
Widget build(BuildContext context) {
return PopScope(
Expand All @@ -31,7 +53,7 @@ class _PlatformRouteState extends State<PlatformRoute> {
appBar: PreferredSize(
preferredSize: const Size.fromHeight(40.0),
child: AppBar(
backgroundColor: AppStyle.textInputColor,
backgroundColor: appBarColor,
title: Text(
widget.title,
textAlign: TextAlign.center,
Expand Down
6 changes: 3 additions & 3 deletions lib/components/navigation/components/SidebarItem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class _SidebarItemState extends State<SidebarItem> {
style:
const TextStyle(fontFamily: 'Futura', fontWeight: FontWeight.bold),
),
onTap: () =>
Navigator.push(context, MaterialPageRoute(builder: (context) {
onTap: () => Navigator.pushAndRemoveUntil(context,
MaterialPageRoute(builder: (context) {
return widget.route;
})),
}), (r) => false),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _AutonomousRow4State extends State<AutonomousRow4> {
checkColor: Colors.white,
labelColor: Colors.white,
margin: const EdgeInsets.only(right: 0.0)),
Align(
Align(
alignment: Alignment.centerLeft,
child: SizedBox(
width: 170.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _AutonomousRow5State extends State<AutonomousRow5> {
checkColor: Colors.white,
labelColor: Colors.white,
margin: const EdgeInsets.only(right: 0.0)),
Align(
Align(
alignment: Alignment.centerLeft,
child: SizedBox(
width: 170.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _AutonomousRow6State extends State<AutonomousRow6> {
checkColor: Colors.white,
labelColor: Colors.white,
margin: const EdgeInsets.only(right: 0.0)),
Align(
Align(
alignment: Alignment.centerLeft,
child: SizedBox(
width: 170.0,
Expand Down
3 changes: 1 addition & 2 deletions lib/routes/prematch/PrematchRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class _PrematchRouteState extends State<PrematchRoute> {
@override
void initState() {
super.initState();
UIHelper.setBrightness(0.3);

AppDataHelper.getCurrentEventIDAndCurrentDriverStation().then((value) {
if (value != "") {
Expand All @@ -30,8 +31,6 @@ class _PrematchRouteState extends State<PrematchRoute> {
});
}
});

UIHelper.setBrightness(0.3);
}

@override
Expand Down
5 changes: 3 additions & 2 deletions lib/routes/qrcode/QRCodeRoute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ class _QRCodeRouteState extends State<QRCodeRoute> {
AppDataHelper.resetStates();
});
Navigator.of(context, rootNavigator: true).pop('dialog');
Navigator.push(context, MaterialPageRoute(builder: (context) {
Navigator.pushAndRemoveUntil(context,
MaterialPageRoute(builder: (context) {
return const PrematchRoute(title: "Prematch Data");
}));
}), (r) => false);
},
);

Expand Down
6 changes: 3 additions & 3 deletions lib/utils/data/constants/OptionConstants.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// ignore_for_file: file_names

class OptionConstants {
static final yesNoOptions = ["Yes", "No"];
static final yesNoOptions = ["", "Yes", "No"];

static final startPositions = ["Top", "Center", "Bottom"];
static final startPositions = ["", "Top", "Center", "Bottom"];

static final endgameOptions = ["No", "Shallow", "Deep", "Park"];
static final endgameOptions = ["", "No", "Shallow", "Deep", "Park"];

static List<String> availableDriverstations = [
"Red 1",
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/data/values/AutonomousValues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
class AutonomousValues {
// other
static TextEditingController autoStartPosition =
TextEditingController(text: "Center");
static TextEditingController autoMobility = TextEditingController(text: "No");
TextEditingController(text: "");
static TextEditingController autoMobility = TextEditingController(text: "");
static TextEditingController coralMissed = TextEditingController(text: "0");
static TextEditingController algaeRemoved = TextEditingController(text: "0");
static TextEditingController algaeProcessor =
Expand Down Expand Up @@ -66,8 +66,8 @@ class AutonomousValues {
static TextEditingController l2G = TextEditingController(text: "0");

static void resetAutoEtcValues() {
AutonomousValues.autoStartPosition.text = "Center";
AutonomousValues.autoMobility.text = "No";
AutonomousValues.autoStartPosition.text = "";
AutonomousValues.autoMobility.text = "";
AutonomousValues.coralMissed.text = "0";
AutonomousValues.algaeRemoved.text = "0";
AutonomousValues.algaeBarge.text = "0";
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/data/values/EndgameValues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class EndgameValues {
/// These don't hold the value of the stopwatch, only properties such as state and the instance
static final stopwatch = Stopwatch();

static TextEditingController endgame = TextEditingController(text: "No");
static TextEditingController endgame = TextEditingController(text: "");
static TextEditingController climbTime = TextEditingController(text: "0");

static void resetEndgameValues() {
EndgameValues.endgame.text = "No"; // was climb, now endgame
EndgameValues.endgame.text = ""; // was climb, now endgame
EndgameValues.climbTime.text = "0"; // parked was below
EndgameValues.stopwatch.stop();
EndgameValues.stopwatch.reset();
Expand Down
1 change: 1 addition & 0 deletions lib/utils/data/values/SettingValues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SettingValues {
TextEditingController(text: AppConstants.defaultEventID);
static TextEditingController fileName =
TextEditingController(text: AppConstants.defaultFileName);
static bool isTeamListenerRegistered = false;

static String isTeamNumberEditable = "No";
static bool isTeamNumberReadOnly = true;
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/data/values/TeleoperatedValues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ class TeleoperatedValues {
TeleoperatedValues.algaeProcessor.text = "0";
TeleoperatedValues.algaeBarge.text = "0";
TeleoperatedValues.defenseTime.text = "0";
TeleoperatedValues.stopwatch.stop();
TeleoperatedValues.stopwatch.reset();
}
}
2 changes: 1 addition & 1 deletion lib/utils/helpers/AppDataHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppDataHelper {
if (!await file.exists()) {
await file.create();
}
await file.writeAsString("$data\n", mode: FileMode.append);
await file.writeAsString(data);
} else {
throw Exception('Permission denied');
}
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/helpers/QRCodeHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:scouting_platform/utils/data/values/EndgameValues.dart';
import 'package:scouting_platform/utils/data/values/PrematchValues.dart';
import 'package:scouting_platform/utils/data/values/SettingValues.dart';
import 'package:scouting_platform/utils/data/values/TeleoperatedValues.dart';
import 'package:scouting_platform/utils/helpers/AppDataHelper.dart';

class QrcodeHelper {
/// Returns a string that represents the contents of the QR code that will be generated and separates them with a "^" character
Expand All @@ -29,7 +28,7 @@ class QrcodeHelper {
// Encode to UTF-8 and then base64 to compress size and reduce issues with characters
List<int> utf8Encoded = utf8.encode(computedValues);

AppDataHelper.saveQRCodeCopy(computedValues);
// AppDataHelper.saveQRCodeCopy(computedValues);

return base64.encode(utf8Encoded);
}
Expand Down
56 changes: 56 additions & 0 deletions lib/utils/helpers/ScheduleHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import 'dart:io';

import 'package:permission_handler/permission_handler.dart';
import 'package:scouting_platform/utils/data/constants/AppConstants.dart';
import 'package:scouting_platform/utils/data/values/PrematchValues.dart';
import 'package:scouting_platform/utils/data/values/SettingValues.dart';

class Schedulehelper {
static late int argumentReadingIndex;
static late int driverStationIdentifier;
static List<String> simbotMatches = [];

static Future<String> get _scheduleDirecotyPath async {
final directory = Directory('/storage/emulated/0/Documents');
Expand Down Expand Up @@ -53,6 +55,60 @@ class Schedulehelper {
return null;
}

static Future<int> getNumberOfLinesInSchedule() async {
final file = File(
"/storage/emulated/0/Documents/match_schedule_${SettingValues.eventID.text}.csv");

if (await file.exists()) {
final lines = await file.readAsLines();
return lines.length - 1;
}
return 0;
}

static Future<List<String>> getSimbotMatches() async {
if (simbotMatches.isNotEmpty) {
// memoization
return simbotMatches;
}

for (var i = 0; i < await getNumberOfLinesInSchedule(); i++) {
String? matchData = await readLineFromSchedule(i);
if (matchData == null) {
break;
}
if (matchData.contains("1114")) {
simbotMatches.add(matchData);
}
}
return simbotMatches;
}

static Future<bool> isTeamInUpcomingMatches(int teamNumber) async {
if (PrematchValues.matchNumber.text.isEmpty) {
return false;
}

List<String> simbotMatches = await getSimbotMatches();
for (String simbotMatch in simbotMatches) {
List<String> simbotMatchData = simbotMatch.split(",");
String matchNumber = simbotMatchData[0];
simbotMatchData.removeAt(0);
int teamIndex = simbotMatchData.indexOf(teamNumber.toString());
int simbotIndex = simbotMatchData.indexOf("1114");

bool teamAlliance = teamIndex < 2 && teamIndex != -1;
bool simbotAlliance = simbotIndex < 2 && simbotIndex != -1;

if (int.parse(matchNumber) >
int.parse(PrematchValues.matchNumber.text) + 1 &&
teamAlliance == simbotAlliance) {
return true;
}
}
return false;
}

static Future<int> getTeamNumberFromSchedule(int matchNumber) async {
switch (SettingValues.selectedDriverStation.text) {
case "Red 1":
Expand Down
15 changes: 15 additions & 0 deletions lib/utils/helpers/UIHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import 'dart:ui';

import 'package:scouting_platform/styles/AppStyle.dart';
import 'package:scouting_platform/utils/data/values/PrematchValues.dart';
import 'package:scouting_platform/utils/data/values/SettingValues.dart';
import 'package:scouting_platform/utils/helpers/ScheduleHelper.dart';
import 'package:screen_brightness/screen_brightness.dart';

class UIHelper {
Expand All @@ -15,6 +17,19 @@ class UIHelper {
}
}

static Future<Color> getAppBarColour() async {
try {
if (await Schedulehelper.isTeamInUpcomingMatches(
int.parse(PrematchValues.teamNumber.text))) {
return Color.from(alpha: 1, red: 0, green: 0.5, blue: 0);
} else {
return AppStyle.textInputColor;
}
} catch (e) {
return AppStyle.textInputColor;
}
}

// Sets the brightness of the screen
static Future<void> setBrightness(double brightness) async {
try {
Expand Down
Loading