Add kanji page

This commit is contained in:
2022-01-26 01:58:47 +01:00
parent a8b0f3b737
commit c1ccbc00b3
16 changed files with 292 additions and 97 deletions

View File

@@ -0,0 +1,50 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:tangocard_reader/models/data_entry.dart';
// TODO: merge
Future<Map<File, List<YokutangoEntry>>> get tangocardFilePaths => rootBundle
.loadString('AssetManifest.json')
.then(
(json) => jsonDecode(json)
.keys
.where((String key) =>
key.contains('yokutango/json/') && key.contains('.json'))
.toList(),
)
.then(
(l) async => Map.fromIterables(
l.map<File>((f) => File(f)),
await Future.wait<List<YokutangoEntry>>(
l.map<Future<List<YokutangoEntry>>>(
(String t) => rootBundle.loadString(t).then<List<YokutangoEntry>>(
(s) => jsonDecode(s)
.map<YokutangoEntry>((e) => YokutangoEntry.fromJson(e))
.toList()),
)),
),
);
Future<Map<File, List<KanjiEntry>>> get kanjicardFilePaths => rootBundle
.loadString('AssetManifest.json')
.then(
(json) => jsonDecode(json)
.keys
.where((String key) =>
key.contains(RegExp(r'yokutango/kanji/kanji_\d+.json')))
.toList(),
)
.then(
(l) async => Map.fromIterables(
l.map<File>((f) => File(f)),
await Future.wait<List<KanjiEntry>>(l.map<Future<List<KanjiEntry>>>(
(String t) => rootBundle.loadString(t).then<List<KanjiEntry>>((s) =>
jsonDecode(s)
.map<KanjiEntry>((e) => KanjiEntry.fromJson(e))
.toList()),
)),
),
);