Skip to content

Commit

Permalink
using UtilEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
Khen Solomon Lethil committed Apr 3, 2021
1 parent ffbf71b commit ef31c85
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 612 deletions.
286 changes: 0 additions & 286 deletions lib/core/bible.single.md

This file was deleted.

24 changes: 8 additions & 16 deletions lib/core/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,31 @@ abstract class _Collection with _Configuration, _Utility {

Future<Collection> readCollection() async {
if (collection == null) {
await docsExists(assetsCollection).then((String hasExists) async {
await UtilDocument.exists(assetsCollection).then((String hasExists) async {
if (hasExists == null){
await loadBundleAsString(join(assetsFolder,assetsCollection)).then(_parseCollection);
await UtilDocument.loadBundleAsString(join(assetsFolder,assetsCollection)).then(_parseCollection);
await writeCollection();
} else {
await docsRead(assetsCollection).then(_parseCollection);
await UtilDocument.readAsString(assetsCollection).then(_parseCollection);
}
});
// await docsExists(assetsCollection).then((bool hasExists) async {
// if (hasExists){
// await docsRead(assetsCollection).then(_parseCollection);
// } else {
// await loadBundleAsString(join(assetsFolder,assetsCollection)).then(_parseCollection);
// await writeCollection();
// }
// });
}
return collection;
}

Future<void> writeCollection() async => await docsWrite(assetsCollection, encodeJSON(collection.toJSON()));
Future<void> writeCollection() async => await UtilDocument.writeAsString(assetsCollection, UtilDocument.encodeJSON(collection.toJSON()));

Future<bool> deleteCollection() async => await docsExists(assetsCollection).then(
Future<bool> deleteCollection() async => await UtilDocument.exists(assetsCollection).then(
(String hasExists) async{
return (hasExists == null)?false:await docsDelete(assetsCollection);
return (hasExists == null)?false:await UtilDocument.delete(assetsCollection);
}
);

// Future<void> updateCollectionTest() async => Future.delayed(Duration(seconds: 3));
Future<void> updateCollection() async => requestHTTP(_liveBookJSON.split('').reversed.join()).then(
Future<void> updateCollection() async => UtilClient.request(_liveBookJSON.split('').reversed.join()).then(
(res) async {
// Map<String, dynamic> parsed = decodeJSON(res.body);
Map<String, dynamic> parsed = decodeJSON(res);
Map<String, dynamic> parsed = UtilDocument.decodeJSON(res);
// NOTE: change of collection bible model
parsed['bible'] = (parsed['book']??parsed['bible']);
await parsed['bible'].forEach((e){
Expand Down
18 changes: 15 additions & 3 deletions lib/core/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ List<DefinitionBible> userBibleList = [];

mixin _Configuration {
String appName = 'Lai Siangtho';
String packageName = '';
String version = '';
String buildNumber = '';
String packageName = '?';
String version = '1.0.4';
String buildNumber = '44';
final String appDescription = 'the Holy Bible in languages';

// final String appAnalytics = 'UA-18644721-1';
Expand Down Expand Up @@ -46,4 +46,16 @@ mixin _Configuration {
// );
String digit(dynamic e) => scripturePrimary.digit(e);
// int get uniqueIdentify => new DateTime.now().millisecondsSinceEpoch;
}

Collection parseCollectionCompute(dynamic response) {
Map<String, dynamic> parsed = (response is String)?UtilDocument.decodeJSON(response):response;
return Collection.fromJSON(parsed)..bible.sort(
(a, b) => a.order.compareTo(b.order)
);
}

DefinitionBible parseBibleCompute(String response){
Map<String, dynamic> parsed = UtilDocument.decodeJSON(response);
return DefinitionBible.fromJSON(parsed);
}
Loading

0 comments on commit ef31c85

Please sign in to comment.