11import 'package:fluent_ui/fluent_ui.dart' ;
22import 'package:fluentui_system_icons/fluentui_system_icons.dart' as msicons;
3+ import 'package:flutter_svg/svg.dart' ;
34import 'package:go_router/go_router.dart' ;
45import '../../i18n/generated/strings.g.dart' ;
6+ import 'package:vector_graphics/vector_graphics.dart' ;
57
68enum RouteSection { main, footer, search }
79
810enum RouteMeta {
911 home (
1012 path: '/' ,
1113 section: RouteSection .main,
12- icon: msicons.FluentIcons .home_24_regular,
14+ icon: SvgPicture (
15+ AssetBytesLoader ('assets/icon/pane/ic_revi_fluent_home_color.svg.vec' ),
16+ width: 20 ,
17+ height: 20 ,
18+ ),
1319 ),
1420 tweaks (
1521 path: '/tweaks' ,
1622 section: RouteSection .main,
17- icon: msicons.FluentIcons .wrench_24_regular,
23+ icon: SvgPicture (
24+ AssetBytesLoader (
25+ 'assets/icon/pane/ic_revi_fluent_wrench_24_color.svg.vec' ,
26+ ),
27+ width: 20 ,
28+ height: 20 ,
29+ ),
1830 ),
1931 msStore (
2032 path: '/msstore' ,
2133 section: RouteSection .main,
22- icon: msicons.FluentIcons .store_microsoft_24_regular,
34+ icon: SvgPicture (
35+ AssetBytesLoader (
36+ 'assets/icon/pane/ic_revi_fluent_ms_store_48_color.svg.vec' ,
37+ ),
38+ width: 24 ,
39+ height: 24 ,
40+ ),
2341 ),
2442 settings (
2543 path: '/settings' ,
2644 section: RouteSection .footer,
27- icon: msicons.FluentIcons .settings_24_regular,
45+ icon: SvgPicture (
46+ AssetBytesLoader ('assets/icon/pane/ic_fluent_settings_48_color.svg.vec' ),
47+ width: 20 ,
48+ height: 20 ,
49+ ),
2850 ),
2951 tweaksSecurity (
3052 path: '/tweaks/security' ,
@@ -60,32 +82,25 @@ enum RouteMeta {
6082
6183 final String path;
6284 final RouteSection section;
63- final IconData icon;
85+ final Object ? icon;
6486
6587 String get label {
66- switch (this ) {
67- case RouteMeta .home:
68- return t.pageHome;
69- case RouteMeta .tweaks:
70- return t.pageTweaks;
71- case RouteMeta .msStore:
72- return t.pageMSStore;
73- case RouteMeta .settings:
74- return t.pageSettings;
75- case RouteMeta .tweaksSecurity:
76- return t.pageTweaksSecurity;
77- case RouteMeta .tweaksPerformance:
78- return t.pageTweaksPerformance;
79- case RouteMeta .tweaksPersonalization:
80- return t.pageTweaksPersonalization;
81- case RouteMeta .tweaksUtilities:
82- return t.pageTweaksUtilities;
83- case RouteMeta .tweaksUpdates:
84- return t.pageTweaksUpdates;
85- }
88+ return switch (this ) {
89+ RouteMeta .home => t.pageHome,
90+ RouteMeta .tweaks => t.pageTweaks,
91+ RouteMeta .msStore => t.pageMSStore,
92+ RouteMeta .settings => t.pageSettings,
93+ RouteMeta .tweaksSecurity => t.pageTweaksSecurity,
94+ RouteMeta .tweaksPerformance => t.pageTweaksPerformance,
95+ RouteMeta .tweaksPersonalization => t.pageTweaksPersonalization,
96+ RouteMeta .tweaksUtilities => t.pageTweaksUtilities,
97+ RouteMeta .tweaksUpdates => t.pageTweaksUpdates,
98+ };
8699 }
87100
88- static final Map <String , RouteMeta > _pathLookup = {for (final r in values) r.path: r};
101+ static final Map <String , RouteMeta > _pathLookup = {
102+ for (final r in values) r.path: r,
103+ };
89104
90105 static RouteMeta ? fromPath (String path, {bool allowPrefix = false }) {
91106 if (! allowPrefix) return _pathLookup[path];
@@ -104,9 +119,15 @@ class AppRoutes {
104119
105120 static const List <RouteMeta > navigationRoutes = _navigationRoutes;
106121
107- static final List <NavigationPaneItem > mainPaneItems = _buildPaneItems (_mainNavigationRoutes);
108- static final List <NavigationPaneItem > footerPaneItems = _buildPaneItems (_footerNavigationRoutes);
109- static final List <NavigationPaneItem > searchableItems = _buildPaneItems (_searchableRoutes);
122+ static final List <NavigationPaneItem > mainPaneItems = _buildPaneItems (
123+ _mainNavigationRoutes,
124+ );
125+ static final List <NavigationPaneItem > footerPaneItems = _buildPaneItems (
126+ _footerNavigationRoutes,
127+ );
128+ static final List <NavigationPaneItem > searchableItems = _buildPaneItems (
129+ _searchableRoutes,
130+ );
110131
111132 static String getRouteName (String path, BuildContext context) {
112133 final RouteMeta ? meta = RouteMeta .fromPath (path);
@@ -126,7 +147,10 @@ class AppRoutes {
126147 String location,
127148 BuildContext context,
128149 ) {
129- final List <String > segments = location.split ('/' ).where ((s) => s.isNotEmpty).toList ();
150+ final List <String > segments = location
151+ .split ('/' )
152+ .where ((s) => s.isNotEmpty)
153+ .toList ();
130154 final FluentThemeData theme = FluentTheme .of (context);
131155
132156 var currentPath = '' ;
@@ -205,7 +229,11 @@ List<NavigationPaneItem> _buildPaneItems(List<RouteMeta> routes) {
205229 .map (
206230 (route) => PaneItem (
207231 key: ValueKey (route.path),
208- icon: Icon (route.icon, size: 20 ),
232+ icon: switch (route.icon) {
233+ final IconData iconData => Icon (iconData),
234+ final SvgPicture svg => svg,
235+ _ => const SizedBox .shrink (),
236+ },
209237 title: Text (route.label),
210238 body: const SizedBox .shrink (),
211239 ),
0 commit comments