From 1a3acf80f10b846a4b1b43067db9cc0d85b57051 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 2 Mar 2021 22:26:33 +0100 Subject: [PATCH 01/14] Update bloc --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index ece49e4..99c2478 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: # cupertino_icons: ^0.1.2 unofficial_jisho_api: ^1.1.0 - flutter_bloc: ^6.0.1 + flutter_bloc: ^6.1.0 url_launcher: ^5.5.0 division: ^0.8.8 From d280f62c9f8720ebd8edf9d2994d0ebe06985863 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 2 Mar 2021 22:26:59 +0100 Subject: [PATCH 02/14] move files around --- lib/bloc/kanji/kanji_bloc.dart | 7 +-- lib/bloc/search/search_bloc.dart | 2 +- lib/main.dart | 7 +-- .../{ => jisho_api}/jisho_search.dart | 0 .../{ => jisho_api}/kanji_search.dart | 0 .../kanji_search_result_page.dart} | 0 .../parts/examples.dart | 0 .../parts/grade.dart | 0 .../parts/header.dart | 0 .../parts/jlpt_level.dart | 0 .../parts/kunyomi.dart | 0 .../parts/meaning.dart | 0 .../parts/onyomi.dart | 0 .../parts/radical.dart | 0 .../kanji_search_result_page}/parts/rank.dart | 0 .../parts/stroke_order_gif.dart | 0 .../kanji_grid.dart} | 0 .../kanji_search_suggestion_list.dart} | 0 .../components/search/LanguageSelector.dart | 59 +++++++++++++++++++ .../components/search/parts/header.dart | 0 .../components/search/parts/other_forms.dart | 0 .../components/search/parts/senses.dart | 0 .../components/search/search_card.dart | 0 .../search/wikipedia_attribute.dart | 0 lib/{ => view}/screens/history.dart | 0 lib/{ => view}/screens/kanji_search.dart | 6 +- lib/{components => view/screens}/loading.dart | 0 lib/{ => view}/screens/memorize.dart | 0 lib/{ => view}/screens/search.dart | 35 ++--------- lib/{ => view}/screens/settings.dart | 0 lib/{ => view}/themes/dark.dart | 0 lib/{ => view}/themes/light.dart | 0 32 files changed, 73 insertions(+), 43 deletions(-) rename lib/services/{ => jisho_api}/jisho_search.dart (100%) rename lib/services/{ => jisho_api}/kanji_search.dart (100%) rename lib/{components/kanji/kanji__search_page/kanji_search_page.dart => view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart} (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/examples.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/grade.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/header.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/jlpt_level.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/kunyomi.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/meaning.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/onyomi.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/radical.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/rank.dart (100%) rename lib/{components/kanji/kanji__search_page => view/components/kanji/kanji_search_result_page}/parts/stroke_order_gif.dart (100%) rename lib/{components/kanji/kanji_list/kanji_list.dart => view/components/kanji/kanji_search_suggestion_list/kanji_grid.dart} (100%) rename lib/{components/kanji/kanji_suggestions.dart => view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart} (100%) create mode 100644 lib/view/components/search/LanguageSelector.dart rename lib/{ => view}/components/search/parts/header.dart (100%) rename lib/{ => view}/components/search/parts/other_forms.dart (100%) rename lib/{ => view}/components/search/parts/senses.dart (100%) rename lib/{ => view}/components/search/search_card.dart (100%) rename lib/{ => view}/components/search/wikipedia_attribute.dart (100%) rename lib/{ => view}/screens/history.dart (100%) rename lib/{ => view}/screens/kanji_search.dart (93%) rename lib/{components => view/screens}/loading.dart (100%) rename lib/{ => view}/screens/memorize.dart (100%) rename lib/{ => view}/screens/search.dart (70%) rename lib/{ => view}/screens/settings.dart (100%) rename lib/{ => view}/themes/dark.dart (100%) rename lib/{ => view}/themes/light.dart (100%) diff --git a/lib/bloc/kanji/kanji_bloc.dart b/lib/bloc/kanji/kanji_bloc.dart index a8cfe7d..5a8c594 100644 --- a/lib/bloc/kanji/kanji_bloc.dart +++ b/lib/bloc/kanji/kanji_bloc.dart @@ -4,7 +4,7 @@ import './kanji_event.dart'; import './kanji_state.dart'; import 'package:bloc/bloc.dart'; -import 'package:jisho_study_tool/services/kanji_search.dart'; +import 'package:jisho_study_tool/services/jisho_api/kanji_search.dart'; import 'package:jisho_study_tool/services/kanji_suggestions.dart'; export './kanji_event.dart'; @@ -15,9 +15,8 @@ class KanjiBloc extends Bloc { KanjiBloc() : super(KanjiSearchInitial()); @override - Stream mapEventToState( - KanjiEvent event, - ) async* { + Stream mapEventToState(KanjiEvent event) + async* { if (event is GetKanji) { yield KanjiSearchLoading(); diff --git a/lib/bloc/search/search_bloc.dart b/lib/bloc/search/search_bloc.dart index 357dee1..bbd02f9 100644 --- a/lib/bloc/search/search_bloc.dart +++ b/lib/bloc/search/search_bloc.dart @@ -5,7 +5,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; -import 'package:jisho_study_tool/services/jisho_search.dart'; +import 'package:jisho_study_tool/services/jisho_api/jisho_search.dart'; import 'package:unofficial_jisho_api/parser.dart'; part 'search_event.dart'; diff --git a/lib/main.dart b/lib/main.dart index 7e91207..ecb68b4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,16 +1,15 @@ 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/screens/kanji_search.dart'; -import 'package:jisho_study_tool/screens/history.dart'; -import 'package:jisho_study_tool/screens/search.dart'; +import 'package:jisho_study_tool/view/screens/kanji_search.dart'; +import 'package:jisho_study_tool/view/screens/history.dart'; +import 'package:jisho_study_tool/view/screens/search.dart'; import 'bloc/search/search_bloc.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( diff --git a/lib/services/jisho_search.dart b/lib/services/jisho_api/jisho_search.dart similarity index 100% rename from lib/services/jisho_search.dart rename to lib/services/jisho_api/jisho_search.dart diff --git a/lib/services/kanji_search.dart b/lib/services/jisho_api/kanji_search.dart similarity index 100% rename from lib/services/kanji_search.dart rename to lib/services/jisho_api/kanji_search.dart diff --git a/lib/components/kanji/kanji__search_page/kanji_search_page.dart b/lib/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/kanji_search_page.dart rename to lib/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart diff --git a/lib/components/kanji/kanji__search_page/parts/examples.dart b/lib/view/components/kanji/kanji_search_result_page/parts/examples.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/examples.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/examples.dart diff --git a/lib/components/kanji/kanji__search_page/parts/grade.dart b/lib/view/components/kanji/kanji_search_result_page/parts/grade.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/grade.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/grade.dart diff --git a/lib/components/kanji/kanji__search_page/parts/header.dart b/lib/view/components/kanji/kanji_search_result_page/parts/header.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/header.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/header.dart diff --git a/lib/components/kanji/kanji__search_page/parts/jlpt_level.dart b/lib/view/components/kanji/kanji_search_result_page/parts/jlpt_level.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/jlpt_level.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/jlpt_level.dart diff --git a/lib/components/kanji/kanji__search_page/parts/kunyomi.dart b/lib/view/components/kanji/kanji_search_result_page/parts/kunyomi.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/kunyomi.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/kunyomi.dart diff --git a/lib/components/kanji/kanji__search_page/parts/meaning.dart b/lib/view/components/kanji/kanji_search_result_page/parts/meaning.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/meaning.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/meaning.dart diff --git a/lib/components/kanji/kanji__search_page/parts/onyomi.dart b/lib/view/components/kanji/kanji_search_result_page/parts/onyomi.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/onyomi.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/onyomi.dart diff --git a/lib/components/kanji/kanji__search_page/parts/radical.dart b/lib/view/components/kanji/kanji_search_result_page/parts/radical.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/radical.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/radical.dart diff --git a/lib/components/kanji/kanji__search_page/parts/rank.dart b/lib/view/components/kanji/kanji_search_result_page/parts/rank.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/rank.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/rank.dart diff --git a/lib/components/kanji/kanji__search_page/parts/stroke_order_gif.dart b/lib/view/components/kanji/kanji_search_result_page/parts/stroke_order_gif.dart similarity index 100% rename from lib/components/kanji/kanji__search_page/parts/stroke_order_gif.dart rename to lib/view/components/kanji/kanji_search_result_page/parts/stroke_order_gif.dart diff --git a/lib/components/kanji/kanji_list/kanji_list.dart b/lib/view/components/kanji/kanji_search_suggestion_list/kanji_grid.dart similarity index 100% rename from lib/components/kanji/kanji_list/kanji_list.dart rename to lib/view/components/kanji/kanji_search_suggestion_list/kanji_grid.dart diff --git a/lib/components/kanji/kanji_suggestions.dart b/lib/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart similarity index 100% rename from lib/components/kanji/kanji_suggestions.dart rename to lib/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart diff --git a/lib/view/components/search/LanguageSelector.dart b/lib/view/components/search/LanguageSelector.dart new file mode 100644 index 0000000..730fc34 --- /dev/null +++ b/lib/view/components/search/LanguageSelector.dart @@ -0,0 +1,59 @@ + +import 'package:flutter/material.dart'; + +class LanguageSelector extends StatefulWidget { + final List _languages; + + LanguageSelector(this._languages); + + @override + LanguageSelectorState createState() => new LanguageSelectorState(this._languages); +} + +class LanguageSelectorState extends State { + final List _languages; + List isSelected = [true, false, false]; + + LanguageSelectorState(this._languages); + + @override + void initState() { + super.initState(); + isSelected = [true, false, false]; + } + + @override + Widget build(BuildContext context) { + return ToggleButtons( + children: [ + LanguageOption("Auto"), + LanguageOption("Japanese"), + LanguageOption("English") + ], + isSelected: isSelected + ); + } + +} + +class LanguageOption extends StatelessWidget { + final String _language; + + LanguageOption(this._language); + + @override + Widget build(BuildContext context) { + return Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 10.0), + child: Center(child: Text(_language)), + decoration: BoxDecoration( + border: Border.all( + color: Colors.black, + width: 1.0, + ), + color: Colors.white), + ), + ); + } +} \ No newline at end of file diff --git a/lib/components/search/parts/header.dart b/lib/view/components/search/parts/header.dart similarity index 100% rename from lib/components/search/parts/header.dart rename to lib/view/components/search/parts/header.dart diff --git a/lib/components/search/parts/other_forms.dart b/lib/view/components/search/parts/other_forms.dart similarity index 100% rename from lib/components/search/parts/other_forms.dart rename to lib/view/components/search/parts/other_forms.dart diff --git a/lib/components/search/parts/senses.dart b/lib/view/components/search/parts/senses.dart similarity index 100% rename from lib/components/search/parts/senses.dart rename to lib/view/components/search/parts/senses.dart diff --git a/lib/components/search/search_card.dart b/lib/view/components/search/search_card.dart similarity index 100% rename from lib/components/search/search_card.dart rename to lib/view/components/search/search_card.dart diff --git a/lib/components/search/wikipedia_attribute.dart b/lib/view/components/search/wikipedia_attribute.dart similarity index 100% rename from lib/components/search/wikipedia_attribute.dart rename to lib/view/components/search/wikipedia_attribute.dart diff --git a/lib/screens/history.dart b/lib/view/screens/history.dart similarity index 100% rename from lib/screens/history.dart rename to lib/view/screens/history.dart diff --git a/lib/screens/kanji_search.dart b/lib/view/screens/kanji_search.dart similarity index 93% rename from lib/screens/kanji_search.dart rename to lib/view/screens/kanji_search.dart index 617423b..299d2fb 100644 --- a/lib/screens/kanji_search.dart +++ b/lib/view/screens/kanji_search.dart @@ -3,9 +3,9 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart'; -import 'package:jisho_study_tool/components/kanji/kanji__search_page/kanji_search_page.dart'; -import 'package:jisho_study_tool/components/kanji/kanji_suggestions.dart'; -import 'package:jisho_study_tool/components/loading.dart'; +import 'package:jisho_study_tool/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart'; +import 'package:jisho_study_tool/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart'; +import 'package:jisho_study_tool/view/screens/loading.dart'; class KanjiView extends StatelessWidget { @override diff --git a/lib/components/loading.dart b/lib/view/screens/loading.dart similarity index 100% rename from lib/components/loading.dart rename to lib/view/screens/loading.dart diff --git a/lib/screens/memorize.dart b/lib/view/screens/memorize.dart similarity index 100% rename from lib/screens/memorize.dart rename to lib/view/screens/memorize.dart diff --git a/lib/screens/search.dart b/lib/view/screens/search.dart similarity index 70% rename from lib/screens/search.dart rename to lib/view/screens/search.dart index 5dd8541..f8f0f73 100644 --- a/lib/screens/search.dart +++ b/lib/view/screens/search.dart @@ -1,8 +1,9 @@ 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/components/loading.dart'; -import 'package:jisho_study_tool/components/search/search_card.dart'; +import 'package:jisho_study_tool/view/components/search/LanguageSelector.dart'; +import 'package:jisho_study_tool/view/screens/loading.dart'; +import 'package:jisho_study_tool/view/components/search/search_card.dart'; class SearchView extends StatelessWidget { @override @@ -45,28 +46,6 @@ class _InitialView extends StatelessWidget { } } -class _LanguageOption extends StatelessWidget { - final String _language; - final Color _color; - - @override - Widget build(BuildContext context) { - return Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 10.0), - child: Center(child: Text(_language)), - decoration: BoxDecoration( - border: Border.all( - color: Colors.black, - width: 1.0, - ), - color: _color), - ), - ); - } - - _LanguageOption(this._language, this._color); -} class SearchBar extends StatelessWidget { @override @@ -89,13 +68,7 @@ class SearchBar extends StatelessWidget { SizedBox( height: 10.0, ), - Row( - children: [ - _LanguageOption('Auto', Colors.white), - _LanguageOption('English', Colors.white), - _LanguageOption('Japanese', Colors.blue), - ], - ), + LanguageSelector(["Auto", "Japanese", "English"]) ], ), ); diff --git a/lib/screens/settings.dart b/lib/view/screens/settings.dart similarity index 100% rename from lib/screens/settings.dart rename to lib/view/screens/settings.dart diff --git a/lib/themes/dark.dart b/lib/view/themes/dark.dart similarity index 100% rename from lib/themes/dark.dart rename to lib/view/themes/dark.dart diff --git a/lib/themes/light.dart b/lib/view/themes/light.dart similarity index 100% rename from lib/themes/light.dart rename to lib/view/themes/light.dart From 68357e73287dd5063844eb6b1ad0746d08683704 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 2 Mar 2021 23:09:56 +0100 Subject: [PATCH 03/14] Move search result page into folder --- .../search/{ => search_result_page}/parts/header.dart | 0 .../search/{ => search_result_page}/parts/other_forms.dart | 0 .../search/{ => search_result_page}/parts/senses.dart | 0 .../{ => search_result_page/parts}/wikipedia_attribute.dart | 0 .../search/{ => search_result_page}/search_card.dart | 6 +++--- lib/view/screens/search.dart | 2 +- 6 files changed, 4 insertions(+), 4 deletions(-) rename lib/view/components/search/{ => search_result_page}/parts/header.dart (100%) rename lib/view/components/search/{ => search_result_page}/parts/other_forms.dart (100%) rename lib/view/components/search/{ => search_result_page}/parts/senses.dart (100%) rename lib/view/components/search/{ => search_result_page/parts}/wikipedia_attribute.dart (100%) rename lib/view/components/search/{ => search_result_page}/search_card.dart (86%) diff --git a/lib/view/components/search/parts/header.dart b/lib/view/components/search/search_result_page/parts/header.dart similarity index 100% rename from lib/view/components/search/parts/header.dart rename to lib/view/components/search/search_result_page/parts/header.dart diff --git a/lib/view/components/search/parts/other_forms.dart b/lib/view/components/search/search_result_page/parts/other_forms.dart similarity index 100% rename from lib/view/components/search/parts/other_forms.dart rename to lib/view/components/search/search_result_page/parts/other_forms.dart diff --git a/lib/view/components/search/parts/senses.dart b/lib/view/components/search/search_result_page/parts/senses.dart similarity index 100% rename from lib/view/components/search/parts/senses.dart rename to lib/view/components/search/search_result_page/parts/senses.dart diff --git a/lib/view/components/search/wikipedia_attribute.dart b/lib/view/components/search/search_result_page/parts/wikipedia_attribute.dart similarity index 100% rename from lib/view/components/search/wikipedia_attribute.dart rename to lib/view/components/search/search_result_page/parts/wikipedia_attribute.dart diff --git a/lib/view/components/search/search_card.dart b/lib/view/components/search/search_result_page/search_card.dart similarity index 86% rename from lib/view/components/search/search_card.dart rename to lib/view/components/search/search_result_page/search_card.dart index 20b2032..72c9376 100644 --- a/lib/view/components/search/search_card.dart +++ b/lib/view/components/search/search_result_page/search_card.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:unofficial_jisho_api/api.dart'; -import 'parts/header.dart'; -import 'parts/senses.dart'; -import 'parts/other_forms.dart'; +import './parts/header.dart'; +import './parts/senses.dart'; +import './parts/other_forms.dart'; class SearchResultCard extends StatelessWidget { final JishoResult _result; diff --git a/lib/view/screens/search.dart b/lib/view/screens/search.dart index f8f0f73..3de1a76 100644 --- a/lib/view/screens/search.dart +++ b/lib/view/screens/search.dart @@ -3,7 +3,7 @@ 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/screens/loading.dart'; -import 'package:jisho_study_tool/view/components/search/search_card.dart'; +import 'package:jisho_study_tool/view/components/search/search_result_page/search_card.dart'; class SearchView extends StatelessWidget { @override From 16ca1d2a691027e78a8ef2301ed7ede4e102649d Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 2 Mar 2021 23:35:47 +0100 Subject: [PATCH 04/14] Fix language selector design --- .../components/search/LanguageSelector.dart | 29 +++++++++---------- lib/view/screens/search.dart | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/view/components/search/LanguageSelector.dart b/lib/view/components/search/LanguageSelector.dart index 730fc34..c8a98f2 100644 --- a/lib/view/components/search/LanguageSelector.dart +++ b/lib/view/components/search/LanguageSelector.dart @@ -2,19 +2,14 @@ import 'package:flutter/material.dart'; class LanguageSelector extends StatefulWidget { - final List _languages; - LanguageSelector(this._languages); @override - LanguageSelectorState createState() => new LanguageSelectorState(this._languages); + LanguageSelectorState createState() => new LanguageSelectorState(); } class LanguageSelectorState extends State { - final List _languages; - List isSelected = [true, false, false]; - - LanguageSelectorState(this._languages); + List isSelected; @override void initState() { @@ -25,12 +20,20 @@ class LanguageSelectorState extends State { @override Widget build(BuildContext context) { return ToggleButtons( - children: [ + isSelected: isSelected, + children: [ LanguageOption("Auto"), LanguageOption("Japanese"), LanguageOption("English") ], - isSelected: isSelected + selectedColor: Colors.blue, + onPressed: (int buttonIndex) { + setState(() { + for (var i in Iterable.generate(isSelected.length)) { + isSelected[i] = i == buttonIndex; + } + }); + }, ); } @@ -45,14 +48,8 @@ class LanguageOption extends StatelessWidget { Widget build(BuildContext context) { return Expanded( child: Container( - padding: EdgeInsets.symmetric(vertical: 10.0), + padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), child: Center(child: Text(_language)), - decoration: BoxDecoration( - border: Border.all( - color: Colors.black, - width: 1.0, - ), - color: Colors.white), ), ); } diff --git a/lib/view/screens/search.dart b/lib/view/screens/search.dart index 3de1a76..23a7dd7 100644 --- a/lib/view/screens/search.dart +++ b/lib/view/screens/search.dart @@ -68,7 +68,7 @@ class SearchBar extends StatelessWidget { SizedBox( height: 10.0, ), - LanguageSelector(["Auto", "Japanese", "English"]) + LanguageSelector() ], ), ); From ac8572da9bca62d760fbcf3c3b0c1bde6c9f859f Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 3 Mar 2021 00:24:25 +0100 Subject: [PATCH 05/14] Clean up variable naming --- lib/bloc/kanji/kanji_bloc.dart | 4 +-- lib/bloc/search/search_bloc.dart | 4 +-- lib/main.dart | 36 +++++++++---------- lib/services/jisho_api/kanji_search.dart | 6 ++-- .../kanji_search_result_page.dart | 24 ++++++------- .../parts/examples.dart | 26 +++++++------- .../kanji_search_result_page/parts/grade.dart | 6 ++-- .../parts/header.dart | 6 ++-- .../parts/jlpt_level.dart | 6 ++-- .../parts/kunyomi.dart | 24 ++++++------- .../parts/meaning.dart | 28 +++++++-------- .../parts/onyomi.dart | 24 ++++++------- .../parts/radical.dart | 6 ++-- .../kanji_search_result_page/parts/rank.dart | 6 ++-- .../parts/stroke_order_gif.dart | 6 ++-- .../kanji_search_suggestion_list.dart | 14 ++++---- .../components/search/LanguageSelector.dart | 20 +++++------ .../search_result_page/parts/header.dart | 10 +++--- .../search_result_page/parts/other_forms.dart | 16 ++++----- .../search_result_page/parts/senses.dart | 18 +++++----- .../search_result_page/search_card.dart | 18 +++++----- lib/view/screens/kanji_search.dart | 30 ++++++++-------- 22 files changed, 168 insertions(+), 170 deletions(-) diff --git a/lib/bloc/kanji/kanji_bloc.dart b/lib/bloc/kanji/kanji_bloc.dart index 5a8c594..ab0859e 100644 --- a/lib/bloc/kanji/kanji_bloc.dart +++ b/lib/bloc/kanji/kanji_bloc.dart @@ -22,8 +22,8 @@ class KanjiBloc extends Bloc { yield KanjiSearchLoading(); try { - final _kanji = await fetchKanji(event.kanjiSearchString); - if (_kanji.found) yield KanjiSearchFinished(kanji: _kanji); + final kanji = await fetchKanji(event.kanjiSearchString); + if (kanji.found) yield KanjiSearchFinished(kanji: kanji); else yield KanjiSearchError('Something went wrong'); } on Exception { yield KanjiSearchError('Something went wrong'); diff --git a/lib/bloc/search/search_bloc.dart b/lib/bloc/search/search_bloc.dart index bbd02f9..abca65c 100644 --- a/lib/bloc/search/search_bloc.dart +++ b/lib/bloc/search/search_bloc.dart @@ -22,8 +22,8 @@ class SearchBloc extends Bloc { yield SearchLoading(); try { - final _searchResults = await fetchJishoResults(event.searchString); - if (_searchResults.meta.status == 200) yield SearchFinished(_searchResults.data); + final searchResults = await fetchJishoResults(event.searchString); + if (searchResults.meta.status == 200) yield SearchFinished(searchResults.data); } on Exception { yield SearchError('Something went wrong'); } diff --git a/lib/main.dart b/lib/main.dart index ecb68b4..5147f3c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -34,21 +34,21 @@ class Home extends StatefulWidget { } class _HomeState extends State { - int _selectedPage = 0; + int selectedPage = 0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: pages[_selectedPage].titleBar, + title: pages[selectedPage].titleBar, centerTitle: true, ), - body: pages[_selectedPage].content, + body: pages[selectedPage].content, bottomNavigationBar: BottomNavigationBar( - currentIndex: _selectedPage, + currentIndex: selectedPage, onTap: (int index) { setState(() { - _selectedPage = index; + selectedPage = index; }); }, items: navBar, @@ -63,55 +63,55 @@ class _HomeState extends State { final List navBar = [ BottomNavigationBarItem( - title: Text('Search'), + label: 'Search', icon: Icon(Icons.search), ), BottomNavigationBarItem( - title: Text('Kanji'), + label: 'Kanji', icon: Text( '漢', style: TextStyle(fontSize: 18), ), ), BottomNavigationBarItem( - title: Text('History'), + label: 'History', icon: Icon(Icons.bookmark), ), BottomNavigationBarItem( - title: Text('Memorize'), + label: 'Memorize', icon: Icon(Icons.local_offer), ), BottomNavigationBarItem( - title: Text('Settings'), + label: 'Settings', icon: Icon(Icons.settings), ), ]; -class Page { +class _Page { Widget content; Widget titleBar; - Page({ + _Page({ this.content, this.titleBar, }); } -final List pages = [ - Page(content: SearchView(), titleBar: Text('Search')), - Page( +final List<_Page> pages = [ + _Page(content: SearchView(), titleBar: Text('Search')), + _Page( content: KanjiView(), titleBar: KanjiViewBar(), ), - Page( + _Page( content: HistoryView(), titleBar: Text("History"), ), - Page( + _Page( content: Container(), titleBar: Text("Memorization"), ), - Page( + _Page( content: Container(), titleBar: Text("Settings"), ), diff --git a/lib/services/jisho_api/kanji_search.dart b/lib/services/jisho_api/kanji_search.dart index ff4b460..92e01e2 100644 --- a/lib/services/jisho_api/kanji_search.dart +++ b/lib/services/jisho_api/kanji_search.dart @@ -1,7 +1,7 @@ import 'package:unofficial_jisho_api/api.dart' as jisho; String _convertGrade(String grade) { - const _conversionTable = { + const conversionTable = { "grade 1": "小1", "grade 2": "小2", "grade 3": "小3", @@ -11,9 +11,9 @@ String _convertGrade(String grade) { "junior high": "中" }; - print('conversion run: $grade -> ${_conversionTable[grade]}'); + print('conversion run: $grade -> ${conversionTable[grade]}'); - return _conversionTable[grade]; + return conversionTable[grade]; } Future fetchKanji(String kanji) async { diff --git a/lib/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart b/lib/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart index 889a48f..87a5763 100644 --- a/lib/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart +++ b/lib/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart @@ -14,7 +14,7 @@ import 'parts/kunyomi.dart'; import 'parts/examples.dart'; class KanjiResultCard extends StatelessWidget { - final jisho.KanjiResult _result; + final jisho.KanjiResult result; @override Widget build(BuildContext context) { @@ -33,26 +33,26 @@ class KanjiResultCard extends StatelessWidget { Flexible( flex: 1, fit: FlexFit.tight, - child: Center(child: Header(_result.query)), + child: Center(child: Header(result.query)), ), Flexible( flex: 1, fit: FlexFit.tight, child: Center( - child: Radical(_result.radical), + child: Radical(result.radical), ), ), ], ), ), - Meaning(_result.meaning), - _result.onyomi.length != 0 ? Onyomi(_result.onyomi) : SizedBox.shrink(), - _result.kunyomi.length != 0 ? Kunyomi(_result.kunyomi) : SizedBox.shrink(), + Meaning(result.meaning), + result.onyomi.length != 0 ? Onyomi(result.onyomi) : SizedBox.shrink(), + result.kunyomi.length != 0 ? Kunyomi(result.kunyomi) : SizedBox.shrink(), IntrinsicHeight( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - StrokeOrderGif(_result.strokeOrderGifUri), + StrokeOrderGif(result.strokeOrderGifUri), Container( child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -61,19 +61,19 @@ class KanjiResultCard extends StatelessWidget { Row( children: [ Text("JLPT: ", style: TextStyle(fontSize: 20.0)), - JlptLevel(_result.jlptLevel ?? "⨉"), + JlptLevel(result.jlptLevel ?? "⨉"), ], ), Row( children: [ Text("Grade: ", style: TextStyle(fontSize: 20.0)), - Grade(_result.taughtIn ?? "⨉"), + Grade(result.taughtIn ?? "⨉"), ], ), Row( children: [ Text("Rank: ", style: TextStyle(fontSize: 20.0)), - Rank(_result.newspaperFrequencyRank ?? -1), + Rank(result.newspaperFrequencyRank ?? -1), ], ), ], @@ -82,10 +82,10 @@ class KanjiResultCard extends StatelessWidget { ], ), ), - Examples(_result.onyomiExamples, _result.kunyomiExamples), + Examples(result.onyomiExamples, result.kunyomiExamples), ], ); } - KanjiResultCard(this._result); + KanjiResultCard(this.result); } diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/examples.dart b/lib/view/components/kanji/kanji_search_result_page/parts/examples.dart index f90911a..1fe4df0 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/examples.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/examples.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; import 'package:unofficial_jisho_api/api.dart'; class Examples extends StatelessWidget { - final List _onyomiExamples; - final List _kunyomiExamples; + final List onyomiExamples; + final List kunyomiExamples; const Examples( - this._onyomiExamples, - this._kunyomiExamples, + this.onyomiExamples, + this.kunyomiExamples, ); @override @@ -30,10 +30,10 @@ class Examples extends StatelessWidget { ), ), children: [ - _onyomiExamples + onyomiExamples .map((onyomiExample) => _Example(onyomiExample, _KanaType.onyomi)) .toList(), - _kunyomiExamples + kunyomiExamples .map((kunyomiExample) => _Example(kunyomiExample, _KanaType.kunyomi)) .toList(), @@ -44,10 +44,10 @@ class Examples extends StatelessWidget { enum _KanaType { kunyomi, onyomi } class _Example extends StatelessWidget { - final _KanaType _kanaType; - final YomiExample _yomiExample; + final _KanaType kanaType; + final YomiExample yomiExample; - const _Example(this._yomiExample, this._kanaType); + const _Example(this.yomiExample, this.kanaType); @override Widget build(BuildContext context) { @@ -67,7 +67,7 @@ class _Example extends StatelessWidget { horizontal: 10.0, ), decoration: BoxDecoration( - color: (_kanaType == _KanaType.kunyomi) + color: (kanaType == _KanaType.kunyomi) ? Colors.lightBlue : Colors.orange, borderRadius: BorderRadius.only( @@ -79,7 +79,7 @@ class _Example extends StatelessWidget { children: [ Container( child: Text( - _yomiExample.reading, + yomiExample.reading, style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -91,7 +91,7 @@ class _Example extends StatelessWidget { ), Container( child: Text( - _yomiExample.example, + yomiExample.example, style: TextStyle( color: Colors.white, fontSize: 20.0, @@ -109,7 +109,7 @@ class _Example extends StatelessWidget { children: [ Container( child: Text( - _yomiExample.meaning, + yomiExample.meaning, style: TextStyle( color: Colors.white, ), diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/grade.dart b/lib/view/components/kanji/kanji_search_result_page/parts/grade.dart index c7422ea..6eda527 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/grade.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/grade.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; class Grade extends StatelessWidget { - final String _grade; + final String grade; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(10.0), child: Text( - _grade, + grade, style: TextStyle( color: Colors.white, fontSize: 20.0, @@ -21,5 +21,5 @@ class Grade extends StatelessWidget { ); } - Grade(this._grade); + Grade(this.grade); } \ No newline at end of file diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/header.dart b/lib/view/components/kanji/kanji_search_result_page/parts/header.dart index 08d2211..1f35943 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/header.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/header.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class Header extends StatelessWidget { - final String _kanji; + final String kanji; @override Widget build(BuildContext context) { @@ -11,12 +11,12 @@ class Header extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(10.0), child: Text( - _kanji, + kanji, style: TextStyle(fontSize: 80.0, color: Colors.white), ), ), ); } - Header(this._kanji); + Header(this.kanji); } \ No newline at end of file diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/jlpt_level.dart b/lib/view/components/kanji/kanji_search_result_page/parts/jlpt_level.dart index 4f67fd3..0743c47 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/jlpt_level.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/jlpt_level.dart @@ -2,14 +2,14 @@ import 'package:flutter/material.dart'; class JlptLevel extends StatelessWidget { - final String _jlptLevel; + final String jlptLevel; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(10.0), child: Text( - _jlptLevel, + jlptLevel, style: TextStyle( color: Colors.white, fontSize: 20.0, @@ -22,5 +22,5 @@ class JlptLevel extends StatelessWidget { ); } - JlptLevel(this._jlptLevel); + JlptLevel(this.jlptLevel); } \ No newline at end of file diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/kunyomi.dart b/lib/view/components/kanji/kanji_search_result_page/parts/kunyomi.dart index 2168303..f9545fc 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/kunyomi.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/kunyomi.dart @@ -1,13 +1,13 @@ import 'package:flutter/material.dart'; class Kunyomi extends StatelessWidget { - final List _kunyomi; - List<_KunyomiCard> _kunyomiCards; - bool _expandable; + final List kunyomi; + List<_KunyomiCard> kunyomiCards; + bool expandable; - Kunyomi(this._kunyomi) { - _kunyomiCards = _kunyomi.map((kunyomi) => _KunyomiCard(kunyomi)).toList(); - _expandable = (_kunyomi.length > 6); + Kunyomi(this.kunyomi) { + kunyomiCards = kunyomi.map((kunyomi) => _KunyomiCard(kunyomi)).toList(); + expandable = (kunyomi.length > 6); } @override @@ -23,7 +23,7 @@ class Kunyomi extends StatelessWidget { } Widget _KunyomiWrapper(BuildContext context) { - if (_expandable) { + if (expandable) { return ExpansionTile( initiallyExpanded: false, title: Center(child: _KunyomiCard('Kunyomi')), @@ -33,7 +33,7 @@ class Kunyomi extends StatelessWidget { ), Wrap( runSpacing: 10.0, - children: _kunyomiCards, + children: kunyomiCards, ), SizedBox( height: 25.0, @@ -43,15 +43,15 @@ class Kunyomi extends StatelessWidget { } else { return Wrap( runSpacing: 10.0, - children: _kunyomiCards, + children: kunyomiCards, ); } } } class _KunyomiCard extends StatelessWidget { - final String _kunyomi; - const _KunyomiCard(this._kunyomi); + final String kunyomi; + const _KunyomiCard(this.kunyomi); @override Widget build(BuildContext context) { @@ -62,7 +62,7 @@ class _KunyomiCard extends StatelessWidget { horizontal: 10.0, ), child: Text( - _kunyomi, + kunyomi, style: TextStyle( fontSize: 20.0, color: Colors.white, diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/meaning.dart b/lib/view/components/kanji/kanji_search_result_page/parts/meaning.dart index daa9d8e..0cf0adf 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/meaning.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/meaning.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; class Meaning extends StatelessWidget { - List _meanings; - List<_MeaningCard> _meaningCards; - bool _expandable; + List meanings; + List<_MeaningCard> meaningCards; + bool expandable; @override Widget build(BuildContext context) { @@ -18,7 +18,7 @@ class Meaning extends StatelessWidget { } Widget _MeaningWrapper(BuildContext context) { - if (_expandable) { + if (expandable) { return ExpansionTile( initiallyExpanded: false, title: Center(child: _MeaningCard('Meanings')), @@ -28,7 +28,7 @@ class Meaning extends StatelessWidget { ), Wrap( runSpacing: 10.0, - children: _meaningCards, + children: meaningCards, ), SizedBox( height: 25.0, @@ -38,21 +38,21 @@ class Meaning extends StatelessWidget { } else { return Wrap( runSpacing: 10.0, - children: _meaningCards, + children: meaningCards, ); } } - Meaning(_meaning) { - this._meanings = _meaning.split(', '); - this._meaningCards = - _meanings.map((meaning) => _MeaningCard(meaning)).toList(); - this._expandable = (this._meanings.length > 6); + 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; + final String meaning; @override Widget build(BuildContext context) { @@ -63,7 +63,7 @@ class _MeaningCard extends StatelessWidget { vertical: 10.0, ), child: Text( - _meaning, + meaning, style: TextStyle( fontSize: 20.0, color: Colors.white, @@ -76,5 +76,5 @@ class _MeaningCard extends StatelessWidget { ); } - _MeaningCard(this._meaning); + _MeaningCard(this.meaning); } diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/onyomi.dart b/lib/view/components/kanji/kanji_search_result_page/parts/onyomi.dart index 3d76434..9839092 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/onyomi.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/onyomi.dart @@ -1,13 +1,13 @@ import 'package:flutter/material.dart'; class Onyomi extends StatelessWidget { - final List _onyomi; - List<_OnyomiCard> _onyomiCards; - bool _expandable; + final List onyomi; + List<_OnyomiCard> onyomiCards; + bool expandable; - Onyomi(this._onyomi) { - _onyomiCards = _onyomi.map((onyomi) => _OnyomiCard(onyomi)).toList(); - _expandable = (_onyomi.length > 6); + Onyomi(this.onyomi) { + onyomiCards = onyomi.map((onyomi) => _OnyomiCard(onyomi)).toList(); + expandable = (onyomi.length > 6); } @override @@ -23,7 +23,7 @@ class Onyomi extends StatelessWidget { } Widget _OnyomiWrapper(BuildContext context) { - if (_expandable) { + if (expandable) { return ExpansionTile( initiallyExpanded: false, title: Center(child: _OnyomiCard('Onyomi')), @@ -33,7 +33,7 @@ class Onyomi extends StatelessWidget { ), Wrap( runSpacing: 10.0, - children: _onyomiCards, + children: onyomiCards, ), SizedBox( height: 25.0, @@ -43,15 +43,15 @@ class Onyomi extends StatelessWidget { } else { return Wrap( runSpacing: 10.0, - children: _onyomiCards, + children: onyomiCards, ); } } } class _OnyomiCard extends StatelessWidget { - final String _onyomi; - const _OnyomiCard(this._onyomi); + final String onyomi; + const _OnyomiCard(this.onyomi); @override Widget build(BuildContext context) { @@ -62,7 +62,7 @@ class _OnyomiCard extends StatelessWidget { horizontal: 10.0, ), child: Text( - _onyomi, + onyomi, style: TextStyle( fontSize: 20.0, color: Colors.white, diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/radical.dart b/lib/view/components/kanji/kanji_search_result_page/parts/radical.dart index fcc952e..07d6d61 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/radical.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/radical.dart @@ -2,14 +2,14 @@ import 'package:flutter/material.dart'; import 'package:unofficial_jisho_api/api.dart' as jisho; class Radical extends StatelessWidget { - final jisho.Radical _radical; + final jisho.Radical radical; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(10.0), child: Text( - _radical.symbol, + radical.symbol, style: TextStyle( color: Colors.white, fontSize: 40.0, @@ -22,5 +22,5 @@ class Radical extends StatelessWidget { ); } - Radical(this._radical); + Radical(this.radical); } \ No newline at end of file diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/rank.dart b/lib/view/components/kanji/kanji_search_result_page/parts/rank.dart index 4202398..6a65b86 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/rank.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/rank.dart @@ -2,14 +2,14 @@ import 'package:flutter/material.dart'; class Rank extends StatelessWidget { - final int _rank; + final int rank; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(10.0), child: Text( - '${_rank.toString()} / 2500', + '${rank.toString()} / 2500', style: TextStyle( color: Colors.white, fontSize: 20.0, @@ -22,5 +22,5 @@ class Rank extends StatelessWidget { ); } - Rank(this._rank); + Rank(this.rank); } \ No newline at end of file diff --git a/lib/view/components/kanji/kanji_search_result_page/parts/stroke_order_gif.dart b/lib/view/components/kanji/kanji_search_result_page/parts/stroke_order_gif.dart index e99b7da..615eb21 100644 --- a/lib/view/components/kanji/kanji_search_result_page/parts/stroke_order_gif.dart +++ b/lib/view/components/kanji/kanji_search_result_page/parts/stroke_order_gif.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class StrokeOrderGif extends StatelessWidget { - final String _uri; + final String uri; @override Widget build(BuildContext context) { @@ -9,7 +9,7 @@ class StrokeOrderGif extends StatelessWidget { margin: EdgeInsets.symmetric(vertical: 20.0), padding: EdgeInsets.all(5.0), child: ClipRRect( - child: Image.network(_uri), + child: Image.network(uri), borderRadius: BorderRadius.circular(10.0), ), decoration: BoxDecoration( @@ -19,5 +19,5 @@ class StrokeOrderGif extends StatelessWidget { ); } - StrokeOrderGif(this._uri); + StrokeOrderGif(this.uri); } \ No newline at end of file diff --git a/lib/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart b/lib/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart index ade96cb..28dfb48 100644 --- a/lib/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart +++ b/lib/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart @@ -3,8 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart'; class KanjiSuggestions extends StatelessWidget { - final List _suggestions; - const KanjiSuggestions(this._suggestions); + final List suggestions; + const KanjiSuggestions(this.suggestions); @override Widget build(BuildContext context) { @@ -18,21 +18,21 @@ class KanjiSuggestions extends StatelessWidget { crossAxisCount: 3, mainAxisSpacing: 20.0, crossAxisSpacing: 40.0, - children: _suggestions.map((kanji) => _Suggestion(kanji)).toList(), + children: suggestions.map((kanji) => _Suggestion(kanji)).toList(), ), ); } } class _Suggestion extends StatelessWidget { - final String _kanji; - const _Suggestion(this._kanji); + final String kanji; + const _Suggestion(this.kanji); @override Widget build(BuildContext context) { return InkWell( onTap: () { - BlocProvider.of(context).add(GetKanji(_kanji)); + BlocProvider.of(context).add(GetKanji(kanji)); }, child: Container( decoration: BoxDecoration( @@ -43,7 +43,7 @@ class _Suggestion extends StatelessWidget { margin: EdgeInsets.all(10.0), child: FittedBox( child: Text( - _kanji, + kanji, style: TextStyle(color: Colors.white), ), ), diff --git a/lib/view/components/search/LanguageSelector.dart b/lib/view/components/search/LanguageSelector.dart index c8a98f2..66ce133 100644 --- a/lib/view/components/search/LanguageSelector.dart +++ b/lib/view/components/search/LanguageSelector.dart @@ -2,13 +2,11 @@ import 'package:flutter/material.dart'; class LanguageSelector extends StatefulWidget { - - @override - LanguageSelectorState createState() => new LanguageSelectorState(); + _LanguageSelectorState createState() => new _LanguageSelectorState(); } -class LanguageSelectorState extends State { +class _LanguageSelectorState extends State { List isSelected; @override @@ -22,9 +20,9 @@ class LanguageSelectorState extends State { return ToggleButtons( isSelected: isSelected, children: [ - LanguageOption("Auto"), - LanguageOption("Japanese"), - LanguageOption("English") + _LanguageOption("Auto"), + _LanguageOption("Japanese"), + _LanguageOption("English") ], selectedColor: Colors.blue, onPressed: (int buttonIndex) { @@ -39,17 +37,17 @@ class LanguageSelectorState extends State { } -class LanguageOption extends StatelessWidget { - final String _language; +class _LanguageOption extends StatelessWidget { + final String language; - LanguageOption(this._language); + _LanguageOption(this.language); @override Widget build(BuildContext context) { return Expanded( child: Container( padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), - child: Center(child: Text(_language)), + child: Center(child: Text(language)), ), ); } diff --git a/lib/view/components/search/search_result_page/parts/header.dart b/lib/view/components/search/search_result_page/parts/header.dart index 6b75b6a..ca8d377 100644 --- a/lib/view/components/search/search_result_page/parts/header.dart +++ b/lib/view/components/search/search_result_page/parts/header.dart @@ -2,20 +2,20 @@ import 'package:flutter/material.dart'; import 'package:unofficial_jisho_api/api.dart'; class JapaneseHeader extends StatelessWidget { - final JishoJapaneseWord _word; - const JapaneseHeader(this._word); + final JishoJapaneseWord word; + const JapaneseHeader(this.word); @override Widget build(BuildContext context) { - final hasFurigana = (_word.word != null); + final hasFurigana = (word.word != null); return Container( alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 10.0), child: Column( children: [ - (hasFurigana) ? Text(_word.reading) : Text(''), - (hasFurigana) ? Text(_word.word) : Text(_word.reading), + (hasFurigana) ? Text(word.reading) : Text(''), + (hasFurigana) ? Text(word.word) : Text(word.reading), ], ), ); diff --git a/lib/view/components/search/search_result_page/parts/other_forms.dart b/lib/view/components/search/search_result_page/parts/other_forms.dart index ca83901..8f78c20 100644 --- a/lib/view/components/search/search_result_page/parts/other_forms.dart +++ b/lib/view/components/search/search_result_page/parts/other_forms.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:unofficial_jisho_api/api.dart'; class OtherForms extends StatelessWidget { - final List _otherForms; - OtherForms(this._otherForms); + final List otherForms; + OtherForms(this.otherForms); @override Widget build(BuildContext context) { @@ -15,7 +15,7 @@ class OtherForms extends StatelessWidget { style: TextStyle(fontWeight: FontWeight.bold), ), Row( - children: _otherForms.map((form) => _KanaBox(form)).toList(), + children: otherForms.map((form) => _KanaBox(form)).toList(), ), ], ), @@ -24,18 +24,18 @@ class OtherForms extends StatelessWidget { } class _KanaBox extends StatelessWidget { - final JishoJapaneseWord _word; - const _KanaBox(this._word); + final JishoJapaneseWord word; + const _KanaBox(this.word); @override Widget build(BuildContext context) { - final hasFurigana = (_word.word != null); + final hasFurigana = (word.word != null); return Container( child: Column( children: [ - (hasFurigana) ? Text(_word.reading) : Text(''), - (hasFurigana) ? Text(_word.word) : Text(_word.reading), + (hasFurigana) ? Text(word.reading) : Text(''), + (hasFurigana) ? Text(word.word) : Text(word.reading), ], ), margin: EdgeInsets.symmetric( diff --git a/lib/view/components/search/search_result_page/parts/senses.dart b/lib/view/components/search/search_result_page/parts/senses.dart index 3d3771d..524bcfb 100644 --- a/lib/view/components/search/search_result_page/parts/senses.dart +++ b/lib/view/components/search/search_result_page/parts/senses.dart @@ -2,24 +2,24 @@ import 'package:flutter/material.dart'; import 'package:unofficial_jisho_api/parser.dart'; class Senses extends StatelessWidget { - final List _senses; - const Senses(this._senses); + final List senses; + const Senses(this.senses); @override Widget build(BuildContext context) { - final List _senseWidgets = - _senses.map((sense) => _Sense(sense)).toList(); + final List senseWidgets = + senses.map((sense) => _Sense(sense)).toList(); return Container( child: Column( - children: _senseWidgets, + children: senseWidgets, )); } } class _Sense extends StatelessWidget { - final JishoWordSense _sense; - const _Sense(this._sense); + final JishoWordSense sense; + const _Sense(this.sense); @override Widget build(BuildContext context) { @@ -27,13 +27,13 @@ class _Sense extends StatelessWidget { child: Column( children: [ Text( - _sense.parts_of_speech.join(', '), + sense.parts_of_speech.join(', '), style: TextStyle(fontWeight: FontWeight.bold), textAlign: TextAlign.left, ), Column( children: - _sense.english_definitions.map((def) => Text(def)).toList(), + sense.english_definitions.map((def) => Text(def)).toList(), ) ], ), diff --git a/lib/view/components/search/search_result_page/search_card.dart b/lib/view/components/search/search_result_page/search_card.dart index 72c9376..88f2b6e 100644 --- a/lib/view/components/search/search_result_page/search_card.dart +++ b/lib/view/components/search/search_result_page/search_card.dart @@ -7,22 +7,22 @@ import './parts/senses.dart'; import './parts/other_forms.dart'; class SearchResultCard extends StatelessWidget { - final JishoResult _result; - JishoJapaneseWord _mainWord; - List _otherForms; + final JishoResult result; + JishoJapaneseWord mainWord; + List otherForms; - SearchResultCard(this._result) { - this._mainWord = _result.japanese[0]; - this._otherForms = _result.japanese.sublist(1); + SearchResultCard(this.result) { + this.mainWord = result.japanese[0]; + this.otherForms = result.japanese.sublist(1); } @override Widget build(BuildContext context) { return ExpansionTile( - title: JapaneseHeader(_mainWord), + title: JapaneseHeader(mainWord), children: [ - Senses(_result.senses), - OtherForms(_otherForms), + Senses(result.senses), + OtherForms(otherForms), ], ); } diff --git a/lib/view/screens/kanji_search.dart b/lib/view/screens/kanji_search.dart index 299d2fb..1950175 100644 --- a/lib/view/screens/kanji_search.dart +++ b/lib/view/screens/kanji_search.dart @@ -76,60 +76,60 @@ class _KanjiTextField extends StatefulWidget { enum TextFieldButton {clear, paste} class _KanjiTextFieldState extends State<_KanjiTextField> { - FocusNode _focus = new FocusNode(); - TextEditingController _textController = new TextEditingController(); - TextFieldButton _button = TextFieldButton.paste; + FocusNode focus = new FocusNode(); + TextEditingController textController = new TextEditingController(); + TextFieldButton button = TextFieldButton.paste; @override void initState() { super.initState(); - _focus.addListener(_onFocusChange); + focus.addListener(_onFocusChange); } void _getKanjiSuggestions(String text) => BlocProvider.of(context).add(GetKanjiSuggestions(text)); - void updateSuggestions() => _getKanjiSuggestions(_textController.text); + void updateSuggestions() => _getKanjiSuggestions(textController.text); void _onFocusChange() { - debugPrint('TextField Focus Changed: ${_focus.hasFocus.toString()}'); + debugPrint('TextField Focus Changed: ${focus.hasFocus.toString()}'); setState(() { - _button = _focus.hasFocus ? TextFieldButton.clear : TextFieldButton.paste; + button = focus.hasFocus ? TextFieldButton.clear : TextFieldButton.paste; }); - if (_focus.hasFocus) + if (focus.hasFocus) updateSuggestions(); else FocusScope.of(context).unfocus(); } void _clearText() { - _textController.text = ''; + textController.text = ''; updateSuggestions(); } void _pasteText() async { ClipboardData clipboardData = await Clipboard.getData('text/plain'); - _textController.text = clipboardData.text; + textController.text = clipboardData.text; updateSuggestions(); } @override Widget build(BuildContext context) { - IconButton _clearButton = IconButton( + IconButton clearButton = IconButton( icon: Icon(Icons.clear), onPressed: () => _clearText(), ); - IconButton _pasteButton = IconButton( + IconButton pasteButton = IconButton( icon: Icon(Icons.content_paste), onPressed: () => _pasteText(), ); return TextField( - focusNode: _focus, - controller: _textController, + focusNode: focus, + controller: textController, onChanged: (text) => _getKanjiSuggestions(text), onSubmitted: (text) => BlocProvider.of(context).add(GetKanji(text)), @@ -143,7 +143,7 @@ class _KanjiTextFieldState extends State<_KanjiTextField> { ), contentPadding: EdgeInsets.symmetric(vertical: 10.0), isDense: false, - suffixIcon: (_button == TextFieldButton.clear) ? _clearButton : _pasteButton, + suffixIcon: (button == TextFieldButton.clear) ? clearButton : pasteButton, ), style: TextStyle( fontSize: 14.0, From f1ab914ce3db3a8aceeb338707559a83028d1693 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 3 Mar 2021 12:47:35 +0100 Subject: [PATCH 06/14] Fix kanji icon --- lib/main.dart | 7 +++---- pubspec.yaml | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5147f3c..d7d7089 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:mdi/mdi.dart'; + import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart'; import 'package:jisho_study_tool/view/screens/kanji_search.dart'; import 'package:jisho_study_tool/view/screens/history.dart'; @@ -68,10 +70,7 @@ final List navBar = [ ), BottomNavigationBarItem( label: 'Kanji', - icon: Text( - '漢', - style: TextStyle(fontSize: 18), - ), + icon: Icon(Mdi.ideogramCjk, size: 30,) ), BottomNavigationBarItem( label: 'History', diff --git a/pubspec.yaml b/pubspec.yaml index 99c2478..39f9739 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: sdk: flutter # cupertino_icons: ^0.1.2 + mdi: ^3.0.0 unofficial_jisho_api: ^1.1.0 flutter_bloc: ^6.1.0 url_launcher: ^5.5.0 From 16d636b45974cc68f83720ab8dfd229f2b41f13b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 3 Mar 2021 12:47:59 +0100 Subject: [PATCH 07/14] Update README --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7827e81..318f590 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,17 @@ A japanese dictionary with features for making studying the language easier. ## Search -Standard search using Jishos own API. This returns standard Jisho search results, including what you'd find if you searched for something through the standard jisho search bar without any #modifiers +Standard search using Jishos API. This returns standard Jisho search results, including what you'd find if you searched through the search bar without any modifiers ## Kanji Search -Standard kanji search using the #kanji modifier. This will give you detailed information about things like drawing order, radicals, different kinds of ranks and statistics and some onyomi and kunyomi example words. +Jisho kanji search just like using the #kanji modifier in the jisho search bar. This will give you detailed information about things like drawing order, radicals, different kinds of ranks and statistics and some onyomi and kunyomi example words. ## Upcoming Features -* Different kinds of kanji input like radicals and grade based lists -* Favorites, history and custom lists -* Anki export -* Memo cards -* Cloud sync -* Dark theme + - [ ] Different kinds of kanji input like radicals and grade based lists + - [ ] Favorites, history and custom lists + - [ ] Anki export + - [ ] Memo cards + - [ ] Cloud sync + - [ ] Dark theme From ef41b50f0d1feab4ecc0261370f0e7aeac456f93 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 00:38:19 +0100 Subject: [PATCH 08/14] Add shared_preferences --- pubspec.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pubspec.yaml b/pubspec.yaml index 39f9739..94436e7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,6 +9,8 @@ dependencies: flutter: sdk: flutter + shared_preferences: "^2.0.3" + # cupertino_icons: ^0.1.2 mdi: ^3.0.0 unofficial_jisho_api: ^1.1.0 From 2476d2958db0dde67c448e644c530783d114d86b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 00:38:35 +0100 Subject: [PATCH 09/14] Make LanguageSelector choice persistent --- .../components/search/LanguageSelector.dart | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/view/components/search/LanguageSelector.dart b/lib/view/components/search/LanguageSelector.dart index 66ce133..3f176cc 100644 --- a/lib/view/components/search/LanguageSelector.dart +++ b/lib/view/components/search/LanguageSelector.dart @@ -1,5 +1,5 @@ - import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class LanguageSelector extends StatefulWidget { @override @@ -7,12 +7,35 @@ class LanguageSelector extends StatefulWidget { } class _LanguageSelectorState extends State { + SharedPreferences prefs; List isSelected; @override void initState() { super.initState(); - isSelected = [true, false, false]; + isSelected = [false, false, false]; + + SharedPreferences.getInstance() + .then((prefs) { + this.prefs = prefs; + setState(() { + isSelected = _getSelectedStatus() ?? isSelected; + }); + }); + } + + void _updateSelectedStatus() async { + await prefs.setStringList('languageSelectorStatus', + isSelected + .map((b) => b ? '1' : '0') + .toList()); + } + + List _getSelectedStatus() { + return prefs + .getStringList('languageSelectorStatus') + ?.map((s) => s == '1') + ?.toList(); } @override @@ -30,6 +53,7 @@ class _LanguageSelectorState extends State { for (var i in Iterable.generate(isSelected.length)) { isSelected[i] = i == buttonIndex; } + _updateSelectedStatus(); }); }, ); @@ -44,11 +68,9 @@ class _LanguageOption extends StatelessWidget { @override Widget build(BuildContext context) { - return Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), - child: Center(child: Text(language)), - ), + return Container( + padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0), + child: Center(child: Text(language)), ); } } \ No newline at end of file From 4f6793c959105560506d67dc2894bfa4c350613b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 22:08:34 +0100 Subject: [PATCH 10/14] Split kanji search bar into component --- .../components/kanji/kanji_search_bar.dart | 88 ++++++++++++++++++ lib/view/screens/kanji_search.dart | 90 +------------------ 2 files changed, 91 insertions(+), 87 deletions(-) create mode 100644 lib/view/components/kanji/kanji_search_bar.dart diff --git a/lib/view/components/kanji/kanji_search_bar.dart b/lib/view/components/kanji/kanji_search_bar.dart new file mode 100644 index 0000000..1e94bfe --- /dev/null +++ b/lib/view/components/kanji/kanji_search_bar.dart @@ -0,0 +1,88 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart'; + +class KanjiSearchBar extends StatefulWidget { + @override + _KanjiSearchBarState createState() => new _KanjiSearchBarState(); +} + +enum TextFieldButton {clear, paste} + +class _KanjiSearchBarState extends State { + FocusNode focus = new FocusNode(); + TextEditingController textController = new TextEditingController(); + TextFieldButton button = TextFieldButton.paste; + + @override + void initState() { + super.initState(); + focus.addListener(_onFocusChange); + } + + void _getKanjiSuggestions(String text) => + BlocProvider.of(context).add(GetKanjiSuggestions(text)); + + void updateSuggestions() => _getKanjiSuggestions(textController.text); + + void _onFocusChange() { + debugPrint('TextField Focus Changed: ${focus.hasFocus.toString()}'); + + setState(() { + button = focus.hasFocus ? TextFieldButton.clear : TextFieldButton.paste; + }); + + if (focus.hasFocus) + updateSuggestions(); + else + FocusScope.of(context).unfocus(); + } + + void _clearText() { + textController.text = ''; + updateSuggestions(); + } + + void _pasteText() async { + ClipboardData clipboardData = await Clipboard.getData('text/plain'); + textController.text = clipboardData.text; + updateSuggestions(); + } + + @override + Widget build(BuildContext context) { + IconButton clearButton = IconButton( + icon: Icon(Icons.clear), + onPressed: () => _clearText(), + ); + + IconButton pasteButton = IconButton( + icon: Icon(Icons.content_paste), + onPressed: () => _pasteText(), + ); + + return TextField( + focusNode: focus, + controller: textController, + onChanged: (text) => _getKanjiSuggestions(text), + onSubmitted: (text) => + BlocProvider.of(context).add(GetKanji(text)), + decoration: new InputDecoration( + prefixIcon: Icon(Icons.search), + hintText: 'Search for kanji', + fillColor: Colors.white, + filled: true, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(100.0), + ), + contentPadding: EdgeInsets.symmetric(vertical: 10.0), + isDense: false, + suffixIcon: (button == TextFieldButton.clear) ? clearButton : pasteButton, + ), + style: TextStyle( + fontSize: 14.0, + ), + ); + } +} \ No newline at end of file diff --git a/lib/view/screens/kanji_search.dart b/lib/view/screens/kanji_search.dart index 1950175..91cacb4 100644 --- a/lib/view/screens/kanji_search.dart +++ b/lib/view/screens/kanji_search.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.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_search_bar.dart'; import 'package:jisho_study_tool/view/components/kanji/kanji_search_result_page/kanji_search_result_page.dart'; import 'package:jisho_study_tool/view/components/kanji/kanji_search_suggestion_list/kanji_search_suggestion_list.dart'; import 'package:jisho_study_tool/view/screens/loading.dart'; @@ -51,7 +51,7 @@ class KanjiViewBar extends StatelessWidget { ), Expanded( child: Container( - child: _KanjiTextField(), + child: KanjiSearchBar(), ), ), IconButton( @@ -66,88 +66,4 @@ class KanjiViewBar extends StatelessWidget { ), ); } -} - -class _KanjiTextField extends StatefulWidget { - @override - _KanjiTextFieldState createState() => new _KanjiTextFieldState(); -} - -enum TextFieldButton {clear, paste} - -class _KanjiTextFieldState extends State<_KanjiTextField> { - FocusNode focus = new FocusNode(); - TextEditingController textController = new TextEditingController(); - TextFieldButton button = TextFieldButton.paste; - - @override - void initState() { - super.initState(); - focus.addListener(_onFocusChange); - } - - void _getKanjiSuggestions(String text) => - BlocProvider.of(context).add(GetKanjiSuggestions(text)); - - void updateSuggestions() => _getKanjiSuggestions(textController.text); - - void _onFocusChange() { - debugPrint('TextField Focus Changed: ${focus.hasFocus.toString()}'); - - setState(() { - button = focus.hasFocus ? TextFieldButton.clear : TextFieldButton.paste; - }); - - if (focus.hasFocus) - updateSuggestions(); - else - FocusScope.of(context).unfocus(); - } - - void _clearText() { - textController.text = ''; - updateSuggestions(); - } - - void _pasteText() async { - ClipboardData clipboardData = await Clipboard.getData('text/plain'); - textController.text = clipboardData.text; - updateSuggestions(); - } - - @override - Widget build(BuildContext context) { - IconButton clearButton = IconButton( - icon: Icon(Icons.clear), - onPressed: () => _clearText(), - ); - - IconButton pasteButton = IconButton( - icon: Icon(Icons.content_paste), - onPressed: () => _pasteText(), - ); - - return TextField( - focusNode: focus, - controller: textController, - onChanged: (text) => _getKanjiSuggestions(text), - onSubmitted: (text) => - BlocProvider.of(context).add(GetKanji(text)), - decoration: new InputDecoration( - prefixIcon: Icon(Icons.search), - hintText: 'Search for kanji', - fillColor: Colors.white, - filled: true, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(100.0), - ), - contentPadding: EdgeInsets.symmetric(vertical: 10.0), - isDense: false, - suffixIcon: (button == TextFieldButton.clear) ? clearButton : pasteButton, - ), - style: TextStyle( - fontSize: 14.0, - ), - ); - } -} +} \ No newline at end of file From f76f0011add026920e5942a13762d37b76b18064 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 22:12:04 +0100 Subject: [PATCH 11/14] Split search bar into component --- lib/view/components/search/search_bar.dart | 32 +++++++++++++++++++++ lib/view/screens/search.dart | 33 ++-------------------- 2 files changed, 34 insertions(+), 31 deletions(-) create mode 100644 lib/view/components/search/search_bar.dart diff --git a/lib/view/components/search/search_bar.dart b/lib/view/components/search/search_bar.dart new file mode 100644 index 0000000..3378b40 --- /dev/null +++ b/lib/view/components/search/search_bar.dart @@ -0,0 +1,32 @@ +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'; + +class SearchBar extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 20.0), + child: Column( + children: [ + TextField( + onSubmitted: (text) => BlocProvider.of(context) + .add(GetSearchResults(text)), + controller: TextEditingController(), + decoration: InputDecoration( + labelText: 'Search', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + ), + ), + ), + SizedBox( + height: 10.0, + ), + LanguageSelector() + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/view/screens/search.dart b/lib/view/screens/search.dart index 23a7dd7..e4e47ad 100644 --- a/lib/view/screens/search.dart +++ b/lib/view/screens/search.dart @@ -1,7 +1,7 @@ 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/search_bar.dart'; import 'package:jisho_study_tool/view/screens/loading.dart'; import 'package:jisho_study_tool/view/components/search/search_result_page/search_card.dart'; @@ -44,33 +44,4 @@ class _InitialView extends StatelessWidget { SearchBar(), ]); } -} - - -class SearchBar extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(horizontal: 20.0), - child: Column( - children: [ - TextField( - onSubmitted: (text) => BlocProvider.of(context) - .add(GetSearchResults(text)), - controller: TextEditingController(), - decoration: InputDecoration( - labelText: 'Search', - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0), - ), - ), - ), - SizedBox( - height: 10.0, - ), - LanguageSelector() - ], - ), - ); - } -} +} \ No newline at end of file From f89724906bb61dd8b6b501209b7f32b2dd2a8df9 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 22:39:28 +0100 Subject: [PATCH 12/14] Correct a formatting error --- lib/main.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index d7d7089..e26b8f6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -97,7 +97,10 @@ class _Page { } final List<_Page> pages = [ - _Page(content: SearchView(), titleBar: Text('Search')), + _Page( + content: SearchView(), + titleBar: Text('Search'), + ), _Page( content: KanjiView(), titleBar: KanjiViewBar(), From 4dfb42f4b693de91eddecb5e2cb7e81a83139118 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 22:39:43 +0100 Subject: [PATCH 13/14] Move theme files to models --- lib/{view => models}/themes/dark.dart | 0 lib/{view => models}/themes/light.dart | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename lib/{view => models}/themes/dark.dart (100%) rename lib/{view => models}/themes/light.dart (100%) diff --git a/lib/view/themes/dark.dart b/lib/models/themes/dark.dart similarity index 100% rename from lib/view/themes/dark.dart rename to lib/models/themes/dark.dart diff --git a/lib/view/themes/light.dart b/lib/models/themes/light.dart similarity index 100% rename from lib/view/themes/light.dart rename to lib/models/themes/light.dart From a179efc71095ca836f7a0b0fab41eb74133476af Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Mar 2021 22:40:20 +0100 Subject: [PATCH 14/14] Fix search bug where header would be null --- .../components/search/search_result_page/parts/header.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/view/components/search/search_result_page/parts/header.dart b/lib/view/components/search/search_result_page/parts/header.dart index ca8d377..554000f 100644 --- a/lib/view/components/search/search_result_page/parts/header.dart +++ b/lib/view/components/search/search_result_page/parts/header.dart @@ -7,7 +7,7 @@ class JapaneseHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final hasFurigana = (word.word != null); + final hasFurigana = (word.word != null && word.reading != null); return Container( alignment: Alignment.centerLeft, @@ -15,7 +15,7 @@ class JapaneseHeader extends StatelessWidget { child: Column( children: [ (hasFurigana) ? Text(word.reading) : Text(''), - (hasFurigana) ? Text(word.word) : Text(word.reading), + (hasFurigana) ? Text(word.word) : Text(word.reading ?? word.word), ], ), );