Skip to content

Commit 5ffdf99

Browse files
[Material You] Migrate to Flutter Material 3 bottom navigation
1 parent 112d223 commit 5ffdf99

3 files changed

Lines changed: 32 additions & 74 deletions

File tree

lib/main_layout.dart

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'package:fallback/services/firebase_services.dart';
77
import 'package:fallback/services/secure_storage.dart';
88
import 'package:fallback/services/shared_prefs.dart';
99
import 'package:fallback/widgets_basic/buttons/custom_material_button.dart';
10-
import 'package:fallback/widgets_basic/material_you/you_bottom_app_bar_button.dart';
1110
import 'package:fallback/widgets_basic/material_you/you_alert_dialog.dart';
1211
import 'package:firebase_core/firebase_core.dart';
1312
import 'package:flutter/material.dart';
@@ -37,6 +36,7 @@ class _MainLayoutState extends LifecycleState<MainLayout> with SingleTickerProvi
3736
_secureStorage=SecureStorage.getInstance();
3837

3938
CanAuthenticateResponse availability=await (await _secureStorage).getBiometricStatus();
39+
4040
if(availability==CanAuthenticateResponse.success){
4141
return;
4242
}
@@ -165,39 +165,40 @@ class _MainLayoutState extends LifecycleState<MainLayout> with SingleTickerProvi
165165
return Scaffold(
166166
backgroundColor: kBackgroundColor,
167167
bottomNavigationBar: BottomAppBar(
168-
child: Container(
169-
color: kBackgroundColor,
170-
height: 65,
171-
child: Row(
172-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
173-
children: [
174-
YouBottomAppBarButton(
175-
iconData: Icons.home,
176-
text: "Home",
177-
isSelected: _selectedScreen==Screen.home,
178-
onPressed: (){
179-
if(_selectedScreen!=Screen.home){
180-
setState(() {
181-
_selectedScreen=Screen.home;
182-
});
183-
}
184-
},
168+
child: NavigationBarTheme(
169+
data: NavigationBarThemeData(
170+
backgroundColor: kBackgroundColor,
171+
indicatorColor: kIconColor,
172+
labelTextStyle: MaterialStateProperty.all(const TextStyle(
173+
color: kIconColor,
174+
),),
175+
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
176+
height: 65,
177+
),
178+
child: NavigationBar(
179+
onDestinationSelected: (index){
180+
if(_selectedScreen!=Screen.values[index]){
181+
setState(() {
182+
_selectedScreen=Screen.values[index];
183+
});
184+
}
185+
},
186+
selectedIndex: _selectedScreen.index,
187+
destinations: const [
188+
NavigationDestination(
189+
icon: Icon(Icons.home,color: kIconColor,),
190+
selectedIcon: Icon(Icons.home,color: kBackgroundColor,),
191+
label: "Home",
185192
),
186-
YouBottomAppBarButton(
187-
iconData: Icons.settings,
188-
text: "Settings",
189-
isSelected: _selectedScreen==Screen.settings,
190-
onPressed: (){
191-
if(_selectedScreen!=Screen.settings){
192-
setState(() {
193-
_selectedScreen=Screen.settings;
194-
});
195-
}
196-
},
193+
NavigationDestination(
194+
icon: Icon(Icons.settings,color: kIconColor,),
195+
selectedIcon: Icon(Icons.settings,color: kBackgroundColor,),
196+
label: "Settings",
197197
),
198198
],
199+
199200
),
200-
),
201+
)
201202
),
202203
floatingActionButton: AnimatedScale(
203204
duration: const Duration(milliseconds: 250),

lib/widgets_basic/material_you/you_bottom_app_bar_button.dart

Lines changed: 0 additions & 43 deletions
This file was deleted.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616
# Read more about iOS versioning at
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
version: 1.0.2+4
18+
version: 1.0.3+5
1919

2020
environment:
2121
sdk: ">=2.16.1 <3.0.0"

0 commit comments

Comments
 (0)