Skip to content

Instantly share code, notes, and snippets.

@AravinthVelusamy
Created April 18, 2021 17:45
Show Gist options
  • Select an option

  • Save AravinthVelusamy/21a7fab1b8935eb3724382b7805965b3 to your computer and use it in GitHub Desktop.

Select an option

Save AravinthVelusamy/21a7fab1b8935eb3724382b7805965b3 to your computer and use it in GitHub Desktop.
class LandingPage extends StatelessWidget {
final TextStyle unselectedLabelStyle = TextStyle(
color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.w500,
fontSize: 12);
final TextStyle selectedLabelStyle =
TextStyle(color: Colors.white, fontWeight: FontWeight.w500, fontSize: 12);
buildBottomNavigationMenu(context, landingPageController) {
return Obx(() => MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: SizedBox(
height: 54,
child: BottomNavigationBar(
showUnselectedLabels: true,
showSelectedLabels: true,
onTap: landingPageController.changeTabIndex,
currentIndex: landingPageController.tabIndex.value,
backgroundColor: Color.fromRGBO(36, 54, 101, 1.0),
unselectedItemColor: Colors.white.withOpacity(0.5),
selectedItemColor: Colors.white,
unselectedLabelStyle: unselectedLabelStyle,
selectedLabelStyle: selectedLabelStyle,
items: [
BottomNavigationBarItem(
icon: Container(
margin: EdgeInsets.only(bottom: 7),
child: Icon(
Icons.home,
size: 20.0,
),
),
label: 'Home',
backgroundColor: Color.fromRGBO(36, 54, 101, 1.0),
),
BottomNavigationBarItem(
icon: Container(
margin: EdgeInsets.only(bottom: 7),
child: Icon(
Icons.search,
size: 20.0,
),
),
label: 'Explore',
backgroundColor: Color.fromRGBO(36, 54, 101, 1.0),
),
BottomNavigationBarItem(
icon: Container(
margin: EdgeInsets.only(bottom: 7),
child: Icon(
Icons.location_history,
size: 20.0,
),
),
label: 'Places',
backgroundColor: Color.fromRGBO(36, 54, 101, 1.0),
),
BottomNavigationBarItem(
icon: Container(
margin: EdgeInsets.only(bottom: 7),
child: Icon(
Icons.settings,
size: 20.0,
),
),
label: 'Settings',
backgroundColor: Color.fromRGBO(36, 54, 101, 1.0),
),
],
),
)));
}
@override
Widget build(BuildContext context) {
final LandingPageController landingPageController =
Get.put(LandingPageController(), permanent: false);
return SafeArea(
child: Scaffold(
bottomNavigationBar:
buildBottomNavigationMenu(context, landingPageController),
body: Obx(() => IndexedStack(
index: landingPageController.tabIndex.value,
children: [
HomePage(),
ExplorePage(),
PlacesPage(),
SettingsPage(),
],
)),
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment