-
Notifications
You must be signed in to change notification settings - Fork 33
/
yaru_navigation_rail.dart
95 lines (89 loc) · 2.58 KB
/
yaru_navigation_rail.dart
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import 'package:flutter/material.dart';
import 'package:yaru_widgets/src/pages/layouts/yaru_page_item.dart';
class YaruNavigationRail extends StatelessWidget {
const YaruNavigationRail({
super.key,
required this.destinations,
required this.selectedIndex,
required this.onDestinationSelected,
this.showLabels = false,
this.extended = false,
});
final List<YaruPageItem> destinations;
final int selectedIndex;
final ValueChanged<int> onDestinationSelected;
final bool showLabels;
final bool extended;
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
for (int i = 0; i < destinations.length; i += 1)
_YaruNavigationRailItem(
i,
i == selectedIndex,
destinations[i],
onDestinationSelected,
showLabels,
)
],
);
}
}
class _YaruNavigationRailItem extends StatelessWidget {
const _YaruNavigationRailItem(
this.index,
this.selected,
this.destination,
this.onSelected,
this.showLabel,
);
final int index;
final bool selected;
final YaruPageItem destination;
final ValueChanged<int> onSelected;
final bool showLabel;
@override
Widget build(BuildContext context) {
return SizedBox(
width: showLabel ? 85 : 60,
child: Material(
child: InkWell(
onTap: () => onSelected(index),
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 7, horizontal: 5),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: selected
? Theme.of(context)
.colorScheme
.onSurface
.withOpacity(.1)
: null,
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 2,
horizontal: 10,
),
child: Icon(destination.iconData),
),
),
if (showLabel) ...[
const SizedBox(height: 2),
destination.titleBuilder(context),
]
],
),
),
),
),
),
);
}
}