mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 13:37:29 +01:00
Connect multiple kanji parts with search
This commit is contained in:
parent
3d30a81205
commit
289592cda5
@ -31,7 +31,7 @@ class KanjiResultBody extends StatelessWidget {
|
||||
children: [
|
||||
const Flexible(
|
||||
fit: FlexFit.tight,
|
||||
child: Center(child: SizedBox()),
|
||||
child: SizedBox(),
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:unofficial_jisho_api/api.dart';
|
||||
|
||||
import '../../../bloc/theme/theme_bloc.dart';
|
||||
import '../../../routing/routes.dart';
|
||||
import '../../../services/romaji_transliteration.dart';
|
||||
import '../../../settings.dart';
|
||||
|
||||
@ -73,7 +74,14 @@ class _Example extends StatelessWidget {
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
children: [
|
||||
_Kana(colors: kanaColors, example: yomiExample),
|
||||
InkWell(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.search,
|
||||
arguments: yomiExample.example,
|
||||
),
|
||||
child: _Kana(colors: kanaColors, example: yomiExample),
|
||||
),
|
||||
_ExampleText(colors: menuColors, example: yomiExample)
|
||||
],
|
||||
),
|
||||
|
@ -18,15 +18,14 @@ class Header extends StatelessWidget {
|
||||
final colors = state.theme.kanjiResultColor;
|
||||
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
color: colors.background,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
kanji,
|
||||
style: TextStyle(fontSize: 70.0, color: colors.foreground),
|
||||
),
|
||||
child: Text(
|
||||
kanji,
|
||||
style: TextStyle(fontSize: 70.0, color: colors.foreground),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||
|
||||
import '../../../bloc/theme/theme_bloc.dart';
|
||||
import '../../../routing/routes.dart';
|
||||
|
||||
class Radical extends StatelessWidget {
|
||||
final jisho.Radical radical;
|
||||
@ -16,17 +17,20 @@ class Radical extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
final colors = state.theme.kanjiResultColor;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: colors.background,
|
||||
),
|
||||
child: Text(
|
||||
radical.symbol,
|
||||
style: TextStyle(
|
||||
color: colors.foreground,
|
||||
fontSize: 40.0,
|
||||
return InkWell(
|
||||
onTap: () => Navigator.pushNamed(context, Routes.kanjiSearchRadicals, arguments: radical.symbol),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: colors.background,
|
||||
),
|
||||
child: Text(
|
||||
radical.symbol,
|
||||
style: TextStyle(
|
||||
color: colors.foreground,
|
||||
fontSize: 40.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../bloc/theme/theme_bloc.dart';
|
||||
import '../../../routing/routes.dart';
|
||||
import '../../../services/romaji_transliteration.dart';
|
||||
import '../../../settings.dart';
|
||||
|
||||
@ -50,24 +51,29 @@ class YomiChips extends StatelessWidget {
|
||||
bool get isExpandable => yomi.length > 6;
|
||||
|
||||
Widget yomiCard({
|
||||
required BuildContext context,
|
||||
required String yomi,
|
||||
required ColorSet colors,
|
||||
}) =>
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 5),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 10.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.background,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: Text(
|
||||
yomi,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
color: colors.foreground,
|
||||
InkWell(
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, Routes.search, arguments: yomi),
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 5),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 10.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.background,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: Text(
|
||||
yomi,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
color: colors.foreground,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -75,12 +81,19 @@ class YomiChips extends StatelessWidget {
|
||||
Widget yomiWrapper(BuildContext context) {
|
||||
final yomiCards = yomi
|
||||
.map((y) => romajiEnabled ? transliterateKanaToLatin(y) : y)
|
||||
.map((y) => yomiCard(yomi: y, colors: type.getColors(context)))
|
||||
.map(
|
||||
(y) => yomiCard(
|
||||
context: context,
|
||||
yomi: y,
|
||||
colors: type.getColors(context),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
final yomiCardsWithTitle = <Widget>[
|
||||
if (type != YomiType.meaning)
|
||||
yomiCard(
|
||||
context: context,
|
||||
yomi: type == YomiType.kunyomi ? 'Kun:' : 'On:',
|
||||
colors: ColorSet(
|
||||
foreground: type.getColors(context).background,
|
||||
@ -101,7 +114,11 @@ class YomiChips extends StatelessWidget {
|
||||
else
|
||||
return ExpansionTile(
|
||||
title: Center(
|
||||
child: yomiCard(yomi: type.title, colors: type.getColors(context)),
|
||||
child: yomiCard(
|
||||
context: context,
|
||||
yomi: type.title,
|
||||
colors: type.getColors(context),
|
||||
),
|
||||
),
|
||||
children: [
|
||||
const SizedBox(height: 20.0),
|
||||
|
@ -34,7 +34,8 @@ Route<Widget> generateRoute(RouteSettings settings) {
|
||||
return MaterialPageRoute(builder: (_) => const KanjiGradeSearch());
|
||||
|
||||
case Routes.kanjiSearchRadicals:
|
||||
return MaterialPageRoute(builder: (_) => const KanjiRadicalSearch());
|
||||
final prechosenRadical = args as String?;
|
||||
return MaterialPageRoute(builder: (_) => KanjiRadicalSearch(prechosenRadical: prechosenRadical));
|
||||
|
||||
// TODO: Add more specific error screens.
|
||||
case Routes.errorNotFound:
|
||||
|
@ -6,7 +6,9 @@ import '../../../../routing/routes.dart';
|
||||
import '../../../../services/jisho_api/radicals_search.dart';
|
||||
|
||||
class KanjiRadicalSearch extends StatefulWidget {
|
||||
const KanjiRadicalSearch({Key? key}) : super(key: key);
|
||||
final String? prechosenRadical;
|
||||
|
||||
const KanjiRadicalSearch({Key? key, this.prechosenRadical}) : super(key: key);
|
||||
|
||||
@override
|
||||
_KanjiRadicalSearchState createState() => _KanjiRadicalSearchState();
|
||||
@ -25,6 +27,15 @@ class _KanjiRadicalSearchState extends State<KanjiRadicalSearch> {
|
||||
for (final String r in radicals.values.expand((l) => l)) r: true
|
||||
};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.prechosenRadical != null &&
|
||||
radicalToggles.containsKey(widget.prechosenRadical))
|
||||
radicalToggles[widget.prechosenRadical!] = true;
|
||||
updateSuggestions();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void resetRadicalToggles() => radicalToggles.forEach((k, _) {
|
||||
radicalToggles[k] = false;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user