Jisho-Study-Tool/lib/main.dart

106 lines
2.0 KiB
Dart
Raw Normal View History

2020-06-28 00:39:45 +02:00
import 'package:flutter/material.dart';
2020-06-30 22:51:32 +02:00
import 'package:jisho_study_tool/screens/kanji_search.dart';
2020-06-28 00:39:45 +02:00
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
2020-07-09 20:06:48 +02:00
title: 'Jisho Study Tool',
2020-06-28 00:39:45 +02:00
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Home(),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
int _selectedPage = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2020-06-30 22:51:32 +02:00
title: Text(pages[_selectedPage].title),
centerTitle: true,
2020-06-28 00:39:45 +02:00
),
2020-06-30 22:51:32 +02:00
body: pages[_selectedPage].content,
2020-06-28 00:39:45 +02:00
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedPage,
onTap: (int index) {
setState(() {
_selectedPage = index;
});
},
2020-06-30 22:51:32 +02:00
items: navBar,
2020-06-28 00:39:45 +02:00
showSelectedLabels: false,
showUnselectedLabels: false,
unselectedItemColor: Colors.blue,
selectedItemColor: Colors.green,
),
);
}
2020-06-30 22:51:32 +02:00
}
List<BottomNavigationBarItem> navBar = [
BottomNavigationBarItem(
title: Text('Search'),
icon: Icon(Icons.search)
),
BottomNavigationBarItem(
title: Text('Kanji'),
icon: Text(
'',
style: TextStyle(
fontSize: 18
),
)
),
BottomNavigationBarItem(
title: Text('Memorize'),
2020-07-09 18:14:17 +02:00
icon: Icon(Icons.local_offer)
2020-06-30 22:51:32 +02:00
),
BottomNavigationBarItem(
title: Text('Settings'),
icon: Icon(Icons.settings)
),
];
class Page {
String title;
Widget content;
Page({
this.title,
this.content
});
}
List<Page> pages = [
Page(
title: "Search",
content: Container()
),
Page(
title: "Kanji",
content: KanjiSearch()
),
Page(
title: "Memorization",
content: Container()
),
Page(
title: "Settings",
content: Container()
),
];