56 lines
1.5 KiB
Dart
56 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:tangocard_reader/service/tangocard_files.dart';
|
|
import 'package:tangocard_reader/service/theme_bloc.dart';
|
|
|
|
import 'pages/tango_set_list.dart';
|
|
|
|
class Home extends StatefulWidget {
|
|
const Home({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<Home> createState() => _HomeState();
|
|
}
|
|
|
|
class _HomeState extends State<Home> {
|
|
int page = 0;
|
|
|
|
final _pages = [
|
|
TangoSetList(
|
|
files: tangocardFilePaths,
|
|
route: '/list/tango',
|
|
),
|
|
TangoSetList(
|
|
files: kanjicardFilePaths,
|
|
route: '/list/kanji',
|
|
),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text("よく単語"),
|
|
actions: [
|
|
BlocBuilder<ThemeBloc, Brightness>(
|
|
builder: (context, state) {
|
|
return Switch(
|
|
value: state == Brightness.dark,
|
|
onChanged: (b) => BlocProvider.of<ThemeBloc>(context)
|
|
.add(SetTheme(state != Brightness.dark)),
|
|
);
|
|
},
|
|
)
|
|
],
|
|
centerTitle: true,
|
|
),
|
|
body: _pages[page],
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
onTap: (int index) => setState(() => page = index),
|
|
currentIndex: page,
|
|
items: const [
|
|
BottomNavigationBarItem(label: '単語', icon: Icon(Icons.style)),
|
|
BottomNavigationBarItem(label: '漢字', icon: Icon(Icons.translate)),
|
|
],
|
|
),
|
|
);
|
|
}
|