From d280f62c9f8720ebd8edf9d2994d0ebe06985863 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 2 Mar 2021 22:26:59 +0100 Subject: [PATCH] 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