Skip to content

Instantly share code, notes, and snippets.

@birchb
Created April 18, 2021 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save birchb/331c26e7cd5d2b29a8abfb4c20c9e341 to your computer and use it in GitHub Desktop.
Save birchb/331c26e7cd5d2b29a8abfb4c20c9e341 to your computer and use it in GitHub Desktop.
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