Skip to content

Commit ff8029f

Browse files
committed
feat(nav): use md3 drawer and bottom nav bar
1 parent 38cb842 commit ff8029f

File tree

3 files changed

+203
-206
lines changed

3 files changed

+203
-206
lines changed

lib/helpers/bottom_navigation_bar.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,11 @@ class _MainBottomNavigationBarState extends State<MainBottomNavigationBar> {
123123
),
124124
drawer: MainDrawer(_homeSetState),
125125
drawerEdgeDragWidth: MediaQuery.of(context).size.width / 4,
126-
bottomNavigationBar: BottomNavigationBar(
127-
type: BottomNavigationBarType.fixed,
128-
currentIndex: _selectedIndex,
126+
bottomNavigationBar: NavigationBar(
127+
selectedIndex: _selectedIndex,
129128
elevation: 10.0,
130-
items: UIProvider().getBottomNavigationBarButtons(context),
131-
onTap: _onItemTapped,
129+
destinations: UIProvider().getBottomNavigationBarButtons(context),
130+
onDestinationSelected: _onItemTapped,
132131
),
133132
body: screens.elementAt(_selectedIndex),
134133
);

lib/helpers/drawer.dart

Lines changed: 177 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -39,197 +39,195 @@ class MainDrawer extends StatelessWidget {
3939
String championship = Hive.box('settings')
4040
.get('championship', defaultValue: 'Formula 1') as String;
4141

42-
return Drawer(
43-
child: Column(
44-
children: [
45-
DrawerHeader(
46-
decoration: BoxDecoration(
47-
color: Theme.of(context).colorScheme.onPrimary,
48-
),
49-
child: const Center(
50-
child: Text(
51-
'Box, Box!',
52-
style: TextStyle(
53-
fontSize: 28,
54-
fontWeight: FontWeight.w700,
55-
),
42+
return NavigationDrawer(
43+
children: [
44+
DrawerHeader(
45+
decoration: BoxDecoration(
46+
color: Theme.of(context).colorScheme.onPrimary,
47+
),
48+
child: const Center(
49+
child: Text(
50+
'Box, Box!',
51+
style: TextStyle(
52+
fontSize: 28,
53+
fontWeight: FontWeight.w700,
5654
),
5755
),
5856
),
59-
championship == 'Formula 1'
60-
? ListTile(
61-
title: Text(
62-
'Formula You',
63-
),
64-
leading: Icon(
65-
Icons.account_circle_outlined,
66-
),
67-
onTap: () {
68-
context.pop();
69-
context.pushNamed('formula-you');
70-
},
71-
)
72-
: Container(),
73-
ListTile(
74-
title: Text(
75-
AppLocalizations.of(context)!.newsMix,
76-
),
77-
leading: Icon(
78-
Icons.dynamic_feed_outlined,
79-
),
80-
onTap: () {
81-
context.pop();
82-
context.pushNamed('mixed-news');
83-
},
57+
),
58+
championship == 'Formula 1'
59+
? ListTile(
60+
title: Text(
61+
'Formula You',
62+
),
63+
leading: Icon(
64+
Icons.account_circle_outlined,
65+
),
66+
onTap: () {
67+
context.pop();
68+
context.pushNamed('formula-you');
69+
},
70+
)
71+
: Container(),
72+
ListTile(
73+
title: Text(
74+
AppLocalizations.of(context)!.newsMix,
8475
),
85-
championship == 'Formula 1'
86-
? ListTile(
87-
title: Text(
88-
AppLocalizations.of(context)!.hallOfFame,
89-
),
90-
leading: Icon(
91-
Icons.emoji_events_outlined,
92-
),
93-
onTap: () {
94-
context.pop();
95-
context.pushNamed('hall-of-fame');
96-
},
97-
)
98-
: Container(),
99-
ListTile(
100-
title: Text(
101-
AppLocalizations.of(context)!.history,
102-
),
103-
leading: Icon(
104-
Icons.history_outlined,
105-
),
106-
onTap: () {
107-
context.pop();
108-
context.pushNamed('history');
109-
},
76+
leading: Icon(
77+
Icons.dynamic_feed_outlined,
78+
),
79+
onTap: () {
80+
context.pop();
81+
context.pushNamed('mixed-news');
82+
},
83+
),
84+
championship == 'Formula 1'
85+
? ListTile(
86+
title: Text(
87+
AppLocalizations.of(context)!.hallOfFame,
88+
),
89+
leading: Icon(
90+
Icons.emoji_events_outlined,
91+
),
92+
onTap: () {
93+
context.pop();
94+
context.pushNamed('hall-of-fame');
95+
},
96+
)
97+
: Container(),
98+
ListTile(
99+
title: Text(
100+
AppLocalizations.of(context)!.history,
110101
),
111-
!kIsWeb
112-
? ListTile(
113-
title: Text(
114-
AppLocalizations.of(context)!.downloads,
115-
),
116-
leading: Icon(
117-
Icons.save_alt_rounded,
118-
),
119-
onTap: () {
120-
context.pop();
121-
context.pushNamed('downloads');
122-
},
123-
)
124-
: Container(),
125-
Divider(
126-
indent: 15,
127-
endIndent: 15,
102+
leading: Icon(
103+
Icons.history_outlined,
128104
),
129-
ListTile(
130-
title: Text(
131-
AppLocalizations.of(context)!.settings,
132-
),
133-
leading: Icon(
134-
Icons.settings_outlined,
135-
),
136-
onTap: () {
137-
context.pop();
138-
context.pushNamed(
139-
'settings',
140-
extra: {
141-
'update': homeSetState,
105+
onTap: () {
106+
context.pop();
107+
context.pushNamed('history');
108+
},
109+
),
110+
!kIsWeb
111+
? ListTile(
112+
title: Text(
113+
AppLocalizations.of(context)!.downloads,
114+
),
115+
leading: Icon(
116+
Icons.save_alt_rounded,
117+
),
118+
onTap: () {
119+
context.pop();
120+
context.pushNamed('downloads');
142121
},
143-
);
144-
},
122+
)
123+
: Container(),
124+
Divider(
125+
indent: 15,
126+
endIndent: 15,
127+
),
128+
ListTile(
129+
title: Text(
130+
AppLocalizations.of(context)!.settings,
145131
),
146-
ListTile(
147-
title: Text(
148-
AppLocalizations.of(context)!.about,
149-
),
150-
leading: Icon(
151-
Icons.info_outlined,
152-
),
153-
onTap: () {
154-
context.pop();
155-
context.pushNamed('about');
156-
},
132+
leading: Icon(
133+
Icons.settings_outlined,
157134
),
158-
enableExperimentalFeatures
159-
? ListTile(
160-
title: Text(
161-
'Live Timing Feed',
162-
),
163-
leading: Icon(
164-
Icons.settings_outlined,
165-
),
166-
onTap: () {
167-
Navigator.of(context).pop();
168-
Navigator.push(
169-
context,
170-
MaterialPageRoute(
171-
builder: (context) => const ArchiveRacesListScreen(),
172-
),
173-
);
174-
},
175-
)
176-
: Container(),
177-
enableExperimentalFeatures
178-
? ListTile(
179-
title: Text(
180-
'Article Test Screen',
181-
),
182-
leading: Icon(
183-
Icons.settings_outlined,
184-
),
185-
onTap: () {
186-
Navigator.of(context).pop();
187-
Navigator.push(
188-
context,
189-
MaterialPageRoute(
190-
builder: (context) => const TestScreen(),
191-
),
192-
);
193-
},
194-
)
195-
: Container(),
196-
enableExperimentalFeatures
197-
? ListTile(
198-
title: Text(
199-
'Compare',
200-
),
201-
leading: Icon(
202-
Icons.compare_arrows_outlined,
203-
),
204-
onTap: () {
205-
Navigator.of(context).pop();
206-
Navigator.push(
207-
context,
208-
MaterialPageRoute(
209-
builder: (context) => const CompareHomeScreen(),
135+
onTap: () {
136+
context.pop();
137+
context.pushNamed(
138+
'settings',
139+
extra: {
140+
'update': homeSetState,
141+
},
142+
);
143+
},
144+
),
145+
ListTile(
146+
title: Text(
147+
AppLocalizations.of(context)!.about,
148+
),
149+
leading: Icon(
150+
Icons.info_outlined,
151+
),
152+
onTap: () {
153+
context.pop();
154+
context.pushNamed('about');
155+
},
156+
),
157+
enableExperimentalFeatures
158+
? ListTile(
159+
title: Text(
160+
'Live Timing Feed',
161+
),
162+
leading: Icon(
163+
Icons.settings_outlined,
164+
),
165+
onTap: () {
166+
Navigator.of(context).pop();
167+
Navigator.push(
168+
context,
169+
MaterialPageRoute(
170+
builder: (context) => const ArchiveRacesListScreen(),
171+
),
172+
);
173+
},
174+
)
175+
: Container(),
176+
enableExperimentalFeatures
177+
? ListTile(
178+
title: Text(
179+
'Article Test Screen',
180+
),
181+
leading: Icon(
182+
Icons.settings_outlined,
183+
),
184+
onTap: () {
185+
Navigator.of(context).pop();
186+
Navigator.push(
187+
context,
188+
MaterialPageRoute(
189+
builder: (context) => const TestScreen(),
190+
),
191+
);
192+
},
193+
)
194+
: Container(),
195+
enableExperimentalFeatures
196+
? ListTile(
197+
title: Text(
198+
'Compare',
199+
),
200+
leading: Icon(
201+
Icons.compare_arrows_outlined,
202+
),
203+
onTap: () {
204+
Navigator.of(context).pop();
205+
Navigator.push(
206+
context,
207+
MaterialPageRoute(
208+
builder: (context) => const CompareHomeScreen(),
209+
),
210+
);
211+
},
212+
)
213+
: Container(),
214+
Expanded(
215+
child: Align(
216+
alignment: Alignment.bottomCenter,
217+
child: FutureBuilder<PackageInfo>(
218+
future: PackageInfo.fromPlatform(),
219+
builder: (context, snapshot) => snapshot.hasData
220+
? Padding(
221+
padding: const EdgeInsets.only(bottom: 10),
222+
child: Text(
223+
snapshot.data!.version,
210224
),
211-
);
212-
},
213-
)
214-
: Container(),
215-
Expanded(
216-
child: Align(
217-
alignment: Alignment.bottomCenter,
218-
child: FutureBuilder<PackageInfo>(
219-
future: PackageInfo.fromPlatform(),
220-
builder: (context, snapshot) => snapshot.hasData
221-
? Padding(
222-
padding: const EdgeInsets.only(bottom: 10),
223-
child: Text(
224-
snapshot.data!.version,
225-
),
226-
)
227-
: const Text(''),
228-
),
225+
)
226+
: const Text(''),
229227
),
230228
),
231-
],
232-
),
229+
),
230+
],
233231
);
234232
}
235233
}

0 commit comments

Comments
 (0)