yokutango-mobile-reader/lib/screens/home.dart

56 lines
1.5 KiB
Dart
Raw Permalink Normal View History

2022-01-26 00:25:07 +01:00
import 'package:flutter/material.dart';
2024-04-26 01:14:49 +02:00
import 'package:yokutango_mobile_reader/service/tangocard_files.dart';
import 'package:yokutango_mobile_reader/service/theme_bloc.dart';
2022-01-26 01:58:47 +01:00
import 'pages/tango_set_list.dart';
2022-01-26 00:25:07 +01:00
2022-01-26 01:58:47 +01:00
class Home extends StatefulWidget {
2024-04-26 01:14:49 +02:00
const Home({super.key});
2022-01-26 00:25:07 +01:00
@override
2022-01-26 01:58:47 +01:00
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
int page = 0;
final _pages = [
2022-02-04 04:22:35 +01:00
TangoSetList(
files: tangocardFilePaths,
route: '/list/tango',
),
TangoSetList(
files: kanjicardFilePaths,
route: '/list/kanji',
),
2022-01-26 01:58:47 +01:00
];
@override
Widget build(BuildContext context) => Scaffold(
2022-01-26 00:25:07 +01:00
appBar: AppBar(
title: const Text("よく単語"),
2022-02-04 04:22:35 +01:00
actions: [
BlocBuilder<ThemeBloc, Brightness>(
builder: (context, state) {
return Switch(
value: state == Brightness.dark,
onChanged: (b) => BlocProvider.of<ThemeBloc>(context)
.add(SetTheme(state != Brightness.dark)),
);
},
)
],
2022-01-26 00:25:07 +01:00
centerTitle: true,
),
2022-01-26 01:58:47 +01:00
body: _pages[page],
bottomNavigationBar: BottomNavigationBar(
onTap: (int index) => setState(() => page = index),
currentIndex: page,
items: const [
2022-02-04 04:22:35 +01:00
BottomNavigationBarItem(label: '単語', icon: Icon(Icons.style)),
BottomNavigationBarItem(label: '漢字', icon: Icon(Icons.translate)),
2022-01-26 01:58:47 +01:00
],
2022-01-26 00:25:07 +01:00
),
);
}