diff --git a/lib/main.dart b/lib/main.dart index df61b27..44a0580 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -215,7 +215,6 @@ class _MyHomePageState extends State { } } catch (_) {} setState(() { - _hatsuonCache[item['idex']] = url; item['loading'] = false; }); } @@ -243,7 +242,6 @@ class _MyHomePageState extends State { url = 'https://audio00.forvo.com/ogg/$match'; } } catch (_) {} - _hatsuonCache[item['idex']] = url; } if (url != null && url.isNotEmpty) { setState(() { @@ -256,10 +254,11 @@ class _MyHomePageState extends State { await player.setFilePath(file.path); player.play(); } catch (_) {} - setState(() { - item['loading'] = false; - }); } + setState(() { + _hatsuonCache[item['idex']] = url; + item['loading'] = false; + }); } _cpListener() async { @@ -342,16 +341,42 @@ class _MyHomePageState extends State { ), ), ), - IconButton( - padding: const EdgeInsets.only(bottom: 8.0), - icon: const Icon( - BootstrapIcons.sort_down_alt, - color: Colors.white, - ), - onPressed: () { - _search(1); - }, - ) + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: SizedBox( + width: 48, + height: 48, + child: InkWell( + onTap: () { + _search(-1); + }, + onLongPress: () => showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: const Text('頻度コントロール'), + content: TextField( + onChanged: (value) { + int v = 0; + try { + v = int.parse(value); + assert(v > 0); + } catch (_) {} + setState(() { + _searchMode = v; + }); + }, + decoration: const InputDecoration( + hintText: "基準頻度(正整数)"), + ), + ); + }), + child: Ink( + child: const Icon( + BootstrapIcons.sort_down_alt, + color: Colors.white, + )), + ))) ], ), ), @@ -393,8 +418,9 @@ class _MyHomePageState extends State { 'SELECT tt.word,tt.yomikata,tt.pitchData,' 'tt.origForm,tt.freqRank,tt.idex,tt.romaji,imis.imi,imis.orig ' 'FROM (imis JOIN (SELECT * FROM jpdc ' - 'WHERE $searchField MATCH "${snapshot.data}*" OR r$searchField ' - 'MATCH "${String.fromCharCodes(snapshot.data.runes.toList().reversed)}*" ' + 'WHERE ($searchField MATCH "${snapshot.data}*" OR r$searchField ' + 'MATCH "${String.fromCharCodes(snapshot.data.runes.toList().reversed)}*") ' + '${(_searchMode > 0 ? "AND _rowid_ >= $_searchMode" : "")} ' 'ORDER BY _rowid_ LIMIT $nextIndex, $pageSize' ') AS tt ON tt.idex=imis._rowid_)', )); @@ -403,9 +429,10 @@ class _MyHomePageState extends State { 'SELECT tt.word,tt.yomikata,tt.pitchData,' 'tt.origForm,tt.freqRank,tt.idex,tt.romaji,imis.imi,imis.orig ' 'FROM (imis JOIN (SELECT * FROM jpdc ' - 'WHERE word $method "${snapshot.data}" ' + 'WHERE (word $method "${snapshot.data}" ' 'OR yomikata $method "${snapshot.data}" ' - 'OR romaji $method "${snapshot.data}" ' + 'OR romaji $method "${snapshot.data}") ' + '${(_searchMode > 0 ? "AND _rowid_ >= $_searchMode" : "")} ' 'ORDER BY _rowid_ LIMIT $nextIndex, $pageSize' ') AS tt ON tt.idex=imis._rowid_)', )); diff --git a/pubspec.yaml b/pubspec.yaml index 424de01..4a8e85e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.2+1 +version: 1.0.3+1 environment: sdk: ">=2.17.5 <3.0.0"