Skip to content

Commit

Permalink
Add usingMatchSchedule() and usingPitSchedule()
Browse files Browse the repository at this point in the history
  • Loading branch information
KangarooKoala committed Apr 11, 2024
1 parent b769e78 commit 2820bb6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/src/main/java/com/scouting/app/viewmodel/ScoutingViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,21 @@ class ScoutingViewModel : ViewModel() {
var scoutName by mutableStateOf(TextFieldValue())

var showingNoTemplateDialog by mutableStateOf(false)
var showingSelectPitDialog by mutableStateOf(false)

lateinit var scoutingScheduleManager: ScoutingScheduleManager
private val preferences = MMKV.defaultMMKV()

/**
* Indicate whether match scouting is currently using a schedule
*/
fun usingMatchSchedule(): Boolean = preferences.decodeBool("COMPETITION_MODE", false)

/**
* Indicate whether pit scouting is currently using a schedule
*/
fun usingPitSchedule(): Boolean = preferences.decodeBool("PIT_SCOUTING_MODE", false)

/**
* Deserialize template items from user-selected and created JSON template
* to list variables stored in the ViewModel, to later be interpreted and
Expand Down Expand Up @@ -104,7 +115,7 @@ class ScoutingViewModel : ViewModel() {
fun populateMatchData() {
currentAllianceMonitoring =
AllianceType.valueOf(preferences.decodeString("DEVICE_ALLIANCE_POSITION", "RED")!!)
if (preferences.decodeBool("COMPETITION_MODE", false)) {
if (usingMatchSchedule()) {
currentMatchMonitoring =
TextFieldValue((scoutingScheduleManager.currentMatchScoutingIteration + 1).toString())
currentTeamNumberMonitoring = TextFieldValue(scoutingScheduleManager.getCurrentTeam())
Expand All @@ -120,7 +131,7 @@ class ScoutingViewModel : ViewModel() {
* scouting mode is disabled.
*/
fun populatePitDataIfScheduled() {
if (preferences.decodeBool("PIT_SCOUTING_MODE", false)) {
if (usingPitSchedule()) {
val teamInfo = scoutingScheduleManager.getCurrentPitInfo()
currentTeamNameMonitoring = TextFieldValue(teamInfo.second)
currentTeamNumberMonitoring = TextFieldValue(teamInfo.first)
Expand Down Expand Up @@ -211,11 +222,11 @@ class ScoutingViewModel : ViewModel() {
}

if (scoutingType == PIT) {
if (preferences.decodeBool("PIT_SCOUTING_MODE", false)) {
if (usingPitSchedule()) {
scoutingScheduleManager.moveToNextPit()
}
} else {
if (preferences.decodeBool("COMPETITION_MODE", false)) {
if (usingMatchSchedule()) {
scoutingScheduleManager.moveToNextMatch()
}
}
Expand Down

0 comments on commit 2820bb6

Please sign in to comment.