Created
March 16, 2019 18:03
Star
You must be signed in to star a gist
[flutter_todos] tab selector
This file contains 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/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:todos_app_core/todos_app_core.dart'; | |
import 'package:flutter_todos/models/models.dart'; | |
class TabSelector extends StatelessWidget { | |
final AppTab activeTab; | |
final Function(AppTab) onTabSelected; | |
TabSelector({ | |
Key key, | |
@required this.activeTab, | |
@required this.onTabSelected, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return BottomNavigationBar( | |
key: ArchSampleKeys.tabs, | |
currentIndex: AppTab.values.indexOf(activeTab), | |
onTap: (index) => onTabSelected(AppTab.values[index]), | |
items: AppTab.values.map((tab) { | |
return BottomNavigationBarItem( | |
icon: Icon( | |
tab == AppTab.todos ? Icons.list : Icons.show_chart, | |
key: tab == AppTab.todos | |
? ArchSampleKeys.todoTab | |
: ArchSampleKeys.statsTab, | |
), | |
title: Text(tab == AppTab.stats | |
? ArchSampleLocalizations.of(context).stats | |
: ArchSampleLocalizations.of(context).todos), | |
); | |
}).toList(), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment