fix navbar matching when using global back button
This commit is contained in:
@@ -113,18 +113,29 @@ class _LoginPanelContentState extends State<LoginPanelContent> {
|
||||
final _usernameController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
bool _loggingIn = false;
|
||||
|
||||
void login() async {
|
||||
final username = _usernameController.text;
|
||||
final password = _passwordController.text;
|
||||
|
||||
final auth = context.read<AuthService>();
|
||||
|
||||
setState(() {
|
||||
_loggingIn = true;
|
||||
});
|
||||
try {
|
||||
auth.login(username, password);
|
||||
print('Login successful');
|
||||
setState(() {
|
||||
_loggingIn = false;
|
||||
});
|
||||
} catch (e) {
|
||||
// Handle error
|
||||
print('Login failed: $e');
|
||||
setState(() {
|
||||
_loggingIn = false;
|
||||
});
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Login failed')));
|
||||
@@ -133,6 +144,15 @@ class _LoginPanelContentState extends State<LoginPanelContent> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget loginButtonContent = Text("Login");
|
||||
if (_loggingIn) {
|
||||
loginButtonContent = Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
} else {
|
||||
loginButtonContent = Text("Login");
|
||||
}
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -164,7 +184,7 @@ class _LoginPanelContentState extends State<LoginPanelContent> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 10,
|
||||
children: [
|
||||
FilledButton(onPressed: login, child: Text("Login")),
|
||||
FilledButton(onPressed: login, child: loginButtonContent),
|
||||
ElevatedButton(
|
||||
onPressed: widget.registerCb,
|
||||
child: Text("Register"),
|
||||
|
||||
10
lib/components/pages/newEntry.dart
Normal file
10
lib/components/pages/newEntry.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:mileograph_flutter/services/dataService.dart';
|
||||
|
||||
class NewEntryPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final data = context.watch<DataService>();
|
||||
return Center(child: Text("New Entry Page"));
|
||||
}
|
||||
}
|
||||
33
lib/components/pages/trips.dart
Normal file
33
lib/components/pages/trips.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:mileograph_flutter/services/dataService.dart';
|
||||
|
||||
class TripsPage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final data = context.watch<DataService>();
|
||||
return ListView.builder(
|
||||
itemCount: data.legs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final leg = data.legs[index];
|
||||
return Card(
|
||||
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${leg.start} → ${leg.end}',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
Text('Mileage: ${leg.mileage.toStringAsFixed(2)} km'),
|
||||
Text('Headcode: ${leg.headcode}'),
|
||||
Text('Begin: ${leg.beginTime}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user