Make titlebar modular

This commit is contained in:
Oystein Kristoffer Tveit 2020-07-14 12:52:48 +02:00
parent d126f54500
commit 9204ce4cfd
2 changed files with 15 additions and 8 deletions

View File

@ -31,7 +31,7 @@ class _HomeState extends State<Home> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(pages[_selectedPage].title), title: pages[_selectedPage].titleBar,
centerTitle: true, centerTitle: true,
), ),
body: pages[_selectedPage].content, body: pages[_selectedPage].content,
@ -79,31 +79,31 @@ final List<BottomNavigationBarItem> navBar = [
]; ];
class Page { class Page {
String title;
Widget content; Widget content;
Widget titleBar;
Page({this.title, this.content}); Page({ this.content,this.titleBar,});
} }
final List<Page> pages = [ final List<Page> pages = [
Page( Page(
title: "Search",
content: SearchView(), content: SearchView(),
titleBar: Text('Search')
), ),
Page( Page(
title: "Kanji",
content: KanjiView(), content: KanjiView(),
titleBar: KanjiViewBar(),
), ),
Page( Page(
title: "History",
content: HistoryView(), content: HistoryView(),
titleBar: Text("History"),
), ),
Page( Page(
title: "Memorization",
content: Container(), content: Container(),
titleBar: Text("Memorization"),
), ),
Page( Page(
title: "Settings",
content: Container(), content: Container(),
titleBar: Text("Settings"),
), ),
]; ];

View File

@ -30,6 +30,13 @@ class _KanjiSearchPage extends StatelessWidget {
} }
} }
class KanjiViewBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text('Kanji');
}
}
class KanjiSearchBar extends StatelessWidget { class KanjiSearchBar extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {