mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 21:47:29 +01:00
Export reused kanji regex into own file
This commit is contained in:
parent
8c7253fd93
commit
eaa5510942
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jisho_study_tool/services/kanji_regex.dart';
|
||||||
import 'package:unofficial_jisho_api/api.dart';
|
import 'package:unofficial_jisho_api/api.dart';
|
||||||
|
|
||||||
import '../../../../models/themes/theme.dart';
|
import '../../../../models/themes/theme.dart';
|
||||||
@ -34,8 +35,8 @@ class KanjiKanaBox extends StatelessWidget {
|
|||||||
|
|
||||||
bool get hasFurigana => word.reading != null;
|
bool get hasFurigana => word.reading != null;
|
||||||
|
|
||||||
String get kana => '${word.reading ?? ""}${word.word ?? ""}'
|
String get kana =>
|
||||||
.replaceAll(RegExp(r'\p{Script=Hani}', unicode: true), '');
|
'${word.reading ?? ""}${word.word ?? ""}'.replaceAll(kanjiRegex, '');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jisho_study_tool/services/kanji_regex.dart';
|
||||||
import 'package:unofficial_jisho_api/api.dart';
|
import 'package:unofficial_jisho_api/api.dart';
|
||||||
|
|
||||||
import './parts/common_badge.dart';
|
import './parts/common_badge.dart';
|
||||||
@ -55,7 +56,7 @@ class _SearchResultCardState extends State<SearchResultCard> {
|
|||||||
return jlpt.last;
|
return jlpt.last;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> get kanji => RegExp(r'(\p{Script=Hani})', unicode: true)
|
List<String> get kanji => kanjiRegex
|
||||||
.allMatches(
|
.allMatches(
|
||||||
widget.result.japanese
|
widget.result.japanese
|
||||||
.map((w) => '${w.word ?? ""}${w.reading ?? ""}')
|
.map((w) => '${w.word ?? ""}${w.reading ?? ""}')
|
||||||
|
1
lib/services/kanji_regex.dart
Normal file
1
lib/services/kanji_regex.dart
Normal file
@ -0,0 +1 @@
|
|||||||
|
final kanjiRegex = RegExp(r'\p{Script=Hani}', unicode: true);
|
Loading…
Reference in New Issue
Block a user