Skip to content
Merged

Dev #79

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
10 changes: 5 additions & 5 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- Flutter (1.0.0)
- MTBBarcodeScanner (5.0.11)
- qr_code_scanner (0.2.0):
- qr_code_scanner_plus (0.2.6):
- Flutter
- MTBBarcodeScanner
- shared_preferences_foundation (0.0.1):
Expand All @@ -12,7 +12,7 @@ PODS:

DEPENDENCIES:
- Flutter (from `Flutter`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- qr_code_scanner_plus (from `.symlinks/plugins/qr_code_scanner_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

Expand All @@ -23,8 +23,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
qr_code_scanner:
:path: ".symlinks/plugins/qr_code_scanner/ios"
qr_code_scanner_plus:
:path: ".symlinks/plugins/qr_code_scanner_plus/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios:
Expand All @@ -33,7 +33,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
qr_code_scanner_plus: 3bfe4deb7f28996a63a2a580819d49dae80d5ed3
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

Expand Down
165 changes: 86 additions & 79 deletions lib/screens/pit_scouting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,89 +129,96 @@ class _PitScoutingState extends State<PitScoutingPage> {
),
body: ListView.builder(
padding: const EdgeInsets.all(8),
itemCount: formFields['Pit']?.length ?? 0,
itemCount: formFields['Pit']?.length + 1 ?? 0,
itemBuilder: (BuildContext context, int index) {
var field = formFields['Pit'][index];
bool showError = fieldErrors[field['name']] ?? false;
if (field['type'] == 'number') {
return Column(
children: [
TextFormField(
keyboardType: TextInputType.number,
initialValue:
textValues[field['name']] ?? '', // Use the stored value
decoration: InputDecoration(
labelText: field['name'],
errorText: showError ? 'This field is required' : null,
),
onChanged: (value) {
if (field['required'] && (value == null || value.isEmpty)) {
fieldErrors[field['name']] = true;
} else {
fieldErrors[field['name']] = false;
}
textValues[field['name']] = value; // Update textValues
setState(() {});
},
),
],
);
} else if (field['type'] == 'text') {
return Column(
children: [
TextFormField(
initialValue:
textValues[field['name']] ?? '', // Use the stored value
decoration: InputDecoration(
labelText: field['name'],
errorText: showError ? 'This field is required' : null,
if (index != formFields['Pit']?.length) {
var field = formFields['Pit'][index];
bool showError = fieldErrors[field['name']] ?? false;
if (field['type'] == 'number') {
return Column(
children: [
TextFormField(
keyboardType: TextInputType.number,
initialValue:
textValues[field['name']] ?? '', // Use the stored value
decoration: InputDecoration(
labelText: field['name'],
errorText: showError ? 'This field is required' : null,
),
onChanged: (value) {
if (field['required'] &&
(value == null || value.isEmpty)) {
fieldErrors[field['name']] = true;
} else {
fieldErrors[field['name']] = false;
}
textValues[field['name']] = value; // Update textValues
setState(() {});
},
),
onChanged: (value) {
if (field['required'] && (value == null || value.isEmpty)) {
fieldErrors[field['name']] = true;
} else {
fieldErrors[field['name']] = false;
}
textValues[field['name']] = value; // Update textValues
setState(() {});
},
),
],
);
} else if (field['type'] == 'radio') {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
field['name'],
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
...field['choices'].map<Widget>((choice) {
return ListTile(
title: Text(choice),
leading: Radio<String>(
value: choice,
groupValue: radioValues[field['name']],
onChanged: (String? value) {
if (value != null) {
setState(() {
radioValues[field['name']] = value;
fieldErrors[field['name']] = false;
});
}
},
],
);
} else if (field['type'] == 'text') {
return Column(
children: [
TextFormField(
initialValue:
textValues[field['name']] ?? '', // Use the stored value
decoration: InputDecoration(
labelText: field['name'],
errorText: showError ? 'This field is required' : null,
),
);
}).toList(),
showError
? Text('This field is required',
style: TextStyle(color: Colors.red))
: SizedBox.shrink(),
],
);
onChanged: (value) {
if (field['required'] &&
(value == null || value.isEmpty)) {
fieldErrors[field['name']] = true;
} else {
fieldErrors[field['name']] = false;
}
textValues[field['name']] = value; // Update textValues
setState(() {});
},
),
],
);
} else if (field['type'] == 'radio') {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
field['name'],
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
...field['choices'].map<Widget>((choice) {
return ListTile(
title: Text(choice),
leading: Radio<String>(
value: choice,
groupValue: radioValues[field['name']],
onChanged: (String? value) {
if (value != null) {
setState(() {
radioValues[field['name']] = value;
fieldErrors[field['name']] = false;
});
}
},
),
);
}).toList(),
showError
? Text('This field is required',
style: TextStyle(color: Colors.red))
: SizedBox.shrink(),
],
);
} else {
return SizedBox
.shrink(); // Return an empty widget for unsupported field types
}
} else {
return SizedBox
.shrink(); // Return an empty widget for unsupported field types
return Text(
"Please send pictures of the robot to the scouting channel");
}
},
),
Expand Down
Loading