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,