feat: Implement home screen with navigation and update login flow
This commit is contained in:
31
lib/screens/home_screen.dart
Normal file
31
lib/screens/home_screen.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'schedule_screen.dart';
|
||||
import 'profile_screen.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
@override
|
||||
_HomeScreenState createState() => _HomeScreenState();
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
int _idx = 0;
|
||||
final _pages = [ScheduleScreen(), ProfileScreen()];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: _pages[_idx],
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _idx,
|
||||
backgroundColor: Color(0xFF0c0a0a),
|
||||
selectedItemColor: Color(0xFFA24BFA),
|
||||
unselectedItemColor: Colors.white70,
|
||||
items: [
|
||||
BottomNavigationBarItem(icon: Icon(Icons.calendar_today), label: 'Beosztás'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profil'),
|
||||
],
|
||||
onTap: (i) => setState(() { _idx = i; }),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
setState(() { _loading = true; });
|
||||
final ok = await auth.login(username, password);
|
||||
setState(() { _loading = false; });
|
||||
if (ok) Navigator.pushReplacementNamed(context, '/profile');
|
||||
if (ok) Navigator.pushReplacementNamed(context, '/home');
|
||||
else ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Bejelentkezés sikertelen')));
|
||||
},
|
||||
child: _loading ? SizedBox(height: 16, width: 16, child: CircularProgressIndicator(strokeWidth: 2)) : Text('Bejelentkezés'),
|
||||
|
||||
@@ -13,9 +13,9 @@ class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderSt
|
||||
void initState() {
|
||||
super.initState();
|
||||
_ctrl = AnimationController(vsync: this, duration: Duration(seconds: 3))..repeat(reverse: true);
|
||||
// simulate load then navigate
|
||||
Timer(Duration(seconds: 2), () {
|
||||
Navigator.pushReplacementNamed(context, '/');
|
||||
// simulate load then navigate depending on token presence
|
||||
Timer(Duration(seconds: 1), () {
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user