110 lines
2.2 KiB
Dart
110 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:jisho_study_tool/screens/kanji_search.dart';
|
|
import 'package:jisho_study_tool/screens/log.dart';
|
|
import 'package:jisho_study_tool/screens/search.dart';
|
|
|
|
void main() => runApp(MyApp());
|
|
|
|
class MyApp extends StatelessWidget {
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Jisho Study Tool',
|
|
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(
|
|
title: Text(pages[_selectedPage].title),
|
|
centerTitle: true,
|
|
),
|
|
body: pages[_selectedPage].content,
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
currentIndex: _selectedPage,
|
|
onTap: (int index) {
|
|
setState(() {
|
|
_selectedPage = index;
|
|
});
|
|
},
|
|
items: navBar,
|
|
showSelectedLabels: false,
|
|
showUnselectedLabels: false,
|
|
unselectedItemColor: Colors.blue,
|
|
selectedItemColor: Colors.green,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
List<BottomNavigationBarItem> navBar = [
|
|
BottomNavigationBarItem(
|
|
title: Text('Search'),
|
|
icon: Icon(Icons.search),
|
|
),
|
|
BottomNavigationBarItem(
|
|
title: Text('Kanji'),
|
|
icon: Text(
|
|
'漢',
|
|
style: TextStyle(fontSize: 18),
|
|
),
|
|
),
|
|
BottomNavigationBarItem(
|
|
title: Text('Log'),
|
|
icon: Icon(Icons.bookmark),
|
|
),
|
|
BottomNavigationBarItem(
|
|
title: Text('Memorize'),
|
|
icon: Icon(Icons.local_offer),
|
|
),
|
|
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: SearchView(),
|
|
),
|
|
Page(
|
|
title: "Kanji",
|
|
content: KanjiView(),
|
|
),
|
|
Page(
|
|
title: "Log",
|
|
content: LogView(),
|
|
),
|
|
Page(
|
|
title: "Memorization",
|
|
content: Container(),
|
|
),
|
|
Page(
|
|
title: "Settings",
|
|
content: Container(),
|
|
),
|
|
];
|