💄 Optimized UX
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:goatagent/screens/account.dart';
|
||||
import 'package:goatagent/screens/dashboard.dart';
|
||||
import 'package:goatagent/screens/notifications.dart';
|
||||
|
||||
class AgentNavigation extends StatefulWidget {
|
||||
const AgentNavigation({super.key, required this.router});
|
||||
|
||||
final GoRouter router;
|
||||
const AgentNavigation({super.key});
|
||||
|
||||
static const items = [
|
||||
NavigationDestination(
|
||||
@ -22,20 +22,17 @@ class AgentNavigation extends StatefulWidget {
|
||||
)
|
||||
];
|
||||
|
||||
static const destinations = ["/", "/notifications", "/account"];
|
||||
|
||||
@override
|
||||
State<AgentNavigation> createState() => _AgentNavigationState();
|
||||
}
|
||||
|
||||
class _AgentNavigationState extends State<AgentNavigation> {
|
||||
int _selected = 0;
|
||||
int _view = 0;
|
||||
|
||||
Future<void> initMessage(BuildContext context) async {
|
||||
void navigate() {
|
||||
widget.router.replace("/notifications");
|
||||
setState(() {
|
||||
_selected = 1;
|
||||
_view = 1;
|
||||
});
|
||||
}
|
||||
|
||||
@ -59,16 +56,33 @@ class _AgentNavigationState extends State<AgentNavigation> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return NavigationBar(
|
||||
selectedIndex: _selected,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
|
||||
destinations: AgentNavigation.items,
|
||||
onDestinationSelected: (index) {
|
||||
widget.router.replace(AgentNavigation.destinations[index]);
|
||||
setState(() {
|
||||
_selected = index;
|
||||
});
|
||||
},
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Offstage(
|
||||
offstage: _view != 0,
|
||||
child: const DashboardScreen(),
|
||||
),
|
||||
Offstage(
|
||||
offstage: _view != 1,
|
||||
child: const NotificationScreen(),
|
||||
),
|
||||
Offstage(
|
||||
offstage: _view != 2,
|
||||
child: const AccountScreen(),
|
||||
)
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: _view,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
|
||||
destinations: AgentNavigation.items,
|
||||
onDestinationSelected: (index) {
|
||||
setState(() {
|
||||
_view = index;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user