Jisho-Study-Tool/lib/components/search/search_results_body/parts/kanji.dart

75 lines
2.0 KiB
Dart
Raw Normal View History

2022-01-23 04:13:00 +01:00
import 'package:flutter/material.dart';
import '../../../../bloc/theme/theme_bloc.dart';
import '../../../../routing/routes.dart';
class KanjiRow extends StatelessWidget {
final List<String> kanji;
2022-01-23 16:25:43 +01:00
final double fontSize;
2022-01-23 04:13:00 +01:00
const KanjiRow({
Key? key,
required this.kanji,
2022-01-23 16:25:43 +01:00
this.fontSize = 20,
2022-01-23 04:13:00 +01:00
}) : super(key: key);
2022-01-23 16:25:43 +01:00
Widget _kanjiBox(String kanji) => UnconstrainedBox(
child: IntrinsicHeight(
child: AspectRatio(
aspectRatio: 1,
child: BlocBuilder<ThemeBloc, ThemeState>(
builder: (context, state) {
final colors = state.theme.menuGreyLight;
return Container(
padding: const EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: colors.background,
borderRadius: BorderRadius.circular(10),
),
child: FittedBox(
child: Text(
kanji,
style: TextStyle(
color: colors.foreground,
fontSize: fontSize,
),
),
),
);
},
),
),
),
);
2022-01-23 04:13:00 +01:00
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
2022-01-23 16:25:43 +01:00
'Kanji:',
2022-01-23 04:13:00 +01:00
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(height: 5),
Wrap(
spacing: 10,
runSpacing: 10,
children: kanji
.map(
(k) => InkWell(
2022-01-23 16:25:43 +01:00
onTap: () => Navigator.pushNamed(
context,
Routes.kanjiSearch,
arguments: k,
2022-01-23 04:13:00 +01:00
),
2022-01-23 16:25:43 +01:00
child: _kanjiBox(k),
2022-01-23 04:13:00 +01:00
),
)
.toList(),
),
],
);
}
}