Jisho-Study-Tool/lib/components/kanji/kanji_search_body/kanji_grid.dart

65 lines
1.7 KiB
Dart
Raw Normal View History

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';
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);
@override
Widget build(BuildContext context) {
return Container(
2021-12-01 23:09:53 +01:00
padding: const EdgeInsets.symmetric(
vertical: 20.0,
horizontal: 40.0,
),
child: GridView.count(
2021-07-19 01:47:12 +02:00
shrinkWrap: true,
crossAxisCount: 3,
2021-07-17 12:19:03 +02:00
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
children: suggestions.map((kanji) => _GridItem(kanji)).toList(),
),
);
}
}
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);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
2022-01-19 02:10:05 +01:00
Navigator.pushNamed(context, Routes.kanjiSearch, arguments: kanji);
},
2021-08-08 23:16:54 +02:00
child: BlocBuilder<ThemeBloc, ThemeState>(
builder: (context, state) {
final _menuColors = state.theme.menuGreyLight;
return Container(
decoration: BoxDecoration(
color: _menuColors.background,
borderRadius: BorderRadius.circular(20.0),
),
child: Container(
2021-12-01 23:09:53 +01:00
margin: const EdgeInsets.all(10.0),
child: FittedBox(
child: Text(
kanji,
2022-01-23 23:56:26 +01:00
style: japaneseFont.textStyle.merge(
TextStyle(color: _menuColors.foreground),
),
),
),
),
);
2021-08-08 23:16:54 +02:00
},
),
);
}
}