1
0
mirror of https://github.com/h7x4/Jisho-Study-Tool.git synced 2024-12-22 13:57:29 +01:00
Jisho-Study-Tool/lib/main.dart

118 lines
2.6 KiB
Dart
Raw Normal View History

2020-06-28 00:39:45 +02:00
import 'package:flutter/material.dart';
2020-07-14 14:33:21 +02:00
import 'package:flutter_bloc/flutter_bloc.dart';
2021-03-03 12:47:35 +01:00
import 'package:mdi/mdi.dart';
2020-07-14 14:33:21 +02:00
import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart';
2021-03-02 22:26:59 +01:00
import 'package:jisho_study_tool/view/screens/kanji_search.dart';
import 'package:jisho_study_tool/view/screens/history.dart';
import 'package:jisho_study_tool/view/screens/search.dart';
2020-06-28 00:39:45 +02:00
2020-07-14 14:33:21 +02:00
import 'bloc/search/search_bloc.dart';
2020-06-28 00:39:45 +02:00
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@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,
),
2020-07-14 14:33:21 +02:00
home: MultiBlocProvider(
providers: [
BlocProvider(create: (context) => SearchBloc()),
BlocProvider(create: (context) => KanjiBloc()),
],
child: Home(),
),
2020-06-28 00:39:45 +02:00
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
2021-03-03 00:24:25 +01:00
int selectedPage = 0;
2020-06-28 00:39:45 +02:00
@override
2020-07-09 20:59:00 +02:00
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2021-03-03 00:24:25 +01:00
title: pages[selectedPage].titleBar,
2020-07-09 20:59:00 +02:00
centerTitle: true,
),
2021-03-03 00:24:25 +01:00
body: pages[selectedPage].content,
2020-07-09 20:59:00 +02:00
bottomNavigationBar: BottomNavigationBar(
2021-03-03 00:24:25 +01:00
currentIndex: selectedPage,
2020-07-09 20:59:00 +02:00
onTap: (int index) {
setState(() {
2021-03-03 00:24:25 +01:00
selectedPage = index;
2020-07-09 20:59:00 +02:00
});
},
items: navBar,
showSelectedLabels: false,
showUnselectedLabels: false,
unselectedItemColor: Colors.blue,
selectedItemColor: Colors.green,
),
);
}
2020-06-30 22:51:32 +02:00
}
2020-07-13 23:39:16 +02:00
final List<BottomNavigationBarItem> navBar = [
2020-06-30 22:51:32 +02:00
BottomNavigationBarItem(
2021-03-03 00:24:25 +01:00
label: 'Search',
2020-07-09 20:59:00 +02:00
icon: Icon(Icons.search),
2020-06-30 22:51:32 +02:00
),
BottomNavigationBarItem(
2021-03-03 00:24:25 +01:00
label: 'Kanji',
2021-03-03 12:47:35 +01:00
icon: Icon(Mdi.ideogramCjk, size: 30,)
2020-07-09 20:59:00 +02:00
),
BottomNavigationBarItem(
2021-03-03 00:24:25 +01:00
label: 'History',
2020-07-09 20:59:00 +02:00
icon: Icon(Icons.bookmark),
2020-06-30 22:51:32 +02:00
),
BottomNavigationBarItem(
2021-03-03 00:24:25 +01:00
label: 'Memorize',
2020-07-09 20:59:00 +02:00
icon: Icon(Icons.local_offer),
2020-06-30 22:51:32 +02:00
),
BottomNavigationBarItem(
2021-03-03 00:24:25 +01:00
label: 'Settings',
2020-07-09 20:59:00 +02:00
icon: Icon(Icons.settings),
2020-06-30 22:51:32 +02:00
),
];
2021-03-03 00:24:25 +01:00
class _Page {
2020-06-30 22:51:32 +02:00
Widget content;
2020-07-14 12:52:48 +02:00
Widget titleBar;
2020-06-30 22:51:32 +02:00
2021-03-03 00:24:25 +01:00
_Page({
2020-07-14 14:33:21 +02:00
this.content,
this.titleBar,
});
2020-06-30 22:51:32 +02:00
}
2021-03-03 00:24:25 +01:00
final List<_Page> pages = [
_Page(content: SearchView(), titleBar: Text('Search')),
_Page(
2020-07-09 22:17:10 +02:00
content: KanjiView(),
2020-07-14 12:52:48 +02:00
titleBar: KanjiViewBar(),
2020-07-09 20:59:00 +02:00
),
2021-03-03 00:24:25 +01:00
_Page(
2020-07-13 23:41:31 +02:00
content: HistoryView(),
2020-07-14 12:52:48 +02:00
titleBar: Text("History"),
2020-06-30 22:51:32 +02:00
),
2021-03-03 00:24:25 +01:00
_Page(
2020-07-09 20:59:00 +02:00
content: Container(),
2020-07-14 12:52:48 +02:00
titleBar: Text("Memorization"),
2020-06-30 22:51:32 +02:00
),
2021-03-03 00:24:25 +01:00
_Page(
2020-07-09 20:59:00 +02:00
content: Container(),
2020-07-14 12:52:48 +02:00
titleBar: Text("Settings"),
2020-06-30 22:51:32 +02:00
),
2020-07-09 20:59:00 +02:00
];