mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 13:37:29 +01:00
Several changes
This commit is contained in:
parent
2ca9988018
commit
83f4eb2f5c
@ -38,7 +38,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "com.example.jisho_study_tool"
|
||||
applicationId "app.jishostudytool.jisho_study_tool"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
|
30
lib/components/common/square.dart
Normal file
30
lib/components/common/square.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// This is somewhat of a hack.
|
||||
/// Wrapping the AspectRatio inside an UnconstrainedBox and IntrinsicHeight will
|
||||
/// result in the AspectRatio having an unbounded width and intrinsic height.
|
||||
/// That makes the AspectRatio size the widget with respect to the height
|
||||
/// (essentially stretch the width out to match the height)
|
||||
class Square extends StatelessWidget {
|
||||
final Widget child;
|
||||
final void Function()? onTap;
|
||||
|
||||
const Square({
|
||||
Key? key,
|
||||
required this.child,
|
||||
this.onTap,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => InkWell(
|
||||
onTap: onTap,
|
||||
child: UnconstrainedBox(
|
||||
child: IntrinsicHeight(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
@ -39,11 +39,9 @@ class KanjiResultBody extends StatelessWidget {
|
||||
),
|
||||
Flexible(
|
||||
fit: FlexFit.tight,
|
||||
child: Center(
|
||||
child: (resultData.radical != null)
|
||||
? Radical(radical: resultData.radical!)
|
||||
: const SizedBox(),
|
||||
),
|
||||
child: (resultData.radical != null)
|
||||
? Center(child: Radical(radical: resultData.radical!))
|
||||
: const SizedBox(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -19,15 +19,16 @@ 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: Text(
|
||||
kanji,
|
||||
style: TextStyle(fontSize: 70.0, color: colors.foreground)
|
||||
.merge(japaneseFont.textStyle),
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
kanji,
|
||||
style: TextStyle(color: colors.foreground)
|
||||
.merge(japaneseFont.textStyle),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -19,21 +19,37 @@ class Radical extends StatelessWidget {
|
||||
final colors = state.theme.kanjiResultColor;
|
||||
|
||||
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,
|
||||
).merge(japaneseFont.textStyle),
|
||||
),
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.kanjiSearchRadicals,
|
||||
arguments: radical.symbol,
|
||||
),
|
||||
child:
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(child: SizedBox()),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: colors.background,
|
||||
),
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
radical.symbol,
|
||||
style: TextStyle(color: colors.foreground)
|
||||
.merge(japaneseFont.textStyle),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Expanded(child: SizedBox()),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../bloc/theme/theme_bloc.dart';
|
||||
import '../../../../routing/routes.dart';
|
||||
import '../../../../settings.dart';
|
||||
import '../../../common/square.dart';
|
||||
|
||||
class KanjiRow extends StatelessWidget {
|
||||
final List<String> kanji;
|
||||
@ -13,33 +14,33 @@ class KanjiRow extends StatelessWidget {
|
||||
this.fontSize = 20,
|
||||
}) : super(key: key);
|
||||
|
||||
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,
|
||||
).merge(japaneseFont.textStyle),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Widget _kanjiBox(BuildContext context, String kanji) => Square(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.kanjiSearch,
|
||||
arguments: kanji,
|
||||
),
|
||||
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,
|
||||
).merge(japaneseFont.textStyle),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -57,15 +58,7 @@ class KanjiRow extends StatelessWidget {
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
for (final k in kanji)
|
||||
InkWell(
|
||||
onTap: () => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.kanjiSearch,
|
||||
arguments: k,
|
||||
),
|
||||
child: _kanjiBox(k),
|
||||
)
|
||||
for (final k in kanji) _kanjiBox(context, k),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@ -76,6 +76,10 @@ class KanjiKanaBox extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
color: Colors.transparent,
|
||||
fontSize: fFontsize,
|
||||
).merge(
|
||||
romajiEnabled && autoTransliterateRomaji
|
||||
? null
|
||||
: japaneseFont.textStyle,
|
||||
),
|
||||
),
|
||||
|
||||
|
@ -456,7 +456,7 @@ const Map<int, Map<int, List<String>>> grades = {
|
||||
'矛', '丙', '払', '氾', '尼',
|
||||
'丼', '凸', '奴', '旦', '占',
|
||||
'仙', '斥', '尻', '召', '汁',
|
||||
'囚', '𠮟', '込', '甲', '巧',
|
||||
'囚', '叱', '込', '甲', '巧',
|
||||
'玄', '巨', '丘', '甘', '且',
|
||||
'瓦', '牙', '凹'
|
||||
],
|
||||
|
@ -73,6 +73,7 @@ class AboutView extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: IconButton(
|
||||
color: Colors.white,
|
||||
iconSize: 50,
|
||||
onPressed: () => open_webpage(
|
||||
'https://github.com/h7x4ABk3g/Jisho-Study-Tool',
|
||||
|
@ -27,7 +27,18 @@ class _ResultPageState extends State<ResultPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
appBar: AppBar(
|
||||
leadingWidth: 100,
|
||||
leading: Row(
|
||||
children: [
|
||||
const BackButton(),
|
||||
CloseButton(
|
||||
onPressed: () =>
|
||||
Navigator.popUntil(context, (route) => route.isFirst),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: widget.isKanji
|
||||
? fetchKanji(widget.searchTerm)
|
||||
|
@ -15,7 +15,7 @@ class KanjiDrawingSearch extends StatelessWidget {
|
||||
Expanded(child: Column()),
|
||||
DrawingBoard(
|
||||
onlyOneCharacterSuggestions: true,
|
||||
onSuggestionChosen: (suggestion) => Navigator.popAndPushNamed(
|
||||
onSuggestionChosen: (suggestion) => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.kanjiSearch,
|
||||
arguments: suggestion,
|
||||
|
@ -5,6 +5,7 @@ import '../../../../data/grades.dart';
|
||||
import '../../../../models/themes/theme.dart';
|
||||
import '../../../../routing/routes.dart';
|
||||
import '../../../components/common/loading.dart';
|
||||
import '../../../components/common/square.dart';
|
||||
import '../../../settings.dart';
|
||||
|
||||
class KanjiGradeSearch extends StatefulWidget {
|
||||
@ -30,26 +31,28 @@ class _GridItem extends StatelessWidget {
|
||||
? () => ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(text)),
|
||||
)
|
||||
: () => Navigator.popAndPushNamed(
|
||||
: () => Navigator.pushNamed(
|
||||
context,
|
||||
Routes.kanjiSearch,
|
||||
arguments: text,
|
||||
);
|
||||
|
||||
return InkWell(
|
||||
return Square(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||
color: color.background,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
color: color.foreground,
|
||||
fontSize: 25,
|
||||
).merge(japaneseFont.textStyle),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headline5
|
||||
?.merge(TextStyle(color: color.foreground))
|
||||
.merge(japaneseFont.textStyle),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -78,29 +81,27 @@ class _KanjiGradeSearchState extends State<KanjiGradeSearch> {
|
||||
|
||||
Future<Widget> get makeGrids async => SingleChildScrollView(
|
||||
child: Column(
|
||||
children: (await Future.wait(
|
||||
children: await Future.wait(
|
||||
grades.keys.map(
|
||||
(grade) async => ExpansionTile(
|
||||
title: Text(grade == 7 ? 'Junior Highschool' : 'Grade $grade'),
|
||||
maintainState: true,
|
||||
children: [
|
||||
GridView.count(
|
||||
crossAxisCount: 6,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 10,
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
children: (await gradeWidgets)[grade]!
|
||||
.values
|
||||
.expand((l) => l)
|
||||
.toList(),
|
||||
)
|
||||
child: Wrap(
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: (await gradeWidgets)[grade]!
|
||||
.values
|
||||
.expand((l) => l)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user