mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-22 05:57:28 +01:00
Several changes
This commit is contained in:
parent
2ca9988018
commit
83f4eb2f5c
@ -38,7 +38,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// 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
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode flutterVersionCode.toInteger()
|
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,12 +39,10 @@ class KanjiResultBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
fit: FlexFit.tight,
|
fit: FlexFit.tight,
|
||||||
child: Center(
|
|
||||||
child: (resultData.radical != null)
|
child: (resultData.radical != null)
|
||||||
? Radical(radical: resultData.radical!)
|
? Center(child: Radical(radical: resultData.radical!))
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -19,16 +19,17 @@ class Header extends StatelessWidget {
|
|||||||
final colors = state.theme.kanjiResultColor;
|
final colors = state.theme.kanjiResultColor;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
color: colors.background,
|
color: colors.background,
|
||||||
),
|
),
|
||||||
|
child: FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
kanji,
|
kanji,
|
||||||
style: TextStyle(fontSize: 70.0, color: colors.foreground)
|
style: TextStyle(color: colors.foreground)
|
||||||
.merge(japaneseFont.textStyle),
|
.merge(japaneseFont.textStyle),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -19,19 +19,35 @@ class Radical extends StatelessWidget {
|
|||||||
final colors = state.theme.kanjiResultColor;
|
final colors = state.theme.kanjiResultColor;
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => Navigator.pushNamed(context, Routes.kanjiSearchRadicals, arguments: radical.symbol),
|
onTap: () => Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
Routes.kanjiSearchRadicals,
|
||||||
|
arguments: radical.symbol,
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Expanded(child: SizedBox()),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(15.0),
|
padding: const EdgeInsets.all(20.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: colors.background,
|
color: colors.background,
|
||||||
),
|
),
|
||||||
|
child: FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
radical.symbol,
|
radical.symbol,
|
||||||
style: TextStyle(
|
style: TextStyle(color: colors.foreground)
|
||||||
color: colors.foreground,
|
.merge(japaneseFont.textStyle),
|
||||||
fontSize: 40.0,
|
),
|
||||||
).merge(japaneseFont.textStyle),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Expanded(child: SizedBox()),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../../../bloc/theme/theme_bloc.dart';
|
import '../../../../bloc/theme/theme_bloc.dart';
|
||||||
import '../../../../routing/routes.dart';
|
import '../../../../routing/routes.dart';
|
||||||
import '../../../../settings.dart';
|
import '../../../../settings.dart';
|
||||||
|
import '../../../common/square.dart';
|
||||||
|
|
||||||
class KanjiRow extends StatelessWidget {
|
class KanjiRow extends StatelessWidget {
|
||||||
final List<String> kanji;
|
final List<String> kanji;
|
||||||
@ -13,10 +14,12 @@ class KanjiRow extends StatelessWidget {
|
|||||||
this.fontSize = 20,
|
this.fontSize = 20,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
Widget _kanjiBox(String kanji) => UnconstrainedBox(
|
Widget _kanjiBox(BuildContext context, String kanji) => Square(
|
||||||
child: IntrinsicHeight(
|
onTap: () => Navigator.pushNamed(
|
||||||
child: AspectRatio(
|
context,
|
||||||
aspectRatio: 1,
|
Routes.kanjiSearch,
|
||||||
|
arguments: kanji,
|
||||||
|
),
|
||||||
child: BlocBuilder<ThemeBloc, ThemeState>(
|
child: BlocBuilder<ThemeBloc, ThemeState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final colors = state.theme.menuGreyLight;
|
final colors = state.theme.menuGreyLight;
|
||||||
@ -39,8 +42,6 @@ class KanjiRow extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -57,15 +58,7 @@ class KanjiRow extends StatelessWidget {
|
|||||||
spacing: 10,
|
spacing: 10,
|
||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
children: [
|
children: [
|
||||||
for (final k in kanji)
|
for (final k in kanji) _kanjiBox(context, k),
|
||||||
InkWell(
|
|
||||||
onTap: () => Navigator.pushNamed(
|
|
||||||
context,
|
|
||||||
Routes.kanjiSearch,
|
|
||||||
arguments: k,
|
|
||||||
),
|
|
||||||
child: _kanjiBox(k),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -76,6 +76,10 @@ class KanjiKanaBox extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
fontSize: fFontsize,
|
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),
|
borderRadius: BorderRadius.circular(15),
|
||||||
),
|
),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
color: Colors.white,
|
||||||
iconSize: 50,
|
iconSize: 50,
|
||||||
onPressed: () => open_webpage(
|
onPressed: () => open_webpage(
|
||||||
'https://github.com/h7x4ABk3g/Jisho-Study-Tool',
|
'https://github.com/h7x4ABk3g/Jisho-Study-Tool',
|
||||||
|
@ -27,7 +27,18 @@ class _ResultPageState extends State<ResultPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(
|
||||||
|
leadingWidth: 100,
|
||||||
|
leading: Row(
|
||||||
|
children: [
|
||||||
|
const BackButton(),
|
||||||
|
CloseButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.popUntil(context, (route) => route.isFirst),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
body: FutureBuilder(
|
body: FutureBuilder(
|
||||||
future: widget.isKanji
|
future: widget.isKanji
|
||||||
? fetchKanji(widget.searchTerm)
|
? fetchKanji(widget.searchTerm)
|
||||||
|
@ -15,7 +15,7 @@ class KanjiDrawingSearch extends StatelessWidget {
|
|||||||
Expanded(child: Column()),
|
Expanded(child: Column()),
|
||||||
DrawingBoard(
|
DrawingBoard(
|
||||||
onlyOneCharacterSuggestions: true,
|
onlyOneCharacterSuggestions: true,
|
||||||
onSuggestionChosen: (suggestion) => Navigator.popAndPushNamed(
|
onSuggestionChosen: (suggestion) => Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
Routes.kanjiSearch,
|
Routes.kanjiSearch,
|
||||||
arguments: suggestion,
|
arguments: suggestion,
|
||||||
|
@ -5,6 +5,7 @@ import '../../../../data/grades.dart';
|
|||||||
import '../../../../models/themes/theme.dart';
|
import '../../../../models/themes/theme.dart';
|
||||||
import '../../../../routing/routes.dart';
|
import '../../../../routing/routes.dart';
|
||||||
import '../../../components/common/loading.dart';
|
import '../../../components/common/loading.dart';
|
||||||
|
import '../../../components/common/square.dart';
|
||||||
import '../../../settings.dart';
|
import '../../../settings.dart';
|
||||||
|
|
||||||
class KanjiGradeSearch extends StatefulWidget {
|
class KanjiGradeSearch extends StatefulWidget {
|
||||||
@ -30,26 +31,28 @@ class _GridItem extends StatelessWidget {
|
|||||||
? () => ScaffoldMessenger.of(context).showSnackBar(
|
? () => ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(text)),
|
SnackBar(content: Text(text)),
|
||||||
)
|
)
|
||||||
: () => Navigator.popAndPushNamed(
|
: () => Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
Routes.kanjiSearch,
|
Routes.kanjiSearch,
|
||||||
arguments: text,
|
arguments: text,
|
||||||
);
|
);
|
||||||
|
|
||||||
return InkWell(
|
return Square(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
alignment: Alignment.center,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||||
color: color.background,
|
color: color.background,
|
||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
style: TextStyle(
|
style: Theme.of(context)
|
||||||
color: color.foreground,
|
.textTheme
|
||||||
fontSize: 25,
|
.headline5
|
||||||
).merge(japaneseFont.textStyle),
|
?.merge(TextStyle(color: color.foreground))
|
||||||
|
.merge(japaneseFont.textStyle),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -78,29 +81,27 @@ class _KanjiGradeSearchState extends State<KanjiGradeSearch> {
|
|||||||
|
|
||||||
Future<Widget> get makeGrids async => SingleChildScrollView(
|
Future<Widget> get makeGrids async => SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: (await Future.wait(
|
children: await Future.wait(
|
||||||
grades.keys.map(
|
grades.keys.map(
|
||||||
(grade) async => ExpansionTile(
|
(grade) async => ExpansionTile(
|
||||||
title: Text(grade == 7 ? 'Junior Highschool' : 'Grade $grade'),
|
title: Text(grade == 7 ? 'Junior Highschool' : 'Grade $grade'),
|
||||||
maintainState: true,
|
maintainState: true,
|
||||||
children: [
|
children: [
|
||||||
GridView.count(
|
Padding(
|
||||||
crossAxisCount: 6,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
shrinkWrap: true,
|
|
||||||
mainAxisSpacing: 10,
|
|
||||||
crossAxisSpacing: 10,
|
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Wrap(
|
||||||
|
runSpacing: 10,
|
||||||
|
spacing: 10,
|
||||||
children: (await gradeWidgets)[grade]!
|
children: (await gradeWidgets)[grade]!
|
||||||
.values
|
.values
|
||||||
.expand((l) => l)
|
.expand((l) => l)
|
||||||
.toList(),
|
.toList(),
|
||||||
)
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
))
|
),
|
||||||
.toList(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user