Created
April 18, 2021 22:37
-
-
Save birchb/331c26e7cd5d2b29a8abfb4c20c9e341 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:time_tracker_flutter_course/app/home/tab_item.dart'; | |
class CupertinoHomeScaffold extends StatelessWidget { | |
// final TabItem currentTab; | |
// final ValueChanged<TabItem> onSelectTab; | |
final Map<TabItem, WidgetBuilder> widgetBuilders; | |
const CupertinoHomeScaffold({ | |
Key key, | |
// @required this.currentTab, | |
// @required this.onSelectTab, | |
@required this.widgetBuilders, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return CupertinoTabScaffold( | |
tabBar: CupertinoTabBar( | |
activeColor: Colors.indigo, | |
inactiveColor: Colors.grey, | |
items: [ | |
_buildItem(TabItem.jobs), | |
_buildItem(TabItem.entries), | |
_buildItem(TabItem.account), | |
], | |
// onTap: (index) => onSelectTab(TabItem.values[index]), | |
), | |
tabBuilder: (context, index) { | |
final item = TabItem.values[index]; | |
return CupertinoTabView( | |
builder: (context) => widgetBuilders[item](context), | |
); | |
}, | |
); | |
} | |
BottomNavigationBarItem _buildItem(TabItem tabItem) { | |
// final color = currentTab == tabItem ? Colors.indigo : Colors.grey; | |
final itemData = TabItemData.allTabs[tabItem]; | |
return BottomNavigationBarItem( | |
icon: Icon(itemData.icon), | |
label: itemData.label, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment