mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-22 13:57:29 +01:00
Add kanji list
This commit is contained in:
parent
6534378606
commit
679033e52c
51
lib/components/search/search_results_body/parts/kanji.dart
Normal file
51
lib/components/search/search_results_body/parts/kanji.dart
Normal file
@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../bloc/theme/theme_bloc.dart';
|
||||
import '../../../../routing/routes.dart';
|
||||
|
||||
class KanjiRow extends StatelessWidget {
|
||||
final List<String> kanji;
|
||||
const KanjiRow({
|
||||
Key? key,
|
||||
required this.kanji,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Kanji',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: kanji
|
||||
.map(
|
||||
(k) => InkWell(
|
||||
onTap: () => Navigator.pushNamed(context, Routes.kanjiSearch, arguments: k),
|
||||
child: BlocBuilder<ThemeBloc, ThemeState>(
|
||||
builder: (context, state) {
|
||||
final colors = state.theme.menuGreyLight;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.background,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child:
|
||||
Text(k, style: TextStyle(color: colors.foreground, fontSize: 25)),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import './parts/senses.dart';
|
||||
import './parts/wanikani_badge.dart';
|
||||
import '../../../settings.dart';
|
||||
import 'parts/audio_player.dart';
|
||||
import 'parts/kanji.dart';
|
||||
import 'parts/links.dart';
|
||||
import 'parts/notes.dart';
|
||||
|
||||
@ -54,6 +55,13 @@ class _SearchResultCardState extends State<SearchResultCard> {
|
||||
return jlpt.last;
|
||||
}
|
||||
|
||||
List<String> get kanji =>
|
||||
RegExp(r'(\p{Script=Hani})', unicode: true)
|
||||
.allMatches(widget.result.japanese.map((w) => '${w.word ?? ""}${w.reading ?? ""}').join())
|
||||
.map((match) => match.group(0)!)
|
||||
.toSet()
|
||||
.toList();
|
||||
|
||||
Widget get _header => IntrinsicWidth(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@ -98,6 +106,10 @@ class _SearchResultCardState extends State<SearchResultCard> {
|
||||
const SizedBox(height: 20),
|
||||
Notes(notes: extendedData.notes),
|
||||
],
|
||||
if (kanji.isNotEmpty) ...[
|
||||
const SizedBox(height: 20),
|
||||
KanjiRow(kanji: kanji),
|
||||
],
|
||||
if (links.isNotEmpty || hasAttribution) ...[
|
||||
const SizedBox(height: 20),
|
||||
Links(
|
||||
|
Loading…
Reference in New Issue
Block a user