Skip to content

Instantly share code, notes, and snippets.

@hitherejoe
Last active December 16, 2018 18:43
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 hitherejoe/a75af5888499a7d074b2402f2bc29c75 to your computer and use it in GitHub Desktop.
Save hitherejoe/a75af5888499a7d074b2402f2bc29c75 to your computer and use it in GitHub Desktop.
class PlatformParent extends PlatformWidget<CupertinoTabScaffold, Scaffold> {
...
PlatformParent({...});
@override
Scaffold createAndroidWidget(BuildContext context) {
return Scaffold(
...,
appBar: buildTabBar(this.showTabs, context),
body: TabBarView(
children: this.children,
),
bottomNavigationBar: BottomNavigationBar(
...,
items: _buildNavigationItems(),
));
}
Widget buildTabBar(bool showTabs, BuildContext context) {
return AppBar(
bottom: showTabs
? TabBar(
indicatorColor: VoiceTheme.blaze_orange,
tabs: _buildTabs(),
)
: null,
);
}
@override
CupertinoTabScaffold createIosWidget(BuildContext context) {
final Map<int, Widget> children = <int, Widget>{
0: Text(countries[0].label),
1: Text(countries[1].label),
2: Text(countries[2].label),
};
return CupertinoTabScaffold(
tabBar: CupertinoTabBar(
...,
items: _buildNavigationItems(),
),
tabBuilder: (BuildContext context, int index) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: showTabs
? SizedBox(
width: 500.0,
child: CupertinoSegmentedControl(
...
children: children,
))
: Container(),
),
child: Scaffold(
body: this.children[0],
),
);
},
);
}
List<Widget> _buildTabs() {
return <Widget>[
PlatformTabs(label: countries[0].label),
PlatformTabs(label: countries[1].label),
PlatformTabs(label: countries[2].label),
];
}
List<BottomNavigationBarItem> _buildNavigationItems() {
return <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
FontAwesomeIcons.handHoldingHeart,
size: 26,
),
title: Text(categories[0].label),
),
...,
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment