Update to null safety
This commit is contained in:
parent
b86e0ae2f2
commit
d82fcbe427
|
@ -30,6 +30,8 @@
|
|||
.pub/
|
||||
/build/
|
||||
|
||||
objectbox.g.dart
|
||||
|
||||
# Web related
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class KanjiSearchFinished extends KanjiState {
|
|||
final bool starred;
|
||||
|
||||
const KanjiSearchFinished({
|
||||
this.kanji,
|
||||
required this.kanji,
|
||||
this.starred = false,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class SearchBloc extends Bloc<SearchEvent, SearchState> {
|
|||
try {
|
||||
addSearchToDB(event.searchString);
|
||||
final searchResults = await fetchJishoResults(event.searchString);
|
||||
if (searchResults.meta.status == 200) yield SearchFinished(searchResults.data);
|
||||
if (searchResults.meta.status == 200) yield SearchFinished(searchResults.data!);
|
||||
} on Exception {
|
||||
yield SearchError('Something went wrong');
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import 'package:path_provider/path_provider.dart';
|
|||
import 'package:path/path.dart';
|
||||
import 'package:jisho_study_tool/objectbox.g.dart';
|
||||
|
||||
import 'package:jisho_study_tool/bloc/search/search_bloc.dart';
|
||||
import 'package:jisho_study_tool/bloc/database/database_bloc.dart';
|
||||
import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart';
|
||||
import 'package:jisho_study_tool/bloc/search/search_bloc.dart';
|
||||
|
||||
import 'package:jisho_study_tool/view/screens/kanji/view.dart';
|
||||
import 'package:jisho_study_tool/view/screens/history.dart';
|
||||
|
@ -46,7 +46,7 @@ class Home extends StatefulWidget {
|
|||
class _HomeState extends State<Home> {
|
||||
int selectedPage = 0;
|
||||
|
||||
Store _store;
|
||||
late final Store _store;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -136,8 +136,8 @@ class _Page {
|
|||
Widget titleBar;
|
||||
|
||||
_Page({
|
||||
this.content,
|
||||
this.titleBar,
|
||||
required this.content,
|
||||
required this.titleBar,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ class KanjiResult {
|
|||
String kanji;
|
||||
|
||||
KanjiResult({
|
||||
this.timestamp,
|
||||
this.kanji,
|
||||
required this.timestamp,
|
||||
required this.kanji,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
|
@ -15,8 +15,8 @@ class SearchString {
|
|||
final chosenResults = ToMany<WordResult>();
|
||||
|
||||
SearchString({
|
||||
this.timestamp,
|
||||
this.query,
|
||||
required this.timestamp,
|
||||
required this.query,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
|
@ -14,8 +14,8 @@ class WordResult {
|
|||
final searchString = ToOne<SearchString>();
|
||||
|
||||
WordResult({
|
||||
this.timestamp,
|
||||
this.word,
|
||||
required this.timestamp,
|
||||
required this.word,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
import 'package:objectbox/objectbox.dart';
|
||||
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||
// import 'package:objectbox/objectbox.dart';
|
||||
// import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||
|
||||
@Entity()
|
||||
class SearchResult {
|
||||
int id = 0;
|
||||
final meta = ToOne<JishoResultMeta>();
|
||||
final data = ToMany<JishoResult>();
|
||||
// @Entity()
|
||||
// class SearchResult {
|
||||
// int id = 0;
|
||||
// final meta = ToOne<JishoResultMeta>();
|
||||
// final data = ToMany<JishoResult>();
|
||||
|
||||
// SearchResult(JishoAPIResult result) {
|
||||
// this.data = result.data;
|
||||
// this.meta = result.meta;
|
||||
// }
|
||||
// // SearchResult(JishoAPIResult result) {
|
||||
// // this.data = result.data;
|
||||
// // this.meta = result.meta;
|
||||
// // }
|
||||
|
||||
// JishoAPIResult toJishoAPIResult() {
|
||||
// return JishoAPIResult(meta: this.meta, data: this.data);
|
||||
// }
|
||||
}
|
||||
// // JishoAPIResult toJishoAPIResult() {
|
||||
// // return JishoAPIResult(meta: this.meta, data: this.data);
|
||||
// // }
|
||||
// }
|
||||
|
||||
@Entity()
|
||||
class JishoResultMeta {
|
||||
int id = 0;
|
||||
int status;
|
||||
}
|
||||
// @Entity()
|
||||
// class JishoResultMeta {
|
||||
// int id = 0;
|
||||
// int status;
|
||||
// }
|
||||
|
||||
@Entity()
|
||||
class JishoResult {
|
||||
int id = 0;
|
||||
final attribution = ToOne<JishoAttribution>();
|
||||
bool is_common;
|
||||
final japanese = ToMany<JishoJapaneseWord>();
|
||||
List<String> jlpt;
|
||||
final senses = ToMany<JishoWordSense>();
|
||||
String slug;
|
||||
List<String> tags;
|
||||
}
|
||||
// @Entity()
|
||||
// class JishoResult {
|
||||
// int id = 0;
|
||||
// final attribution = ToOne<JishoAttribution>();
|
||||
// bool is_common;
|
||||
// final japanese = ToMany<JishoJapaneseWord>();
|
||||
// List<String> jlpt;
|
||||
// final senses = ToMany<JishoWordSense>();
|
||||
// String slug;
|
||||
// List<String> tags;
|
||||
// }
|
||||
|
||||
@Entity()
|
||||
class JishoAttribution {
|
||||
int id = 0;
|
||||
String dbpedia;
|
||||
String jmdict;
|
||||
bool jmnedict;
|
||||
}
|
||||
// @Entity()
|
||||
// class JishoAttribution {
|
||||
// int id = 0;
|
||||
// String dbpedia;
|
||||
// String jmdict;
|
||||
// bool jmnedict;
|
||||
// }
|
||||
|
||||
@Entity()
|
||||
class JishoJapaneseWord {
|
||||
int id = 0;
|
||||
String reading;
|
||||
String word;
|
||||
}
|
||||
// @Entity()
|
||||
// class JishoJapaneseWord {
|
||||
// int id = 0;
|
||||
// String reading;
|
||||
// String word;
|
||||
// }
|
||||
|
||||
@Entity()
|
||||
class JishoWordSense {
|
||||
int id = 0;
|
||||
List<String> antonyms;
|
||||
List<String> english_definitions;
|
||||
List<String> info;
|
||||
final links = ToMany<JishoSenseLink>();
|
||||
List<String> parts_of_speech;
|
||||
List<String> restrictions;
|
||||
List<String> see_also;
|
||||
List<dynamic> source;
|
||||
List<String> tags;
|
||||
}
|
||||
// @Entity()
|
||||
// class JishoWordSense {
|
||||
// int id = 0;
|
||||
// List<String> antonyms;
|
||||
// List<String> english_definitions;
|
||||
// List<String> info;
|
||||
// final links = ToMany<JishoSenseLink>();
|
||||
// List<String> parts_of_speech;
|
||||
// List<String> restrictions;
|
||||
// List<String> see_also;
|
||||
// List<dynamic> source;
|
||||
// List<String> tags;
|
||||
// }
|
||||
|
||||
@Entity()
|
||||
class JishoSenseLink {
|
||||
int id = 0;
|
||||
String text;
|
||||
String url;
|
||||
}
|
||||
// @Entity()
|
||||
// class JishoSenseLink {
|
||||
// int id = 0;
|
||||
// String text;
|
||||
// String url;
|
||||
// }
|
||||
|
|
|
@ -4,255 +4,23 @@
|
|||
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
|
||||
"entities": [
|
||||
{
|
||||
"id": "3:7851566044119418641",
|
||||
"lastPropertyId": "4:2352718426928758061",
|
||||
"name": "JishoAttribution",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:9162407962473480509",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:708495477684386",
|
||||
"name": "dbpedia",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "3:6579248575703756688",
|
||||
"name": "jmdict",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "4:2352718426928758061",
|
||||
"name": "jmnedict",
|
||||
"type": 1
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
},
|
||||
{
|
||||
"id": "4:5830034738494786681",
|
||||
"lastPropertyId": "3:1420686825377652298",
|
||||
"name": "JishoJapaneseWord",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:5568051277997102473",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:8794655557751948952",
|
||||
"name": "reading",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "3:1420686825377652298",
|
||||
"name": "word",
|
||||
"type": 9
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
},
|
||||
{
|
||||
"id": "5:814015574151442186",
|
||||
"lastPropertyId": "6:5908719510010444548",
|
||||
"name": "JishoResult",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:4779715838063307925",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:398633124413531447",
|
||||
"name": "attributionId",
|
||||
"type": 11,
|
||||
"flags": 520,
|
||||
"indexId": "1:3741479335507224998",
|
||||
"relationTarget": "JishoAttribution"
|
||||
},
|
||||
{
|
||||
"id": "3:3743357097628620453",
|
||||
"name": "is_common",
|
||||
"type": 1
|
||||
},
|
||||
{
|
||||
"id": "4:2403901886209575067",
|
||||
"name": "jlpt",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "5:9147057123672087105",
|
||||
"name": "slug",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "6:5908719510010444548",
|
||||
"name": "tags",
|
||||
"type": 30
|
||||
}
|
||||
],
|
||||
"relations": [
|
||||
{
|
||||
"id": "1:1762405519516054052",
|
||||
"name": "japanese",
|
||||
"targetId": "4:5830034738494786681"
|
||||
},
|
||||
{
|
||||
"id": "2:5662556255405307520",
|
||||
"name": "senses",
|
||||
"targetId": "8:7499450265299287403"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "6:6175990861942758315",
|
||||
"lastPropertyId": "2:6228403848602783530",
|
||||
"name": "JishoResultMeta",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:2609861734144336951",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:6228403848602783530",
|
||||
"name": "status",
|
||||
"type": 6
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
},
|
||||
{
|
||||
"id": "7:8388739279951258717",
|
||||
"lastPropertyId": "3:6475272726803052671",
|
||||
"name": "JishoSenseLink",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:9038298290884158108",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:3536322409202325005",
|
||||
"name": "text",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "3:6475272726803052671",
|
||||
"name": "url",
|
||||
"type": 9
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
},
|
||||
{
|
||||
"id": "8:7499450265299287403",
|
||||
"lastPropertyId": "8:8987388154341761734",
|
||||
"name": "JishoWordSense",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:3215440847258041904",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:2015550844387658352",
|
||||
"name": "antonyms",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "3:5828592811743363528",
|
||||
"name": "english_definitions",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "4:5593994833762859570",
|
||||
"name": "info",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "5:2972516533060921751",
|
||||
"name": "parts_of_speech",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "6:116167531949398184",
|
||||
"name": "restrictions",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "7:5268205144755091970",
|
||||
"name": "see_also",
|
||||
"type": 30
|
||||
},
|
||||
{
|
||||
"id": "8:8987388154341761734",
|
||||
"name": "tags",
|
||||
"type": 30
|
||||
}
|
||||
],
|
||||
"relations": [
|
||||
{
|
||||
"id": "4:554428283260148269",
|
||||
"name": "links",
|
||||
"targetId": "7:8388739279951258717"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "9:6483665137820532859",
|
||||
"lastPropertyId": "2:8047458152016460696",
|
||||
"name": "SearchResult",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:1744658189464710184",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:8047458152016460696",
|
||||
"name": "metaId",
|
||||
"type": 11,
|
||||
"flags": 520,
|
||||
"indexId": "2:2854883655423126351",
|
||||
"relationTarget": "JishoResultMeta"
|
||||
}
|
||||
],
|
||||
"relations": [
|
||||
{
|
||||
"id": "3:9171394818028481706",
|
||||
"name": "data",
|
||||
"targetId": "5:814015574151442186"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "10:2511293769307589652",
|
||||
"lastPropertyId": "3:7310514284446208088",
|
||||
"id": "1:8135239166970424087",
|
||||
"lastPropertyId": "3:1930470268740402049",
|
||||
"name": "KanjiResult",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:4875831913401260727",
|
||||
"id": "1:2681934095975267680",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:2639524138758004976",
|
||||
"id": "2:4514526257378540330",
|
||||
"name": "timestamp",
|
||||
"type": 10
|
||||
},
|
||||
{
|
||||
"id": "3:7310514284446208088",
|
||||
"id": "3:1930470268740402049",
|
||||
"name": "kanji",
|
||||
"type": 9
|
||||
}
|
||||
|
@ -260,23 +28,23 @@
|
|||
"relations": []
|
||||
},
|
||||
{
|
||||
"id": "11:8718716930258187923",
|
||||
"lastPropertyId": "3:6047999002753663080",
|
||||
"id": "2:461492167249325765",
|
||||
"lastPropertyId": "3:7573103520245228403",
|
||||
"name": "SearchString",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:8056495551508046109",
|
||||
"id": "1:4297905889790758495",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:5805071287032353000",
|
||||
"id": "2:4157902147911002923",
|
||||
"name": "timestamp",
|
||||
"type": 10
|
||||
},
|
||||
{
|
||||
"id": "3:6047999002753663080",
|
||||
"id": "3:7573103520245228403",
|
||||
"name": "query",
|
||||
"type": 9
|
||||
}
|
||||
|
@ -284,56 +52,47 @@
|
|||
"relations": []
|
||||
},
|
||||
{
|
||||
"id": "12:8709403319711854658",
|
||||
"lastPropertyId": "4:4071472200738865726",
|
||||
"id": "3:8314315977756262774",
|
||||
"lastPropertyId": "4:7972948456299367594",
|
||||
"name": "WordResult",
|
||||
"properties": [
|
||||
{
|
||||
"id": "1:2725285997242709614",
|
||||
"id": "1:8286440150679521496",
|
||||
"name": "id",
|
||||
"type": 6,
|
||||
"flags": 1
|
||||
},
|
||||
{
|
||||
"id": "2:6271798504226631398",
|
||||
"id": "2:2698026687178480112",
|
||||
"name": "timestamp",
|
||||
"type": 10
|
||||
},
|
||||
{
|
||||
"id": "3:5467536225310784192",
|
||||
"id": "3:8750782874894963158",
|
||||
"name": "word",
|
||||
"type": 9
|
||||
},
|
||||
{
|
||||
"id": "4:4071472200738865726",
|
||||
"id": "4:7972948456299367594",
|
||||
"name": "searchStringId",
|
||||
"type": 11,
|
||||
"flags": 520,
|
||||
"indexId": "3:5534321127094586184",
|
||||
"indexId": "1:6146948198859733323",
|
||||
"relationTarget": "SearchString"
|
||||
}
|
||||
],
|
||||
"relations": []
|
||||
}
|
||||
],
|
||||
"lastEntityId": "12:8709403319711854658",
|
||||
"lastIndexId": "3:5534321127094586184",
|
||||
"lastRelationId": "4:554428283260148269",
|
||||
"lastEntityId": "3:8314315977756262774",
|
||||
"lastIndexId": "1:6146948198859733323",
|
||||
"lastRelationId": "0:0",
|
||||
"lastSequenceId": "0:0",
|
||||
"modelVersion": 5,
|
||||
"modelVersionParserMinimum": 5,
|
||||
"retiredEntityUids": [
|
||||
2061102273968386021,
|
||||
7471000004971513655
|
||||
],
|
||||
"retiredEntityUids": [],
|
||||
"retiredIndexUids": [],
|
||||
"retiredPropertyUids": [
|
||||
1377817599424560887,
|
||||
182004738902401315,
|
||||
647032929519296287,
|
||||
8448353731705407210,
|
||||
1530573958565295186
|
||||
],
|
||||
"retiredPropertyUids": [],
|
||||
"retiredRelationUids": [],
|
||||
"version": 1
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||
|
||||
String _convertGrade(String grade) {
|
||||
String? _convertGrade(String grade) {
|
||||
const conversionTable = {
|
||||
"grade 1": "小1",
|
||||
"grade 2": "小2",
|
||||
|
@ -16,8 +16,11 @@ String _convertGrade(String grade) {
|
|||
return conversionTable[grade];
|
||||
}
|
||||
|
||||
// TODO: fix this logic
|
||||
|
||||
Future<jisho.KanjiResult> fetchKanji(String kanji) async {
|
||||
final result = await jisho.searchForKanji(kanji);
|
||||
result.taughtIn = _convertGrade(result.taughtIn);
|
||||
if (result.data != null && result.data?.taughtIn != null)
|
||||
result.data!.taughtIn = _convertGrade(result.data!.taughtIn!);
|
||||
return result;
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
final kanjiPattern = RegExp(r'[\u3400-\u4DB5\u4E00-\u9FCB\uF900-\uFA6A]');
|
||||
|
||||
List<String> kanjiSuggestions(String string) {
|
||||
return kanjiPattern.allMatches(string).map((match) => match.group(0)).toList();
|
||||
}
|
||||
return kanjiPattern
|
||||
.allMatches(string)
|
||||
.map((match) => match.group(0))
|
||||
.where((element) => element != null)
|
||||
.map((element) => element!)
|
||||
.toList();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:jisho_study_tool/models/history/kanji_result.dart';
|
|||
class _KanjiSearchItemHeader extends StatelessWidget {
|
||||
final KanjiResult result;
|
||||
|
||||
const _KanjiSearchItemHeader(this.result, {Key key}) : super(key: key);
|
||||
const _KanjiSearchItemHeader(this.result, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -16,7 +16,7 @@ class _KanjiSearchItemHeader extends StatelessWidget {
|
|||
class KanjiSearchItem extends StatelessWidget {
|
||||
final KanjiResult result;
|
||||
|
||||
const KanjiSearchItem(this.result,{Key key}) : super(key: key);
|
||||
const KanjiSearchItem(this.result,{Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:jisho_study_tool/models/history/search_string.dart';
|
|||
class SearchItemHeader extends StatelessWidget {
|
||||
final SearchString _search;
|
||||
|
||||
const SearchItemHeader(this._search, {Key key}) : super(key: key);
|
||||
const SearchItemHeader(this._search, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -18,7 +18,7 @@ class SearchItemHeader extends StatelessWidget {
|
|||
class SearchItem extends StatelessWidget {
|
||||
final SearchString _search;
|
||||
|
||||
const SearchItem(this._search, {Key key}) : super(key: key);
|
||||
const SearchItem(this._search, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -35,9 +35,11 @@ class _KanjiSearchBarState extends State<KanjiSearchBar> {
|
|||
}
|
||||
|
||||
void _pasteText() async {
|
||||
ClipboardData clipboardData = await Clipboard.getData('text/plain');
|
||||
textController.text = clipboardData.text;
|
||||
updateSuggestions();
|
||||
ClipboardData? clipboardData = await Clipboard.getData('text/plain');
|
||||
if (clipboardData != null && clipboardData.text != null) {
|
||||
textController.text = clipboardData.text!;
|
||||
updateSuggestions();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:jisho_study_tool/bloc/kanji/kanji_bloc.dart';
|
|||
//TODO: Make buttons have an effect
|
||||
|
||||
class KanjiSearchOptionsBar extends StatelessWidget {
|
||||
const KanjiSearchOptionsBar({Key key}) : super(key: key);
|
||||
const KanjiSearchOptionsBar({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -42,8 +42,12 @@ class KanjiSearchOptionsBar extends StatelessWidget {
|
|||
|
||||
class _IconButton extends StatelessWidget {
|
||||
final Widget icon;
|
||||
final Function onPressed;
|
||||
const _IconButton({this.icon, this.onPressed, Key key}) : super(key: key);
|
||||
final void Function()? onPressed;
|
||||
const _IconButton({
|
||||
required this.icon,
|
||||
required this.onPressed,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
|||
|
||||
class Kunyomi extends StatelessWidget {
|
||||
final List<String> kunyomi;
|
||||
List<_KunyomiCard> kunyomiCards;
|
||||
bool expandable;
|
||||
late final List<_KunyomiCard> kunyomiCards;
|
||||
late final bool expandable;
|
||||
|
||||
Kunyomi(this.kunyomi) {
|
||||
kunyomiCards = kunyomi.map((kunyomi) => _KunyomiCard(kunyomi)).toList();
|
||||
|
@ -18,11 +18,11 @@ class Kunyomi extends StatelessWidget {
|
|||
vertical: 5.0,
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _KunyomiWrapper(context),
|
||||
child: _kunyomiWrapper(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _KunyomiWrapper(BuildContext context) {
|
||||
Widget _kunyomiWrapper(BuildContext context) {
|
||||
if (expandable) {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: false,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class Meaning extends StatelessWidget {
|
||||
List<String> meanings;
|
||||
List<_MeaningCard> meaningCards;
|
||||
bool expandable;
|
||||
late final List<String> meanings;
|
||||
late final List<_MeaningCard> meaningCards;
|
||||
late final bool expandable;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -13,11 +13,11 @@ class Meaning extends StatelessWidget {
|
|||
vertical: 5.0,
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _MeaningWrapper(context),
|
||||
child: _meaningWrapper(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _MeaningWrapper(BuildContext context) {
|
||||
Widget _meaningWrapper(BuildContext context) {
|
||||
if (expandable) {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: false,
|
||||
|
|
|
@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
|||
|
||||
class Onyomi extends StatelessWidget {
|
||||
final List<String> onyomi;
|
||||
List<_OnyomiCard> onyomiCards;
|
||||
bool expandable;
|
||||
late final List<_OnyomiCard> onyomiCards;
|
||||
late final bool expandable;
|
||||
|
||||
Onyomi(this.onyomi) {
|
||||
onyomiCards = onyomi.map((onyomi) => _OnyomiCard(onyomi)).toList();
|
||||
|
@ -18,11 +18,11 @@ class Onyomi extends StatelessWidget {
|
|||
vertical: 5.0,
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _OnyomiWrapper(context),
|
||||
child: _onyomiWrapper(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _OnyomiWrapper(BuildContext context) {
|
||||
Widget _onyomiWrapper(BuildContext context) {
|
||||
if (expandable) {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: false,
|
||||
|
|
|
@ -7,8 +7,8 @@ class LanguageSelector extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _LanguageSelectorState extends State<LanguageSelector> {
|
||||
SharedPreferences prefs;
|
||||
List<bool> isSelected;
|
||||
late final SharedPreferences prefs;
|
||||
late List<bool> isSelected;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -31,11 +31,11 @@ class _LanguageSelectorState extends State<LanguageSelector> {
|
|||
.toList());
|
||||
}
|
||||
|
||||
List<bool> _getSelectedStatus() {
|
||||
List<bool>? _getSelectedStatus() {
|
||||
return prefs
|
||||
.getStringList('languageSelectorStatus')
|
||||
?.map((s) => s == '1')
|
||||
?.toList();
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -4,9 +4,7 @@ import 'package:jisho_study_tool/view/components/search/search_result_page/parts
|
|||
class CommonBadge extends StatelessWidget {
|
||||
bool isCommon;
|
||||
|
||||
CommonBadge(this.isCommon) {
|
||||
this.isCommon ??= false;
|
||||
}
|
||||
CommonBadge(this.isCommon);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -14,8 +14,9 @@ class JapaneseHeader extends StatelessWidget {
|
|||
padding: EdgeInsets.only(left: 10.0),
|
||||
child: Column(
|
||||
children: [
|
||||
(hasFurigana) ? Text(word.reading) : Text(''),
|
||||
(hasFurigana) ? Text(word.word) : Text(word.reading ?? word.word),
|
||||
// TODO: take a look at this logic
|
||||
(hasFurigana) ? Text(word.reading!) : Text(''),
|
||||
(hasFurigana) ? Text(word.word!) : Text(word.reading ?? word.word!),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -37,8 +37,9 @@ class _KanaBox extends StatelessWidget {
|
|||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
(hasFurigana) ? Text(word.reading) : Text(''),
|
||||
(hasFurigana) ? Text(word.word) : Text(word.reading),
|
||||
// TODO: take a look at this logic
|
||||
(hasFurigana) ? Text(word.reading ?? '') : Text(''),
|
||||
(hasFurigana) ? Text(word.word!) : Text(word.reading ?? ''),
|
||||
],
|
||||
),
|
||||
margin: EdgeInsets.symmetric(
|
||||
|
|
|
@ -35,7 +35,7 @@ class _Sense extends StatelessWidget {
|
|||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
Text(
|
||||
sense.parts_of_speech.join(', '),
|
||||
sense.partsOfSpeech.join(', '),
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
|
@ -46,7 +46,7 @@ class _Sense extends StatelessWidget {
|
|||
children:[
|
||||
Column(
|
||||
children:
|
||||
sense.english_definitions.map((def) => Text(def)).toList(),
|
||||
sense.englishDefinitions.map((def) => Text(def)).toList(),
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -11,8 +11,8 @@ import './parts/other_forms.dart';
|
|||
|
||||
class SearchResultCard extends StatelessWidget {
|
||||
final JishoResult result;
|
||||
JishoJapaneseWord mainWord;
|
||||
List<JishoJapaneseWord> otherForms;
|
||||
late final JishoJapaneseWord mainWord;
|
||||
late final List<JishoJapaneseWord> otherForms;
|
||||
|
||||
SearchResultCard(this.result) {
|
||||
this.mainWord = result.japanese[0];
|
||||
|
@ -31,7 +31,7 @@ class SearchResultCard extends StatelessWidget {
|
|||
children: [
|
||||
WKBadge(result.tags.firstWhere((tag) => tag.contains("wanikani"), orElse: () => '')),
|
||||
JLPTBadge(result.jlpt.isNotEmpty ? result.jlpt[0] : ''),
|
||||
CommonBadge(result.is_common)
|
||||
CommonBadge(result.isCommon!)
|
||||
],
|
||||
)
|
||||
],
|
||||
|
|
|
@ -15,7 +15,8 @@ import 'package:jisho_study_tool/view/components/kanji/result/kunyomi.dart';
|
|||
import 'package:jisho_study_tool/view/components/kanji/result/examples.dart';
|
||||
|
||||
class KanjiResultCard extends StatelessWidget {
|
||||
final jisho.KanjiResult result;
|
||||
late final String query;
|
||||
late final jisho.KanjiResultData resultData;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -34,26 +35,26 @@ class KanjiResultCard extends StatelessWidget {
|
|||
Flexible(
|
||||
flex: 1,
|
||||
fit: FlexFit.tight,
|
||||
child: Center(child: Header(result.query)),
|
||||
child: Center(child: Header(query)),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
fit: FlexFit.tight,
|
||||
child: Center(
|
||||
child: Radical(result.radical),
|
||||
child: (resultData.radical != null) ? Radical(resultData.radical!) : SizedBox(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Meaning(result.meaning),
|
||||
result.onyomi.length != 0 ? Onyomi(result.onyomi) : SizedBox.shrink(),
|
||||
result.kunyomi.length != 0 ? Kunyomi(result.kunyomi) : SizedBox.shrink(),
|
||||
Meaning(resultData.meaning),
|
||||
resultData.onyomi.length != 0 ? Onyomi(resultData.onyomi) : SizedBox.shrink(),
|
||||
resultData.kunyomi.length != 0 ? Kunyomi(resultData.kunyomi) : SizedBox.shrink(),
|
||||
IntrinsicHeight(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
StrokeOrderGif(result.strokeOrderGifUri),
|
||||
StrokeOrderGif(resultData.strokeOrderGifUri),
|
||||
Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
|
@ -62,19 +63,19 @@ class KanjiResultCard extends StatelessWidget {
|
|||
Row(
|
||||
children: [
|
||||
Text("JLPT: ", style: TextStyle(fontSize: 20.0)),
|
||||
JlptLevel(result.jlptLevel ?? "⨉"),
|
||||
JlptLevel(resultData.jlptLevel ?? "⨉"),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Grade: ", style: TextStyle(fontSize: 20.0)),
|
||||
Grade(result.taughtIn ?? "⨉"),
|
||||
Grade(resultData.taughtIn ?? "⨉"),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text("Rank: ", style: TextStyle(fontSize: 20.0)),
|
||||
Rank(result.newspaperFrequencyRank ?? -1),
|
||||
Rank(resultData.newspaperFrequencyRank ?? -1),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@ -83,10 +84,19 @@ class KanjiResultCard extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
Examples(result.onyomiExamples, result.kunyomiExamples),
|
||||
Examples(resultData.onyomiExamples, resultData.kunyomiExamples),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
KanjiResultCard(this.result);
|
||||
KanjiResultCard({required jisho.KanjiResult result}) {
|
||||
|
||||
query = result.query;
|
||||
|
||||
// TODO: Handle this kind of exception before widget is initialized
|
||||
if (result.data == null)
|
||||
throw Exception();
|
||||
|
||||
resultData = result.data!;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ import 'package:jisho_study_tool/view/components/kanji/kanji_search_bar.dart';
|
|||
import 'package:jisho_study_tool/view/components/kanji/kanji_search_options_bar.dart';
|
||||
|
||||
class SearchScreen extends StatefulWidget {
|
||||
SearchScreen({Key key}) : super(key: key);
|
||||
SearchScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_SearchScreenState createState() => _SearchScreenState();
|
||||
|
@ -16,8 +16,8 @@ class SearchScreen extends StatefulWidget {
|
|||
|
||||
class _SearchScreenState extends State<SearchScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
Animation _searchbarMovementAnimation;
|
||||
late final AnimationController _controller;
|
||||
late final Animation _searchbarMovementAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -28,7 +28,7 @@ class KanjiView extends StatelessWidget {
|
|||
else if (state is KanjiSearchLoading) return LoadingScreen();
|
||||
else if (state is KanjiSearchFinished)
|
||||
return WillPopScope(
|
||||
child: KanjiResultCard(state.kanji),
|
||||
child: KanjiResultCard(result: state.kanji),
|
||||
onWillPop: () async {
|
||||
BlocProvider.of<KanjiBloc>(context)
|
||||
.add(ReturnToInitialState());
|
||||
|
|
26
pubspec.yaml
26
pubspec.yaml
|
@ -1,31 +1,31 @@
|
|||
name: jisho_study_tool
|
||||
description: A new Flutter project.
|
||||
description: A dictionary app for studying japanese
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
animated_size_and_fade: ^2.0.0
|
||||
division: ^0.9.0
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
shared_preferences: "^2.0.3"
|
||||
flutter_bloc: ^7.0.1
|
||||
flutter_slidable: ^0.6.0
|
||||
mdi: ^5.0.0-nullsafety.0
|
||||
objectbox: ^1.1.1
|
||||
objectbox_flutter_libs: any
|
||||
objectbox_flutter_libs: ^1.1.1
|
||||
path_provider: ^2.0.2
|
||||
shared_preferences: ^2.0.6
|
||||
unofficial_jisho_api: ^2.0.2
|
||||
url_launcher: ^6.0.9
|
||||
|
||||
# cupertino_icons: ^0.1.2
|
||||
mdi: ^4.0.0
|
||||
unofficial_jisho_api: ^1.1.0
|
||||
flutter_bloc: ^7.0.0
|
||||
url_launcher: ^6.0.3
|
||||
division: ^0.8.8
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.0.6
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
build_runner: ^1.0.0
|
||||
objectbox_generator: any
|
||||
objectbox_generator: ^1.1.1
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
|
Loading…
Reference in New Issue