2020-07-21 23:29:02 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-07-17 12:19:03 +02:00
|
|
|
|
2022-01-19 02:10:05 +01:00
|
|
|
import '../../../bloc/theme/theme_bloc.dart';
|
|
|
|
import '../../../routing/routes.dart';
|
2022-01-23 23:56:26 +01:00
|
|
|
import '../../../settings.dart';
|
2020-07-21 23:29:02 +02:00
|
|
|
|
2021-07-17 12:19:03 +02:00
|
|
|
class KanjiGrid extends StatelessWidget {
|
2021-03-03 00:24:25 +01:00
|
|
|
final List<String> suggestions;
|
2021-12-01 23:09:53 +01:00
|
|
|
|
|
|
|
const KanjiGrid({required this.suggestions, Key? key}) : super(key: key);
|
2020-07-21 23:29:02 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
2021-12-01 23:09:53 +01:00
|
|
|
padding: const EdgeInsets.symmetric(
|
2020-07-21 23:29:02 +02:00
|
|
|
vertical: 20.0,
|
|
|
|
horizontal: 40.0,
|
|
|
|
),
|
|
|
|
child: GridView.count(
|
2021-07-19 01:47:12 +02:00
|
|
|
shrinkWrap: true,
|
2020-07-21 23:29:02 +02:00
|
|
|
crossAxisCount: 3,
|
2021-07-17 12:19:03 +02:00
|
|
|
mainAxisSpacing: 10.0,
|
|
|
|
crossAxisSpacing: 10.0,
|
|
|
|
children: suggestions.map((kanji) => _GridItem(kanji)).toList(),
|
2020-07-21 23:29:02 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-17 12:19:03 +02:00
|
|
|
class _GridItem extends StatelessWidget {
|
2021-03-03 00:24:25 +01:00
|
|
|
final String kanji;
|
2021-07-17 12:19:03 +02:00
|
|
|
const _GridItem(this.kanji);
|
2020-07-21 23:29:02 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
2022-01-19 02:10:05 +01:00
|
|
|
Navigator.pushNamed(context, Routes.kanjiSearch, arguments: kanji);
|
2020-07-21 23:29:02 +02:00
|
|
|
},
|
2021-08-08 23:16:54 +02:00
|
|
|
child: BlocBuilder<ThemeBloc, ThemeState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
final _menuColors = state.theme.menuGreyLight;
|
2021-09-07 00:05:33 +02:00
|
|
|
return Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: _menuColors.background,
|
|
|
|
borderRadius: BorderRadius.circular(20.0),
|
2020-07-21 23:29:02 +02:00
|
|
|
),
|
2021-09-07 00:05:33 +02:00
|
|
|
child: Container(
|
2021-12-01 23:09:53 +01:00
|
|
|
margin: const EdgeInsets.all(10.0),
|
2021-09-07 00:05:33 +02:00
|
|
|
child: FittedBox(
|
|
|
|
child: Text(
|
|
|
|
kanji,
|
2022-01-23 23:56:26 +01:00
|
|
|
style: japaneseFont.textStyle.merge(
|
|
|
|
TextStyle(color: _menuColors.foreground),
|
|
|
|
),
|
2021-09-07 00:05:33 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2021-08-08 23:16:54 +02:00
|
|
|
},
|
2020-07-21 23:29:02 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2021-09-07 00:05:33 +02:00
|
|
|
}
|