Fix small bugs, formatting and file structure
This commit is contained in:
parent
ff6f6ef868
commit
d3f76f0b22
|
@ -43,6 +43,7 @@ class KanjiSearchOptionsBar extends StatelessWidget {
|
|||
class _IconButton extends StatelessWidget {
|
||||
final Widget icon;
|
||||
final void Function()? onPressed;
|
||||
|
||||
const _IconButton({
|
||||
required this.icon,
|
||||
required this.onPressed,
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
|||
class Grade extends StatelessWidget {
|
||||
final String grade;
|
||||
|
||||
const Grade(this.grade);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -20,6 +22,4 @@ class Grade extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
Grade(this.grade);
|
||||
}
|
|
@ -3,20 +3,24 @@ import 'package:flutter/material.dart';
|
|||
class Header extends StatelessWidget {
|
||||
final String kanji;
|
||||
|
||||
const Header(this.kanji);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.0), color: Colors.blue),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(
|
||||
kanji,
|
||||
style: TextStyle(fontSize: 80.0, color: Colors.white),
|
||||
return AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
color: Colors.blue,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
kanji,
|
||||
style: TextStyle(fontSize: 70.0, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Header(this.kanji);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
|||
class JlptLevel extends StatelessWidget {
|
||||
final String jlptLevel;
|
||||
|
||||
const JlptLevel(this.jlptLevel);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -21,6 +23,4 @@ class JlptLevel extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
JlptLevel(this.jlptLevel);
|
||||
}
|
|
@ -5,6 +5,13 @@ class Meaning extends StatelessWidget {
|
|||
late final List<_MeaningCard> meaningCards;
|
||||
late final bool expandable;
|
||||
|
||||
Meaning(meaning) {
|
||||
this.meanings = meaning.split(', ');
|
||||
this.meaningCards =
|
||||
meanings.map((m) => _MeaningCard(m)).toList();
|
||||
this.expandable = (this.meanings.length > 6);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -42,18 +49,13 @@ class Meaning extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
Meaning(meaning) {
|
||||
this.meanings = meaning.split(', ');
|
||||
this.meaningCards =
|
||||
meanings.map((m) => _MeaningCard(m)).toList();
|
||||
this.expandable = (this.meanings.length > 6);
|
||||
}
|
||||
}
|
||||
|
||||
class _MeaningCard extends StatelessWidget {
|
||||
final String meaning;
|
||||
|
||||
const _MeaningCard(this.meaning);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -75,6 +77,4 @@ class _MeaningCard extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
_MeaningCard(this.meaning);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class Onyomi extends StatelessWidget {
|
|||
|
||||
class _OnyomiCard extends StatelessWidget {
|
||||
final String onyomi;
|
||||
|
||||
const _OnyomiCard(this.onyomi);
|
||||
|
||||
@override
|
||||
|
|
|
@ -4,6 +4,8 @@ import 'package:unofficial_jisho_api/api.dart' as jisho;
|
|||
class Radical extends StatelessWidget {
|
||||
final jisho.Radical radical;
|
||||
|
||||
const Radical(this.radical);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -21,6 +23,4 @@ class Radical extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
Radical(this.radical);
|
||||
}
|
|
@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
|||
class Rank extends StatelessWidget {
|
||||
final int rank;
|
||||
|
||||
const Rank(this.rank);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -21,6 +23,4 @@ class Rank extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
Rank(this.rank);
|
||||
}
|
|
@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
|||
class StrokeOrderGif extends StatelessWidget {
|
||||
final String uri;
|
||||
|
||||
const StrokeOrderGif(this.uri);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
@ -18,6 +20,4 @@ class StrokeOrderGif extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
StrokeOrderGif(this.uri);
|
||||
}
|
|
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class LanguageSelector extends StatefulWidget {
|
||||
const LanguageSelector();
|
||||
|
||||
@override
|
||||
_LanguageSelectorState createState() => new _LanguageSelectorState();
|
||||
}
|
||||
|
@ -44,7 +46,7 @@ class _LanguageSelectorState extends State<LanguageSelector> {
|
|||
isSelected: isSelected,
|
||||
children: <Widget> [
|
||||
_LanguageOption("Auto"),
|
||||
_LanguageOption("Japanese"),
|
||||
_LanguageOption("日本語"),
|
||||
_LanguageOption("English")
|
||||
],
|
||||
selectedColor: Colors.blue,
|
||||
|
@ -64,7 +66,7 @@ class _LanguageSelectorState extends State<LanguageSelector> {
|
|||
class _LanguageOption extends StatelessWidget {
|
||||
final String language;
|
||||
|
||||
_LanguageOption(this.language);
|
||||
const _LanguageOption(this.language);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
|
@ -1,9 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:jisho_study_tool/bloc/search/search_bloc.dart';
|
||||
import 'package:jisho_study_tool/view/components/search/LanguageSelector.dart';
|
||||
import 'package:jisho_study_tool/view/components/search/language_selector.dart';
|
||||
|
||||
class SearchBar extends StatelessWidget {
|
||||
|
||||
const SearchBar();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
|
|
@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
|
|||
import 'package:jisho_study_tool/view/components/search/search_result_page/parts/badge.dart';
|
||||
|
||||
class CommonBadge extends StatelessWidget {
|
||||
bool isCommon;
|
||||
final bool isCommon;
|
||||
|
||||
CommonBadge(this.isCommon);
|
||||
const CommonBadge(this.isCommon);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:unofficial_jisho_api/api.dart';
|
|||
|
||||
class JapaneseHeader extends StatelessWidget {
|
||||
final JishoJapaneseWord word;
|
||||
|
||||
const JapaneseHeader(this.word);
|
||||
|
||||
@override
|
||||
|
|
|
@ -3,7 +3,8 @@ import 'package:unofficial_jisho_api/api.dart';
|
|||
|
||||
class OtherForms extends StatelessWidget {
|
||||
final List<JishoJapaneseWord> otherForms;
|
||||
OtherForms(this.otherForms);
|
||||
|
||||
const OtherForms(this.otherForms);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -28,6 +29,7 @@ class OtherForms extends StatelessWidget {
|
|||
|
||||
class _KanaBox extends StatelessWidget {
|
||||
final JishoJapaneseWord word;
|
||||
|
||||
const _KanaBox(this.word);
|
||||
|
||||
@override
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:unofficial_jisho_api/parser.dart';
|
|||
|
||||
class Senses extends StatelessWidget {
|
||||
final List<JishoWordSense> senses;
|
||||
|
||||
const Senses(this.senses);
|
||||
|
||||
@override
|
||||
|
|
|
@ -31,7 +31,7 @@ class SearchResultCard extends StatelessWidget {
|
|||
children: [
|
||||
WKBadge(result.tags.firstWhere((tag) => tag.contains("wanikani"), orElse: () => '')),
|
||||
JLPTBadge(result.jlpt.isNotEmpty ? result.jlpt[0] : ''),
|
||||
CommonBadge(result.isCommon!)
|
||||
CommonBadge(result.isCommon ?? false)
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart';
|
||||
import 'package:jisho_study_tool/view/components/kanji/kanji_grid.dart';
|
||||
import 'package:jisho_study_tool/view/components/kanji/kanji_search_bar.dart';
|
||||
|
||||
|
|
|
@ -8,32 +8,30 @@ import 'package:jisho_study_tool/view/components/search/search_result_page/searc
|
|||
class SearchView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<SearchBloc, SearchState>(
|
||||
listener: (context, state) {},
|
||||
child: BlocBuilder<SearchBloc, SearchState>(
|
||||
builder: (context, state) {
|
||||
if (state is SearchInitial)
|
||||
return _InitialView();
|
||||
else if (state is SearchLoading)
|
||||
return LoadingScreen();
|
||||
else if (state is SearchFinished) {
|
||||
return WillPopScope(
|
||||
child: ListView(
|
||||
children: state.results
|
||||
.map((result) => SearchResultCard(result))
|
||||
.toList(),
|
||||
),
|
||||
onWillPop: () async {
|
||||
BlocProvider.of<SearchBloc>(context)
|
||||
.add(ReturnToInitialState());
|
||||
print('Popped');
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
throw 'No such event found';
|
||||
},
|
||||
));
|
||||
return BlocConsumer<SearchBloc, SearchState>(
|
||||
listener: (context, state) {},
|
||||
builder: (context, state) {
|
||||
if (state is SearchInitial)
|
||||
return _InitialView();
|
||||
else if (state is SearchLoading)
|
||||
return LoadingScreen();
|
||||
else if (state is SearchFinished) {
|
||||
return WillPopScope(
|
||||
child: ListView(
|
||||
children: state.results
|
||||
.map((result) => SearchResultCard(result))
|
||||
.toList(),
|
||||
),
|
||||
onWillPop: () async {
|
||||
BlocProvider.of<SearchBloc>(context).add(ReturnToInitialState());
|
||||
print('Popped');
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
throw 'No such event found';
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,4 +42,4 @@ class _InitialView extends StatelessWidget {
|
|||
SearchBar(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue