Added bottom options and reset.

This commit is contained in:
Raktbastr 2026-01-23 17:27:24 -06:00
parent 78618aed9a
commit 84aaf9c527
6 changed files with 125 additions and 10 deletions

View file

@ -117,7 +117,7 @@ final ThemeData laserTheme = ThemeData(
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.white,
backgroundColor: Color(0x00FFFFFF),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
),

View file

@ -4,6 +4,7 @@ import 'core/theme.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'eventpicker.dart';
import 'settings.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(const MyApp());
@ -49,6 +50,12 @@ class _LoginPageState extends State<LoginPage> {
await prefs.setString('teamNumber', _teamNumberController.text);
}
Future<void> _launchUrl(Uri url) async {
if (!await launchUrl(url)) {
throw Exception('Could not launch $url');
}
}
@override
void dispose() {
_teamNumberController.dispose();
@ -65,7 +72,7 @@ class _LoginPageState extends State<LoginPage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/main.png', height: 100),
Image.asset('assets/main.png', height: 75, alignment: Alignment.center),
const SizedBox(height: 16.0),
TextField(
controller: _teamNumberController,
@ -120,9 +127,38 @@ class _LoginPageState extends State<LoginPage> {
),
)
: const Text('Login'),
)
],
),
),
bottomNavigationBar: Padding (
padding: const EdgeInsets.all(50.0),
child: Row (
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
child: const Text('Info'),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Info'),
content: const Text(
"This app makes use of The Blue Alliance APIv3 through Laser Proxy. No API keys are stored on device. Laser Scouter was created by FRC 2077 Laser Robotics. \n\nVersion: Rebuilt 26.1.23"
),
);
}
);
},
),
const SizedBox(height: 8),
ElevatedButton(
TextButton(
child: const Text('Github'),
onPressed: () {
_launchUrl(Uri.parse('https://github.com/raktbastr/laserscouter'));
}
),
TextButton(
onPressed: _isLoading
? null
: () {
@ -130,13 +166,14 @@ class _LoginPageState extends State<LoginPage> {
context,
MaterialPageRoute(
builder: (context) => const SettingsPage(),
));
)
);
},
child: const Text('Settings'),
),
],
),
),
)
]
)
)
);
}
}

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'core/api.dart';
import 'login.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@ -72,6 +73,46 @@ class _SettingsPageState extends State<SettingsPage> {
}
),
const Divider(height: 32),
ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Reset All Data'),
content: const Text('Are you sure you want to reset all data?'),
actions: <Widget>[
ElevatedButton(
onPressed: () async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.clear();
Navigator.pop(context);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => const LoginPage(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
textStyle: const TextStyle(color: Colors.white),
),
child: const Text('Yes'),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('No'),
),
]
);
}
);
},
child: const Text('Reset All Data'),
),
],
),
);