Added ability to add custom teams and events.
This commit is contained in:
parent
84aaf9c527
commit
9327b6120f
8 changed files with 687 additions and 189 deletions
208
lib/login.dart
208
lib/login.dart
|
|
@ -67,112 +67,116 @@ class _LoginPageState extends State<LoginPage> {
|
|||
appBar: AppBar(
|
||||
title: const Text('Login'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/main.png', height: 75, alignment: Alignment.center),
|
||||
const SizedBox(height: 16.0),
|
||||
TextField(
|
||||
controller: _teamNumberController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Team Number',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
ElevatedButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () async {
|
||||
final navigator = Navigator.of(context);
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
try {
|
||||
await _saveData();
|
||||
String teamNumber = _teamNumberController.text;
|
||||
final result = await teamSearch(teamNumber);
|
||||
navigator.push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EventPicker(
|
||||
eventNames: result.eventNames,
|
||||
eventCodes: result.eventCodes,
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
SnackBar(content: Text('Error: ${e.toString()}')),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
child: _isLoading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
color: Colors.white,
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Image.asset('assets/main.png', height: 75, alignment: Alignment.center),
|
||||
const SizedBox(height: 16.0),
|
||||
TextField(
|
||||
controller: _teamNumberController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Team Number',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
)
|
||||
: 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"
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
ElevatedButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () async {
|
||||
final navigator = Navigator.of(context);
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
try {
|
||||
await _saveData();
|
||||
String teamNumber = _teamNumberController.text;
|
||||
final result = await teamSearch(teamNumber);
|
||||
navigator.push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EventPicker(
|
||||
eventNames: result.eventNames,
|
||||
eventCodes: result.eventCodes,
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Error: ${e.toString()}'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
margin: const EdgeInsets.all(16.0),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Github'),
|
||||
onPressed: () {
|
||||
_launchUrl(Uri.parse('https://github.com/raktbastr/laserscouter'));
|
||||
}
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SettingsPage(),
|
||||
}
|
||||
},
|
||||
child: _isLoading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: const Text('Login'),
|
||||
),
|
||||
const Spacer(),
|
||||
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.2.14}"
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Github'),
|
||||
onPressed: () {
|
||||
_launchUrl(Uri.parse('https://github.com/raktbastr/laserscouter'));
|
||||
}
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SettingsPage(),
|
||||
)
|
||||
);
|
||||
},
|
||||
child: const Text('Settings'),
|
||||
)
|
||||
);
|
||||
},
|
||||
child: const Text('Settings'),
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue