Add login page and basic event select page.

This commit is contained in:
Raktbastr 2025-02-03 15:04:15 -06:00
parent 71870260e4
commit a5603f21f1
7 changed files with 143 additions and 97 deletions

BIN
assets/laserscouterlogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -51,7 +51,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Profile"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"

20
lib/eventpicker.dart Normal file
View file

@ -0,0 +1,20 @@
// login.dart
import 'package:flutter/material.dart';
class EventPicker extends StatelessWidget {
const EventPicker({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Event', style: TextStyle(color: Colors.white)),
backgroundColor: const Color.fromARGB(255, 19, 81, 179),
iconTheme: const IconThemeData(color: Colors.white),
),
body: Center(
child: Text('Login Page Content'),
),
);
}
}

95
lib/login.dart Normal file
View file

@ -0,0 +1,95 @@
import 'package:flutter/material.dart';
import 'eventpicker.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'eventpicker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Login Page',
theme: ThemeData(
useMaterial3: true,
appBarTheme: const AppBarTheme(
iconTheme: IconThemeData(color: Colors.white),
),
),
home: const LoginPage(),
);
}
}
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final TextEditingController _teamNumberController = TextEditingController();
final TextEditingController _apiKeyController = TextEditingController();
@override
void dispose() {
_teamNumberController.dispose();
_apiKeyController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Login', style: TextStyle(color: Colors.white)),
backgroundColor: const Color.fromARGB(255, 19, 81, 179),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/laserscouterlogo.png', height: 100),
const SizedBox(height: 16.0),
TextField(
controller: _teamNumberController,
decoration: const InputDecoration(
labelText: 'Team Number',
border: OutlineInputBorder(),
),
),
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 {
String teamNumber = _teamNumberController.text;
String apiKey = _apiKeyController.text;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => EventPicker()),
);
},
child: const Text('Login'),
),
],
),
),
);
}
}

View file

@ -1,110 +1,22 @@
import 'package:flutter/material.dart';
import 'login.dart';
void main() {
runApp(const MyApp());
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Laser Scouter',
theme: ThemeData(fontFamily: 'Ocraextended',
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent),
useMaterial3: true,
theme: ThemeData(
primarySwatch: Colors.blue,
fontFamily: 'Ocraextended',
),
home: const MyHomePage(title: 'Laser Scouter'),
home: LoginPage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
}

View file

@ -131,6 +131,22 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: "direct main"
description:
name: http
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
url: "https://pub.dev"
source: hosted
version: "0.13.6"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
source: hosted
version: "4.1.2"
image:
dependency: transitive
description:

View file

@ -36,6 +36,8 @@ dependencies:
cupertino_icons: ^1.0.8
flutter_launcher_icons: ^0.14.3
http: ^0.13.4
dev_dependencies:
flutter_test:
sdk: flutter
@ -59,7 +61,8 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
assets:
- assets/laserscouterlogo.png
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg