Skip to content

Commit

Permalink
Add bottom navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Mar 4, 2024
1 parent 36acd48 commit dfe4f9a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class MyApp extends StatelessWidget {
expansionTileTheme: const ExpansionTileThemeData().copyWith(
backgroundColor: kColorScheme.backgroundDarker,
collapsedBackgroundColor: ThemeData().colorScheme.background),
bottomNavigationBarTheme: const BottomNavigationBarThemeData().copyWith(
selectedItemColor: kColorScheme.primary,
unselectedItemColor: kColorScheme.secondary,
),
),
darkTheme: ThemeData(
useMaterial3: true,
Expand All @@ -121,6 +125,10 @@ class MyApp extends StatelessWidget {
expansionTileTheme: const ExpansionTileThemeData().copyWith(
backgroundColor: kDarkColorScheme.backgroundDarker,
collapsedBackgroundColor: kDarkColorScheme.background),
bottomNavigationBarTheme: const BottomNavigationBarThemeData().copyWith(
selectedItemColor: kDarkColorScheme.primary,
unselectedItemColor: kDarkColorScheme.secondary,
),
),
themeMode: ThemeMode.system,
home: SplashScreen(initDone: initDone, registered: registered),
Expand Down
40 changes: 40 additions & 0 deletions app/lib/widgets/layout_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,37 @@ class LayoutDrawer extends StatefulWidget {

class _LayoutDrawerState extends State<LayoutDrawer> {
Globals globals = Globals();
int currentScreenIndex = 0;

void _selectScreen(index) {
setState(() {
currentScreenIndex = index;
if (index == 0) {
globals.tabController.animateTo(0);
} else if (index == 1) {
globals.tabController.animateTo(2);
} else if (index == 2) {
globals.tabController.animateTo(3);
} else if (index == 3) {
globals.tabController.animateTo(6);
} else {
return;
}
});
}

@override
Widget build(BuildContext context) {
if (widget.titleText == 'Home') {
currentScreenIndex = 0;
} else if (widget.titleText == 'Wallet') {
currentScreenIndex = 1;
} else if (widget.titleText == 'Farming') {
currentScreenIndex = 2;
} else if (widget.titleText == 'Settings') {
currentScreenIndex = 3;
}

return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
Expand Down Expand Up @@ -133,6 +161,18 @@ class _LayoutDrawerState extends State<LayoutDrawer> {
],
),
),
bottomNavigationBar: BottomNavigationBar(
onTap: _selectScreen,
currentIndex: currentScreenIndex,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(
icon: Icon(Icons.account_balance_wallet), label: 'Wallet'),
BottomNavigationBarItem(icon: Icon(Icons.storage), label: 'Farms'),
BottomNavigationBarItem(
icon: Icon(Icons.settings), label: 'Settings'),
],
),
);
}
}

0 comments on commit dfe4f9a

Please sign in to comment.