Skip to content

Commit

Permalink
Merge pull request #50 from FRC2706/dev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
ryanidk authored Mar 14, 2024
2 parents f468f14 + e68faf5 commit e3ed2e8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
4 changes: 3 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:merge_data/screens/start.dart';

const CURRENT_YEAR = 2024;
const API_ENDPOINT = "https://ryanidkproductions.com/api/mergedata";

void main() {
runApp(const MergeDataApp());
Expand All @@ -20,7 +21,8 @@ class MergeDataApp extends StatelessWidget {
seedColor: const Color.fromARGB(255, 102, 51, 153)),
useMaterial3: true,
),
home: const StartPage(title: 'MergeData', year: CURRENT_YEAR),
home: const StartPage(
title: 'MergeData', year: CURRENT_YEAR, api: API_ENDPOINT),
);
}
}
10 changes: 6 additions & 4 deletions lib/screens/match_scouting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'dart:async';
import 'send_data.dart';

class MatchScoutingPage extends StatefulWidget {
const MatchScoutingPage({super.key, required this.title, required this.year});
const MatchScoutingPage(
{super.key, required this.title, required this.year, required this.api});

final String title;
final int year;
final String api;

@override
State<MatchScoutingPage> createState() => _MatchScoutingState();
Expand Down Expand Up @@ -190,9 +192,9 @@ class _MatchScoutingState extends State<MatchScoutingPage> {
context,
MaterialPageRoute(
builder: (context) => SendData(
data: getBunchValues(),
isGame: true,
)),
data: getBunchValues(),
isGame: true,
api: widget.api)),
);
},
),
Expand Down
10 changes: 6 additions & 4 deletions lib/screens/pit_scouting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import 'package:flutter/services.dart';
import 'send_data.dart';

class PitScoutingPage extends StatefulWidget {
PitScoutingPage({Key? key, required this.title, required this.year})
PitScoutingPage(
{Key? key, required this.title, required this.year, required this.api})
: super(key: key);

final String title;
final int year;
final String api;

@override
_PitScoutingState createState() => _PitScoutingState();
Expand Down Expand Up @@ -86,9 +88,9 @@ class _PitScoutingState extends State<PitScoutingPage> {
context,
MaterialPageRoute(
builder: (context) => SendData(
data: getBunchValues(),
isGame: false,
)),
data: getBunchValues(),
isGame: false,
api: widget.api)),
);
},
),
Expand Down
10 changes: 5 additions & 5 deletions lib/screens/scan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:qr_code_scanner/qr_code_scanner.dart';
class ScanResultsPage extends StatefulWidget {
final String title;
final int year;
final String api;

ScanResultsPage({Key? key, required this.title, required this.year})
ScanResultsPage(
{Key? key, required this.title, required this.year, required this.api})
: super(key: key);

@override
Expand All @@ -30,10 +32,8 @@ class _ScanResultsPageState extends State<ScanResultsPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SendData(
data: values,
isGame: isGame,
)),
builder: (context) =>
SendData(data: values, isGame: isGame, api: widget.api)),
);
}

Expand Down
7 changes: 4 additions & 3 deletions lib/screens/send_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ class SendData extends StatefulWidget {
final Map<String, String> data;
final bool isGame;
final bool justSend;
final String api;

SendData(
{Key? key,
required this.data,
required this.isGame,
this.justSend = false})
this.justSend = false,
required this.api})
: super(key: key);

@override
Expand Down Expand Up @@ -54,8 +56,7 @@ class _SendDataState extends State<SendData> {
}

Future<Map> fetchApi(String key) async {
var a = await http.get(Uri.parse(
'https://ryanidkproductions.com/api/mergedata?key=$key')); // temp api host
var a = await http.get(Uri.parse('${widget.api}?key=$key'));
if (a.statusCode == 200) {
return jsonDecode(a.body);
} else {
Expand Down
19 changes: 11 additions & 8 deletions lib/screens/start.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:shared_preferences/shared_preferences.dart';

class StartPage extends StatefulWidget {
const StartPage({super.key, required this.title, required this.year});
const StartPage(
{super.key, required this.title, required this.year, required this.api});

final String title;
final int year;
final String api;

@override
State<StartPage> createState() => _StartState();
Expand All @@ -22,8 +24,8 @@ class _StartState extends State<StartPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
MatchScoutingPage(title: "Match Scouting", year: widget.year),
builder: (context) => MatchScoutingPage(
title: "Match Scouting", year: widget.year, api: widget.api),
),
);
}
Expand All @@ -32,8 +34,8 @@ class _StartState extends State<StartPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PitScoutingPage(title: "Pit Scouting", year: widget.year),
builder: (context) => PitScoutingPage(
title: "Pit Scouting", year: widget.year, api: widget.api),
),
);
}
Expand All @@ -42,8 +44,8 @@ class _StartState extends State<StartPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ScanResultsPage(title: "Scan Results", year: widget.year),
builder: (context) => ScanResultsPage(
title: "Scan Results", year: widget.year, api: widget.api),
),
);
}
Expand All @@ -52,7 +54,8 @@ class _StartState extends State<StartPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SendData(data: {}, isGame: true, justSend: true),
builder: (context) =>
SendData(data: {}, isGame: true, justSend: true, api: widget.api),
),
);
}
Expand Down

0 comments on commit e3ed2e8

Please sign in to comment.