1
0
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:
Oystein Kristoffer Tveit 2022-01-27 00:18:11 +01:00
parent 2ca9988018
commit 83f4eb2f5c
12 changed files with 140 additions and 85 deletions

View File

@ -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()

View 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,
),
),
),
);
}

View File

@ -39,11 +39,9 @@ class KanjiResultBody extends StatelessWidget {
), ),
Flexible( Flexible(
fit: FlexFit.tight, fit: FlexFit.tight,
child: Center( child: (resultData.radical != null)
child: (resultData.radical != null) ? Center(child: Radical(radical: resultData.radical!))
? Radical(radical: resultData.radical!) : const SizedBox(),
: const SizedBox(),
),
), ),
], ],
), ),

View File

@ -19,15 +19,16 @@ 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: Text( child: FittedBox(
kanji, child: Text(
style: TextStyle(fontSize: 70.0, color: colors.foreground) kanji,
.merge(japaneseFont.textStyle), style: TextStyle(color: colors.foreground)
.merge(japaneseFont.textStyle),
),
), ),
); );
}, },

View File

@ -19,21 +19,37 @@ 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(
child: Container( context,
padding: const EdgeInsets.all(15.0), Routes.kanjiSearchRadicals,
decoration: BoxDecoration( arguments: radical.symbol,
shape: BoxShape.circle,
color: colors.background,
),
child: Text(
radical.symbol,
style: TextStyle(
color: colors.foreground,
fontSize: 40.0,
).merge(japaneseFont.textStyle),
),
), ),
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()),
],
),
),
); );
}, },
); );

View File

@ -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,33 +14,33 @@ 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,
child: BlocBuilder<ThemeBloc, ThemeState>( arguments: kanji,
builder: (context, state) { ),
final colors = state.theme.menuGreyLight; child: BlocBuilder<ThemeBloc, ThemeState>(
return Container( builder: (context, state) {
padding: const EdgeInsets.all(10), final colors = state.theme.menuGreyLight;
alignment: Alignment.center, return Container(
decoration: BoxDecoration( padding: const EdgeInsets.all(10),
color: colors.background, alignment: Alignment.center,
borderRadius: BorderRadius.circular(10), decoration: BoxDecoration(
), color: colors.background,
child: FittedBox( borderRadius: BorderRadius.circular(10),
child: Text( ),
kanji, child: FittedBox(
style: TextStyle( child: Text(
color: colors.foreground, kanji,
fontSize: fontSize, style: TextStyle(
).merge(japaneseFont.textStyle), color: colors.foreground,
), fontSize: fontSize,
), ).merge(japaneseFont.textStyle),
); ),
}, ),
), );
), },
), ),
); );
@ -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),
)
], ],
), ),
], ],

View File

@ -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,
), ),
), ),

View File

@ -456,7 +456,7 @@ const Map<int, Map<int, List<String>>> grades = {
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '𠮟', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '' '', '', ''
], ],

View File

@ -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',

View File

@ -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)

View File

@ -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,

View File

@ -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),
children: (await gradeWidgets)[grade]! child: Wrap(
.values runSpacing: 10,
.expand((l) => l) spacing: 10,
.toList(), children: (await gradeWidgets)[grade]!
) .values
.expand((l) => l)
.toList(),
),
),
], ],
), ),
), ),
)) ),
.toList(),
), ),
); );