Laser Proxy support

This commit is contained in:
Raktbastr 2026-01-06 21:32:11 -06:00
parent f97222dcc9
commit 5858a4a231
5 changed files with 49 additions and 69 deletions

View file

@ -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,
),
),
);