Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active August 15, 2019 23:13
Show Gist options
  • Select an option

  • Save VB10/d3c264c9d940730abbf55472a4abd3bf to your computer and use it in GitHub Desktop.

Select an option

Save VB10/d3c264c9d940730abbf55472a4abd3bf to your computer and use it in GitHub Desktop.
Healtho Tabbar
lass _HomeTabViewState extends State<HomeTabView> {
/// save current page state
int _currentPageIndex = 0;
AppBar get _appBar {
return AppBar(
/// [StatusBar] color light
brightness: Brightness.dark,
backgroundColor: UIHelper.SETTINGS_APP_BAR_COLOR,
leading: Image.asset(UIHelper.MENU_ICON),
title: Text(_appBarTitle),
centerTitle: false,
actions: <Widget>[_rigtActionItem],
);
}
/// get [AppBar] title
String get _appBarTitle {
switch (_currentPageIndex) {
case 0:
return Constants.NOTIFICATION_TITLE;
case 1:
return Constants.REMINDER_TITLE;
default:
return Constants.SETTINGS_TITLE;
}
}
/// get [SearchBar] icon
Widget get _rigtActionItem => Chip(
label: Icon(Icons.search),
backgroundColor: UIHelper.SETTINGS_APP_BAR_COLOR,
shape: Border(),
);
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: Constants.TABBAR_COUNT,
child: Scaffold(
appBar: _appBar,
bottomNavigationBar: BottomAppBar(
child: TabBar(
labelPadding: EdgeInsets.all(0),
indicatorColor: Colors.transparent,
labelColor: Colors.black,
onTap: (int index) {
/// [TabBar] item ontab reload view.
setState(() {
_currentPageIndex = index;
});
},
tabs: <Widget>[
_tabBarItem(icon: Icons.notifications),
_tabBarItem(icon: Icons.access_time),
_tabBarItem(icon: Icons.settings),
_tabProfileIcon(url: Constants.PROFILE_IMAGE)
],
),
),
body: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
NotifiactionView(),
ReminderView(),
SettingsView(),
Container(),
],
),
),
);
}
/// Default [Tab] item
Widget _tabBarItem({IconData icon}) {
return Tab(
icon: Icon(icon, color: Colors.grey),
);
}
Widget _tabProfileIcon({String url}) {
return Tab(
child: FlatButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onPressed: () {},
child: Center(
child: CircleAvatar(
backgroundImage: NetworkImage(url),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment