@@ -46,10 +46,21 @@ class ScoutingViewModel : ViewModel() {
46
46
var scoutName by mutableStateOf(TextFieldValue ())
47
47
48
48
var showingNoTemplateDialog by mutableStateOf(false )
49
+ var showingSelectPitDialog by mutableStateOf(false )
49
50
50
51
lateinit var scoutingScheduleManager: ScoutingScheduleManager
51
52
private val preferences = MMKV .defaultMMKV()
52
53
54
+ /* *
55
+ * Indicate whether match scouting is currently using a schedule
56
+ */
57
+ fun usingMatchSchedule (): Boolean = preferences.decodeBool(" COMPETITION_MODE" , false )
58
+
59
+ /* *
60
+ * Indicate whether pit scouting is currently using a schedule
61
+ */
62
+ fun usingPitSchedule (): Boolean = preferences.decodeBool(" PIT_SCOUTING_MODE" , false )
63
+
53
64
/* *
54
65
* Deserialize template items from user-selected and created JSON template
55
66
* to list variables stored in the ViewModel, to later be interpreted and
@@ -104,7 +115,7 @@ class ScoutingViewModel : ViewModel() {
104
115
fun populateMatchData () {
105
116
currentAllianceMonitoring =
106
117
AllianceType .valueOf(preferences.decodeString(" DEVICE_ALLIANCE_POSITION" , " RED" )!! )
107
- if (preferences.decodeBool( " COMPETITION_MODE " , false )) {
118
+ if (usingMatchSchedule( )) {
108
119
currentMatchMonitoring =
109
120
TextFieldValue ((scoutingScheduleManager.currentMatchScoutingIteration + 1 ).toString())
110
121
currentTeamNumberMonitoring = TextFieldValue (scoutingScheduleManager.getCurrentTeam())
@@ -120,7 +131,7 @@ class ScoutingViewModel : ViewModel() {
120
131
* scouting mode is disabled.
121
132
*/
122
133
fun populatePitDataIfScheduled () {
123
- if (preferences.decodeBool( " PIT_SCOUTING_MODE " , false )) {
134
+ if (usingPitSchedule( )) {
124
135
val teamInfo = scoutingScheduleManager.getCurrentPitInfo()
125
136
currentTeamNameMonitoring = TextFieldValue (teamInfo.second)
126
137
currentTeamNumberMonitoring = TextFieldValue (teamInfo.first)
@@ -211,11 +222,11 @@ class ScoutingViewModel : ViewModel() {
211
222
}
212
223
213
224
if (scoutingType == PIT ) {
214
- if (preferences.decodeBool( " PIT_SCOUTING_MODE " , false )) {
225
+ if (usingPitSchedule( )) {
215
226
scoutingScheduleManager.moveToNextPit()
216
227
}
217
228
} else {
218
- if (preferences.decodeBool( " COMPETITION_MODE " , false )) {
229
+ if (usingMatchSchedule( )) {
219
230
scoutingScheduleManager.moveToNextMatch()
220
231
}
221
232
}
0 commit comments