-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_rail.dart
More file actions
76 lines (74 loc) · 2.59 KB
/
base_rail.dart
File metadata and controls
76 lines (74 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:time_keeper/router/app_routes.dart';
class BaseRail extends HookConsumerWidget {
const BaseRail({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
// Derive selected index from current route instead of local state
final selectedIndex = AppRoute.currentRailIndex(context);
final isExtended = useState(false);
return Positioned(
left: 0,
top: 0,
bottom: 0,
child: Row(
children: [
NavigationRail(
extended: isExtended.value,
minWidth: 48,
minExtendedWidth: 200,
selectedIndex: selectedIndex,
onDestinationSelected: (index) {
// Type-safe navigation using the enum
final route = AppRoute.fromRailIndex(index);
route?.go(context);
},
leading: Padding(
padding: const EdgeInsets.only(bottom: 30, top: 20),
child: IconButton(
style: IconButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
icon: Icon(isExtended.value ? Icons.chevron_left : Icons.menu),
onPressed: () => isExtended.value = !isExtended.value,
),
),
destinations: const [
NavigationRailDestination(
icon: Icon(Icons.handyman),
label: Text('Settings'),
),
NavigationRailDestination(
icon: Icon(Icons.person),
label: Text('Users'),
),
NavigationRailDestination(
icon: Icon(Icons.supervised_user_circle),
label: Text('Team'),
),
NavigationRailDestination(
icon: Icon(Icons.event_note),
label: Text('Sessions'),
),
NavigationRailDestination(
icon: Icon(Icons.location_on),
label: Text('Locations'),
),
NavigationRailDestination(
icon: Icon(Icons.analytics),
label: Text('Statistics'),
),
],
),
const VerticalDivider(thickness: 1, width: 1),
],
),
);
}
}