Laser Proxy support
This commit is contained in:
parent
f97222dcc9
commit
5858a4a231
5 changed files with 49 additions and 69 deletions
|
|
@ -5,9 +5,8 @@ import 'teampicker.dart';
|
|||
class EventPicker extends StatelessWidget {
|
||||
final List<String> eventNames;
|
||||
final List<String> eventCodes;
|
||||
final String apiKey;
|
||||
|
||||
EventPicker({required this.eventNames, required this.eventCodes, required this.apiKey});
|
||||
EventPicker({required this.eventNames, required this.eventCodes});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -27,7 +26,6 @@ class EventPicker extends StatelessWidget {
|
|||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TeamPicker(
|
||||
apiKey: apiKey,
|
||||
eventCode: eventCodes[index],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -4,12 +4,9 @@ import 'package:http/http.dart' as http;
|
|||
import 'dart:convert';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void getData(String apiKey, String teamNumber, Function(List<String>, List<String>) callback) async {
|
||||
void getData(String teamNumber, Function(List<String>, List<String>) callback) async {
|
||||
final response = await http.get(
|
||||
Uri.parse('https://www.thebluealliance.com/api/v3/team/frc$teamNumber/events/2025'),
|
||||
headers: {
|
||||
'X-TBA-Auth-Key': apiKey,
|
||||
},
|
||||
Uri.parse('https://laserscouter.halfheart.net/teamsearch/$teamNumber'),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
String data = response.body;
|
||||
|
|
@ -42,7 +39,7 @@ class MyApp extends StatelessWidget {
|
|||
useMaterial3: true,
|
||||
primaryColor: const Color.fromARGB(255, 19, 81, 179),
|
||||
appBarTheme: const AppBarTheme(
|
||||
color: Color.fromARGB(255, 19, 81, 179),
|
||||
backgroundColor: Color.fromARGB(255, 19, 81, 179),
|
||||
iconTheme: IconThemeData(color: Colors.white),
|
||||
),
|
||||
),
|
||||
|
|
@ -109,27 +106,17 @@ class _LoginPageState extends State<LoginPage> {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
TextField(
|
||||
controller: _apiKeyController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'TBA API Key',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await _saveData();
|
||||
String teamNumber = _teamNumberController.text;
|
||||
String apiKey = _apiKeyController.text;
|
||||
getData(apiKey, teamNumber, (eventNames, eventCodes) {
|
||||
getData(teamNumber, (eventNames, eventCodes) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EventPicker(
|
||||
eventNames: eventNames,
|
||||
eventCodes: eventCodes,
|
||||
apiKey: apiKey,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -4,12 +4,9 @@ import 'dart:convert';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:to_csv/to_csv.dart' as exportCSV;
|
||||
|
||||
void getData(String apiKey, String eventCode, Function(List<String>, List<String>) callback) async {
|
||||
void getData(String eventCode, Function(List<String>, List<String>) callback) async {
|
||||
final response = await http.get(
|
||||
Uri.parse('https://www.thebluealliance.com/api/v3/event/$eventCode/teams'),
|
||||
headers: {
|
||||
'X-TBA-Auth-Key': apiKey,
|
||||
},
|
||||
Uri.parse('https://laserscouter.halfheart.net/eventsearch/$eventCode'),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
String data = response.body;
|
||||
|
|
@ -28,10 +25,9 @@ void getData(String apiKey, String eventCode, Function(List<String>, List<String
|
|||
}
|
||||
|
||||
class TeamPicker extends StatefulWidget {
|
||||
final String apiKey;
|
||||
final String eventCode;
|
||||
|
||||
TeamPicker({required this.apiKey, required this.eventCode});
|
||||
TeamPicker({required this.eventCode});
|
||||
|
||||
@override
|
||||
_TeamPickerState createState() => _TeamPickerState();
|
||||
|
|
@ -43,7 +39,6 @@ class NotesPage extends StatefulWidget {
|
|||
final String teamName;
|
||||
NotesPage({required this.teamCode, required this.teamName, required this.eventCode});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
|
@ -204,7 +199,7 @@ class _TeamPickerState extends State<TeamPicker> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getData(widget.apiKey, widget.eventCode, (names, codes) {
|
||||
getData(widget.eventCode, (names, codes) {
|
||||
setState(() {
|
||||
teamNames = names;
|
||||
teamCodes = codes;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue