Added ability to add custom teams and events.

This commit is contained in:
Raktbastr 2026-02-14 13:35:40 -06:00
parent 84aaf9c527
commit 9327b6120f
8 changed files with 687 additions and 189 deletions

View file

@ -20,19 +20,22 @@ class NotesPage extends StatefulWidget {
}
class _NotesPageState extends State<NotesPage> {
late SharedPreferences _prefs;
late SharedPreferences prefs;
ScoutingView _selectedView = ScoutingView.match;
bool _isLoading = true;
final _autonRundownController = TextEditingController();
final _botPositionController = TextEditingController();
final _generalObservationsController = TextEditingController();
final _driveTrainTypeController = TextEditingController();
bool _hasVision = false;
double _climbLevel = 100.0;
bool _trenchable = false;
final _autonRundownController = TextEditingController();
final _intakePositionController = TextEditingController();
final _scoreMechanisimController = TextEditingController();
double _fuelPerCycle = 0;
bool _canDriveUnderTrench = false;
bool _canDriveOverBump = false;
double _climbLevel = 0.0;
double _fuelCapacity = 0.0;
bool _canGiveToHumanPlayer = false;
double _cycleTime = 0.0;
@override
void initState() {
@ -44,8 +47,9 @@ class _NotesPageState extends State<NotesPage> {
void dispose() {
_autonRundownController.dispose();
_botPositionController.dispose();
_driveTrainTypeController.dispose();
_generalObservationsController.dispose();
_intakePositionController.dispose();
_scoreMechanisimController.dispose();
super.dispose();
}
@ -54,21 +58,33 @@ class _NotesPageState extends State<NotesPage> {
}
Future<void> _loadNotes() async {
_prefs = await SharedPreferences.getInstance();
SharedPreferences prefs = await SharedPreferences.getInstance();
_autonRundownController.text = _prefs.getString(_generateKey('autonRundown')) ?? '';
_botPositionController.text = _prefs.getString(_generateKey('botPosition')) ?? '';
_generalObservationsController.text = _prefs.getString(_generateKey('generalObservations')) ?? '';
_driveTrainTypeController.text = _prefs.getString(_generateKey('driveTrainType')) ?? '';
_hasVision = _prefs.getBool(_generateKey('hasVision')) ?? false;
_climbLevel = _prefs.getDouble(_generateKey('climbLevel')) ?? 0.0;
_trenchable = _prefs.getBool(_generateKey('trenchable')) ?? false;
_fuelCapacity = _prefs.getDouble(_generateKey('fuelCapacity')) ?? 0.0;
_autonRundownController.addListener(() => _saveString('autonRundown', _autonRundownController.text));
_botPositionController.text = prefs.getString(_generateKey('botPosition')) ?? '';
_botPositionController.addListener(() => _saveString('botPosition', _botPositionController.text));
_driveTrainTypeController.addListener(() => _saveString('driveTrainType', _driveTrainTypeController.text));
_generalObservationsController.text = prefs.getString(_generateKey('generalObservations')) ?? '';
_generalObservationsController.addListener(() => _saveString('generalObservations', _generalObservationsController.text));
_autonRundownController.text = prefs.getString(_generateKey('autonRundown')) ?? '';
_autonRundownController.addListener(() => _saveString('autonRundown', _autonRundownController.text));
_intakePositionController.text = prefs.getString(_generateKey('intakePosition')) ?? '';
_intakePositionController.addListener(() => _saveString('intakePosition', _intakePositionController.text));
_scoreMechanisimController.text = prefs.getString(_generateKey('scoreMechanism')) ?? '';
_scoreMechanisimController.addListener(() => _saveString('scoreMechanism', _scoreMechanisimController.text));
_fuelPerCycle = prefs.getDouble(_generateKey('fuelPerCycle')) ?? 0.0;
_canDriveUnderTrench = prefs.getBool(_generateKey('canDriveUnderTrench')) ?? false;
_canDriveOverBump = prefs.getBool(_generateKey('canDriveOverBump')) ?? false;
_climbLevel = prefs.getDouble(_generateKey('climbLevel')) ?? 0.0;
_fuelCapacity = prefs.getDouble(_generateKey('fuelCapacity')) ?? 0.0;
_canGiveToHumanPlayer = prefs.getBool(_generateKey('canGiveToHumanPlayer')) ?? false;
_cycleTime = prefs.getDouble(_generateKey('cycleTime')) ?? 0.0;
if (mounted) {
setState(() {
_isLoading = false;
@ -77,15 +93,15 @@ class _NotesPageState extends State<NotesPage> {
}
Future<void> _saveString(String field, String value) async {
await _prefs.setString(_generateKey(field), value);
await prefs.setString(_generateKey(field), value);
}
Future<void> _saveBool(String field, bool value) async {
await _prefs.setBool(_generateKey(field), value);
await prefs.setBool(_generateKey(field), value);
}
Future<void> _saveDouble(String field, double value) async {
await _prefs.setDouble(_generateKey(field), value);
await prefs.setDouble(_generateKey(field), value);
}
@override
@ -96,37 +112,39 @@ class _NotesPageState extends State<NotesPage> {
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Text(widget.teamName, style: Theme.of(context).textTheme.titleLarge)
: SafeArea(
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Text(widget.teamName, style: Theme.of(context).textTheme.titleLarge)
),
Padding(
padding: const EdgeInsets.all(16.0),
child: SegmentedButton<ScoutingView>(
segments: const [
ButtonSegment(value: ScoutingView.match, label: Text('Match Scouting')),
ButtonSegment(value: ScoutingView.pit, label: Text('Pit Scouting')),
],
selected: {_selectedView},
onSelectionChanged: (newSelection) {
setState(() {
_selectedView = newSelection.first;
});
},
),
),
Expanded(
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: _selectedView == ScoutingView.match
? _buildMatchScoutingView()
: _buildPitScoutingView(),
),
),
],
),
Padding(
padding: const EdgeInsets.all(16.0),
child: SegmentedButton<ScoutingView>(
segments: const [
ButtonSegment(value: ScoutingView.match, label: Text('Match Scouting')),
ButtonSegment(value: ScoutingView.pit, label: Text('Pit Scouting')),
],
selected: {_selectedView},
onSelectionChanged: (newSelection) {
setState(() {
_selectedView = newSelection.first;
});
},
),
),
Expanded(
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: _selectedView == ScoutingView.match
? _buildMatchScoutingView()
: _buildPitScoutingView(),
),
),
],
),
)
);
}
@ -146,15 +164,6 @@ class _NotesPageState extends State<NotesPage> {
),
),
const SizedBox(height: 16),
TextField(
controller: _autonRundownController,
decoration: const InputDecoration(
labelText: 'Autonomous Rundown',
hintText: 'Describe their auto',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 16),
TextField(
controller: _generalObservationsController,
decoration: const InputDecoration(
@ -175,32 +184,42 @@ class _NotesPageState extends State<NotesPage> {
Text('Robot Technical Details', style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: 16),
TextField(
controller: _driveTrainTypeController,
controller: _autonRundownController,
decoration: const InputDecoration(
labelText: 'Drivetrain Type',
hintText: 'e.g., Swerve, Tank',
labelText: 'Autonomous Rundown',
hintText: 'Describe their auto',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 16),
SwitchListTile(
title: Text('Has Vision/AprilTags', style: Theme.of(context).textTheme.titleSmall),
value: _hasVision,
title: Text('Can Drive Over Bump', style: Theme.of(context).textTheme.titleSmall),
value: _canDriveOverBump,
onChanged: (bool value) {
setState(() {
_hasVision = value;
_canDriveOverBump = value;
});
_saveBool('hasVision', value);
_saveBool('canDriveOverBump', value);
},
),
SwitchListTile(
title: Text('Can Go Under Trench', style: Theme.of(context).textTheme.titleSmall),
value: _trenchable,
value: _canDriveUnderTrench,
onChanged: (bool value) {
setState(() {
_trenchable = value;
_canDriveUnderTrench = value;
});
_saveBool('trenchable', value);
_saveBool('canDriveUnderTrench', value);
},
),
SwitchListTile(
title: Text('Can Give Fuel To Human Player', style: Theme.of(context).textTheme.titleSmall),
value: _canGiveToHumanPlayer,
onChanged: (bool value) {
setState(() {
_canGiveToHumanPlayer = value;
});
_saveBool('canGiveToHumanPlayer', value);
},
),
const SizedBox(height: 16),
@ -253,6 +272,56 @@ class _NotesPageState extends State<NotesPage> {
],
),
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Fuel Per Cycle - ${_fuelPerCycle.round()}', style: Theme.of(context).textTheme.titleSmall),
Slider(
value: _fuelPerCycle,
min: 0,
max: _fuelCapacity,
divisions: 50,
label: _fuelPerCycle.round().toString(),
onChanged: (double value) {
setState(() {
_fuelPerCycle = value;
});
},
onChangeEnd: (double value) {
_saveDouble('fuelPerCycle', value);
},
),
],
),
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Cycle Time - ${_cycleTime.round()}', style: Theme.of(context).textTheme.titleSmall),
Slider(
value: _cycleTime,
min: 0,
max: _cycleTime,
divisions: 50,
label: _cycleTime.round().toString(),
onChanged: (double value) {
setState(() {
_cycleTime = value;
});
},
onChangeEnd: (double value) {
_saveDouble('cycleTime', value);
},
),
],
),
),
],
);
}