diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index a34ffd2..f8dfebd 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-10-20 16:40:20.714473","version":"3.0.3"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"qr_code_scanner","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\qr_code_scanner-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\Users\\\\thoma\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-2.0.3+1\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"qr_code_scanner","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2022-10-23 11:11:04.666376","version":"3.0.3"} \ No newline at end of file diff --git a/lib/Screens/Article/article.dart b/lib/Screens/Article/article.dart index 215ae15..4634438 100644 --- a/lib/Screens/Article/article.dart +++ b/lib/Screens/Article/article.dart @@ -222,18 +222,87 @@ class _ArticlePageState extends State { try { bool isOnline = await hasNetwork(); if(sectionDTO == null || articleDTO == null) { - await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.sections, articleId).then((value) async { + print("ARTCILE DTO GET ARTICLE"); + + List> sectionTest = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.sections, articleId); + if(sectionTest.isNotEmpty) { + sectionDTO = DatabaseHelper.instance.getSectionFromDB(sectionTest.first); + print(sectionDTO!.data); + } else { + print("EMPTY SECTION"); + } + if(sectionDTO!.type == SectionType.Article) { + print("set article __ !!"); + print(sectionDTO!.data!); + articleDTO = ArticleDTO.fromJson(jsonDecode(sectionDTO!.data!)); + print(articleDTO); + } + + if(sectionDTO!.imageId != null) { + List> ressourceTest = await DatabaseHelper + .instance.queryWithColumnId( + DatabaseTableType.resources, sectionDTO!.imageId!); + if (ressourceTest.isNotEmpty) { + resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(ressourceTest.first)); + } else { + print("EMPTY resourcesModel - first"); + } + } + + if(articleDTO!.images!.isNotEmpty) { + for (var image in articleDTO!.images!) { + if(image.resourceId != null) { + print("image.resourceId != nullimage.resourceId != nullimage.resourceId != null"); + + List> ressourceArticle = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, image.resourceId!); + if(ressourceArticle.isNotEmpty) { + resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(ressourceArticle.first)); + } else { + print("EMPTY resourcesModel - second"); + } + + /*await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, image.resourceId!).then((value) { + print(value); + if(value.isNotEmpty) { + resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(value.first)); + } else { + print("EMPTY resourcesModel - second"); + } + });*/ + } + } + + /*if(mainResource == null && resourcesModel.isNotEmpty) { + mainResource = resourcesModel.first; + }*/ + } + + + /*await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, sectionDTO!.imageId!).then((value) { + if(value.isNotEmpty) { + resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(value.first)); + } else { + print("EMPTY resourcesModel - first"); + } + });*/ + //} + + /*await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.sections, articleId).then((value) async { setState(() { if(value.isNotEmpty) { sectionDTO = DatabaseHelper.instance.getSectionFromDB(value.first); + print(sectionDTO!.data); } else { print("EMPTY SECTION"); } if(sectionDTO!.type == SectionType.Article) { + print("set article __ !!"); articleDTO = ArticleDTO.fromJson(jsonDecode(sectionDTO!.data!)); + print(articleDTO); } }); - if(sectionDTO!.imageId != null) { + */ + /*if(sectionDTO!.imageId != null) { await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, sectionDTO!.imageId!).then((value) { if(value.isNotEmpty) { resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(value.first)); @@ -241,8 +310,8 @@ class _ArticlePageState extends State { print("EMPTY resourcesModel - first"); } }); - } - if(articleDTO!.images!.isNotEmpty) { + }*/ + /*if(articleDTO!.images!.isNotEmpty) { for (var image in articleDTO!.images!) { if(image.resourceId != null) { print("image.resourceId != nullimage.resourceId != nullimage.resourceId != null"); @@ -255,13 +324,13 @@ class _ArticlePageState extends State { } }); } - } + }*/ /*if(mainResource == null && resourcesModel.isNotEmpty) { mainResource = resourcesModel.first; }*/ - } - }); + //} + //}); } else { // TODO ONLINE return null; // TODO return local list..