diff --git a/lib/Components/ScannerDialog.dart b/lib/Components/ScannerDialog.dart index 2e2f5d9..2762310 100644 --- a/lib/Components/ScannerDialog.dart +++ b/lib/Components/ScannerDialog.dart @@ -6,6 +6,7 @@ import 'package:mymuseum_visitapp/Helpers/translationHelper.dart'; import 'package:mymuseum_visitapp/Models/visitContext.dart'; import 'package:mymuseum_visitapp/Screens/Article/article_page.dart'; import 'package:mymuseum_visitapp/Screens/Quizz/quizz_page.dart'; +import 'package:mymuseum_visitapp/Screens/section_page.dart'; import 'package:mymuseum_visitapp/app_context.dart'; import 'package:mymuseum_visitapp/constants.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -180,28 +181,14 @@ class _ScannerDialogState extends State { } else { SectionDTO section = visitAppContext.currentSections!.firstWhere((cs) => cs!.id == sectionId)!; - switch(section.type) { - case SectionType.Article: - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) { - return ArticlePage(visitAppContextIn: visitAppContext, articleId: section.id!); - }, - ), - ); - break; - case SectionType.Quiz: - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) { - return QuizzPage(visitAppContextIn: visitAppContext, sectionId: section.id!); - }, - ), - ); - break; - } + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) { + return SectionPage(visitAppContextIn: visitAppContext, sectionId: section.id!); + }, + ), + ); } } }); diff --git a/lib/Helpers/DatabaseHelper.dart b/lib/Helpers/DatabaseHelper.dart index 24f15ee..2df8b60 100644 --- a/lib/Helpers/DatabaseHelper.dart +++ b/lib/Helpers/DatabaseHelper.dart @@ -400,7 +400,7 @@ class DatabaseHelper { imageSource: element["imageSource"], configurationId: element["configurationId"], type: SectionType.values[element["type"]], - data: element["data"], + // data: element["data"], // TODO section data dateCreation: DateTime.tryParse(element["dateCreation"]), order: int.parse(element["orderOfElement"]), ); diff --git a/lib/Helpers/modelsHelper.dart b/lib/Helpers/modelsHelper.dart index 20335f6..8aaa9da 100644 --- a/lib/Helpers/modelsHelper.dart +++ b/lib/Helpers/modelsHelper.dart @@ -35,7 +35,7 @@ class ModelsHelper { 'isSubSection': section.isSubSection, 'parentId': section.parentId, 'type': section.type!.value, - 'data': section.data, + //'data': section.data, // TODO section data 'dateCreation': section.dateCreation!.toUtc().toIso8601String(), 'orderOfElement': section.order, }; diff --git a/lib/Models/visitContext.dart b/lib/Models/visitContext.dart index 1912256..ee86e85 100644 --- a/lib/Models/visitContext.dart +++ b/lib/Models/visitContext.dart @@ -6,7 +6,7 @@ import 'package:mymuseum_visitapp/Models/resourceModel.dart'; import 'package:mymuseum_visitapp/client.dart'; class VisitAppContext with ChangeNotifier { - Client clientAPI = Client("https://api.myinfomate.be"); // Replace by https://api.mymuseum.be //http://192.168.31.140:8089 + Client clientAPI = Client("http://192.168.31.228:5000"); // Replace by https://api.mymuseum.be //http://192.168.31.140:8089 // https://api.myinfomate.be String? id = ""; String? language = ""; diff --git a/lib/Screens/Article/article_page.dart b/lib/Screens/Article/article_page.dart index aa0cd87..b145392 100644 --- a/lib/Screens/Article/article_page.dart +++ b/lib/Screens/Article/article_page.dart @@ -24,10 +24,11 @@ import 'package:path_provider/path_provider.dart'; import 'audio_player_floating.dart'; class ArticlePage extends StatefulWidget { - const ArticlePage({Key? key, required this.visitAppContextIn, required this.articleDTO}) : super(key: key); + const ArticlePage({Key? key, required this.visitAppContextIn, required this.articleDTO, required this.resourcesModel}) : super(key: key); final ArticleDTO articleDTO; final VisitAppContext visitAppContextIn; + final List resourcesModel; @override State createState() => _ArticlePageState(); @@ -36,7 +37,6 @@ class ArticlePage extends StatefulWidget { class _ArticlePageState extends State { SectionDTO? sectionDTO; ArticleDTO? articleDTO; - List resourcesModel = []; ResourceModel? audioResourceModel; final GlobalKey _scaffoldKey = GlobalKey(); File? audioFile; @@ -69,19 +69,18 @@ class _ArticlePageState extends State { isHomeButton: false, isTextSizeButton: true, ), - body: FutureBuilder( - future: getArticle(appContext, visitAppContext.clientAPI, widget.articleDTO.id, false), - builder: (context, AsyncSnapshot snapshot) { + body: OrientationBuilder( + builder: (context, orientation) { if(articleDTO != null && sectionDTO != null) { if(size.height > size.width) { return Column( children: [ if(articleDTO!.isContentTop!) getContent(size, appContext), - if(articleDTO!.isContentTop! && resourcesModel.isNotEmpty) + if(articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty) getImages(size, articleDTO!.isContentTop!), - if(!articleDTO!.isContentTop! && resourcesModel.isNotEmpty) + if(!articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty) getImages(size, articleDTO!.isContentTop!), if(!articleDTO!.isContentTop!) getContent(size, appContext), @@ -101,10 +100,10 @@ class _ArticlePageState extends State { children: [ if(articleDTO!.isContentTop!) getContent(size, appContext), - if(articleDTO!.isContentTop! && resourcesModel.isNotEmpty) + if(articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty) getImages(size, articleDTO!.isContentTop!), - if(!articleDTO!.isContentTop! && resourcesModel.isNotEmpty) + if(!articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty) getImages(size, articleDTO!.isContentTop!), if(!articleDTO!.isContentTop!) getContent(size, appContext), @@ -121,14 +120,9 @@ class _ArticlePageState extends State { } } ), - floatingActionButton: FutureBuilder( - future: getArticle(appContext, visitAppContext.clientAPI, widget.articleId, true), - builder: (context, AsyncSnapshot snapshot) { - return Padding( - padding: EdgeInsets.only(right: 0, top: 0), //size.height*0.1 - child: audioResourceModel != null && audioResourceModel!.source != null ? AudioPlayerFloatingContainer(file: audioFile, resourceURl: audioResourceModel!.source!, isAuto: articleDTO!.isReadAudioAuto!) : null, - ); - } + floatingActionButton: Padding( + padding: const EdgeInsets.only(right: 0, top: 0), //size.height*0.1 + child: audioResourceModel != null && audioResourceModel!.source != null ? AudioPlayerFloatingContainer(file: audioFile, resourceURl: audioResourceModel!.source!, isAuto: articleDTO!.isReadAudioAuto!) : null, ), floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat, //miniEndTop ); @@ -153,7 +147,7 @@ class _ArticlePageState extends State { boxShadow: const [kDefaultShadow], ), child: SliderImagesWidget( - resources: resourcesModel, + resources: widget.resourcesModel, height: size.height * 0.29, contentsDTO: articleDTO!.contents!, ) @@ -178,7 +172,7 @@ class _ArticlePageState extends State { boxShadow: const [kDefaultShadow], ), child: SliderImagesWidget( - resources: resourcesModel, + resources: widget.resourcesModel, height: size.height * 0.29, contentsDTO: articleDTO!.contents!, ) @@ -262,7 +256,7 @@ class _ArticlePageState extends State { } } - Future getArticle(AppContext appContext, Client client, String articleId, bool isAudio) async { + /*Future getArticle(AppContext appContext, Client client, String articleId, bool isAudio) async { try { if(sectionDTO == null || articleDTO == null) { bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!; @@ -407,5 +401,5 @@ class _ArticlePageState extends State { print("IN CATCH"); return null; } - } + }*/ } diff --git a/lib/Screens/Home/home.dart b/lib/Screens/Home/home.dart index 7f1ee2c..0abb15b 100644 --- a/lib/Screens/Home/home.dart +++ b/lib/Screens/Home/home.dart @@ -6,6 +6,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/services.dart'; import 'package:manager_api_new/api.dart'; import 'package:mymuseum_visitapp/Components/CustomAppBar.dart'; +import 'package:mymuseum_visitapp/Components/ScannerBouton.dart'; import 'package:mymuseum_visitapp/Components/loading_common.dart'; import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart'; import 'package:mymuseum_visitapp/Helpers/modelsHelper.dart'; @@ -109,7 +110,7 @@ class _HomePageState extends State with WidgetsBindingObserver { ], ) ), - //floatingActionButton: ScannerBouton(appContext: appContext), + // floatingActionButton: ScannerBouton(appContext: appContext), //floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterFloat, /*bottomNavigationBar: BottomNavigationBar( currentIndex: currentIndex, diff --git a/lib/Screens/Home/home_3.0.dart b/lib/Screens/Home/home_3.0.dart new file mode 100644 index 0000000..08f8777 --- /dev/null +++ b/lib/Screens/Home/home_3.0.dart @@ -0,0 +1,360 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; +import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; +import 'package:manager_api_new/api.dart'; +import 'package:mymuseum_visitapp/Components/CustomAppBar.dart'; +import 'package:mymuseum_visitapp/Components/ScannerBouton.dart'; +import 'package:mymuseum_visitapp/Components/loading_common.dart'; +import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart'; +import 'package:mymuseum_visitapp/Helpers/modelsHelper.dart'; +import 'package:mymuseum_visitapp/Helpers/networkCheck.dart'; +import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart'; +import 'package:mymuseum_visitapp/Helpers/translationHelper.dart'; +import 'package:mymuseum_visitapp/Models/beaconSection.dart'; +import 'package:mymuseum_visitapp/Models/visitContext.dart'; +import 'package:mymuseum_visitapp/Services/apiService.dart'; +import 'package:mymuseum_visitapp/Services/downloadConfiguration.dart'; +import 'package:mymuseum_visitapp/app_context.dart'; +import 'package:mymuseum_visitapp/client.dart'; +import 'package:mymuseum_visitapp/constants.dart'; +import 'package:provider/provider.dart'; + +import '../Tests/TestAR.dart'; +import 'configurations_list.dart'; + +class HomePage3 extends StatefulWidget { + const HomePage3({Key? key}) : super(key: key); + + @override + State createState() => _HomePage3State(); +} + +class _HomePage3State extends State with WidgetsBindingObserver { + int currentIndex = 0; + + late List configurations = []; + List alreadyDownloaded = []; + late VisitAppContext visitAppContext; + + final List colors = [ + Colors.blue, + Colors.green, + Colors.orange, + Colors.purple, + Colors.teal, + Colors.red, + ]; + + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + final appContext = Provider.of(context); + visitAppContext = appContext.getContext(); + + return Scaffold( + body: FutureBuilder( + future: getConfigurationsCall(visitAppContext.clientAPI, appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + configurations = List.from(snapshot.data).where((configuration) => configuration.isMobile!).toList(); + + //String cleanedTitle = configurations[0].title.replaceAll('\n', ' ').replaceAll('
', ' '); // TODO + + return Stack( + children: [ + SizedBox( + height: size.height * 0.35, + width: size.width, + child: Image.network( + configurations[2].imageSource!, + fit: BoxFit.cover, + ) + ), + Padding( + padding: EdgeInsets.only(top: size.height * 0.15), + child: CustomScrollView( + slivers: [ + /*SliverAppBar( + backgroundColor: Colors.transparent, + pinned: true, + expandedHeight: 200.0, + collapsedHeight: 100.0, + flexibleSpace: FlexibleSpaceBar( + collapseMode: CollapseMode.none, // 👈 Optionnel pour éviter le fade + background: Image.network( + configurations[2].imageSource!, + fit: BoxFit.cover, + ), + ), + ),*/ + SliverAppBar( + backgroundColor: Colors.transparent, + pinned: true, + expandedHeight: 225.0, + flexibleSpace: Container() /*FlexibleSpaceBar( + collapseMode: CollapseMode.none, // 👈 Optionnel pour éviter le fade + centerTitle: true, + background: Image.network( + configurations[2].imageSource!, + fit: BoxFit.cover, + ), + title: InkWell( + onLongPress: () { + showDialog( + builder: (BuildContext context) => const AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)) + ), + //content: AdminPopup(), + contentPadding: EdgeInsets.zero, + ), context: context + ); + }, + child: SizedBox( + width: /*widget.isHomeButton ?*/ size.width * 0.8 /*: null*/, + height: 60, + child: Center( + child: HtmlWidget( + "Carnaval de Marche", + textStyle: const TextStyle(color: Colors.white, fontFamily: 'Roboto', fontSize: 20), + customStylesBuilder: (element) + { + return {'text-align': 'center', 'font-family': "Roboto", '-webkit-line-clamp': "2"}; + }, + ), + ), + ), + ), + ),*/ // plus de FlexibleSpaceBar + ), + SliverPadding( + padding: const EdgeInsets.all(8), + sliver: SliverMasonryGrid.count( + crossAxisCount: 2, + mainAxisSpacing: 12, + crossAxisSpacing: 12, + childCount: configurations.length, + itemBuilder: (context, index) { + //return buildTile(configurations[index]); + return Container( + height: 200 + (index % 3) * 55, + decoration: BoxDecoration( + color: colors[index % colors.length], + borderRadius: BorderRadius.circular(16), + ), + child: Center( + child: Text( + 'Bloc ${index + 1}', + style: const TextStyle(color: Colors.white, fontSize: 18), + ), + ), + ); + }, + ), + ), + + /*SliverToBoxAdapter( + child: Image.network(configurations[0].imageSource!), // ou NetworkImage + ),*/ + + ], + ), + ), + /*FutureBuilder( + future: getConfigurationsCall(visitAppContext.clientAPI, appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + + + return /*RefreshIndicator ( + onRefresh: () { + setState(() {}); + return Future(() => null); + }, + color: kSecondColor, + child:*/ ;/*ConfigurationsList( + alreadyDownloaded: alreadyDownloaded, + configurations: configurations, + requestRefresh: () { + setState(() {}); // For refresh + }, + ),*/ + //); + } + } + ),*/ + ], + ); + } else if (snapshot.connectionState == ConnectionState.none) { + return Text(TranslationHelper.getFromLocale("noData", appContext.getContext())); + } else { + return Center( + child: Container( + height: size.height * 0.15, + child: LoadingCommon() + ) + ); + } + } + ), + ); + + return Scaffold( + /*appBar: CustomAppBar( + title: TranslationHelper.getFromLocale("visitTitle", appContext.getContext()), + isHomeButton: false, + ),*/ + body: SingleChildScrollView( + child: Column( + children: [ + SizedBox( + width: size.width, + height: size.height, + child: FutureBuilder( + future: getConfigurationsCall(visitAppContext.clientAPI, appContext), + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + configurations = List.from(snapshot.data).where((configuration) => configuration.isMobile!).toList(); + return RefreshIndicator ( + onRefresh: () { + setState(() {}); + return Future(() => null); + }, + color: kSecondColor, + child: ConfigurationsList( + alreadyDownloaded: alreadyDownloaded, + configurations: configurations, + requestRefresh: () { + setState(() {}); // For refresh + }, + ), + ); + } else if (snapshot.connectionState == ConnectionState.none) { + return Text(TranslationHelper.getFromLocale("noData", appContext.getContext())); + } else { + return Center( + child: Container( + height: size.height * 0.15, + child: LoadingCommon() + ) + ); + } + } + ), + ), + /*InkWell( + onTap: () { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) { + return TestAR(); + //return XRWithQRScannerPage(); + }, + ), + ); + + }, + child: const SizedBox( + height: 50, + width: 10, + child: Text('TEST XR'), + ), + ),*/ + ], + ) + ), + // floatingActionButton: ScannerBouton(appContext: appContext), + //floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterFloat, + /*bottomNavigationBar: BottomNavigationBar( + currentIndex: currentIndex, + onTap: (index) { + setState(() { + currentIndex = index; + }); + + if (currentIndex == 0) { + controller.startScanning(); + } else { + controller.pauseScanning(); + controller.startBroadcasting(); + } + }, + items: [ + BottomNavigationBarItem( + icon: Icon(Icons.list), + label: 'Scan', + ), + BottomNavigationBarItem( + icon: Icon(Icons.bluetooth_audio), + label: 'Broadcast', + ), + ], + ),*/ + ); + } + + Future?> getConfigurationsCall(Client client, AppContext appContext) async { + bool isOnline = await hasNetwork(); + VisitAppContext visitAppContext = appContext.getContext(); + + List? configurations; + configurations = List.from(await DatabaseHelper.instance.getData(DatabaseTableType.configurations)); + alreadyDownloaded = configurations.map((c) => c.id).toList(); + + if(!isOnline) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(TranslationHelper.getFromLocale("noInternet", appContext.getContext())), backgroundColor: kMainColor2), + ); + + // GET ALL SECTIONIDS FOR ALL CONFIGURATION (OFFLINE) + for(var configuration in configurations) + { + var sections = List.from(await DatabaseHelper.instance.queryWithConfigurationId(DatabaseTableType.sections, configuration.id!)); + configuration.sectionIds = sections.map((e) => e.id!).toList(); + } + + // GET BEACONS FROM LOCAL + List beaconSections = List.from(await DatabaseHelper.instance.getData(DatabaseTableType.beaconSection)); + print("GOT beaconSection from LOCAL"); + print(beaconSections); + + visitAppContext.beaconSections = beaconSections; + //appContext.setContext(visitAppContext); + + return configurations; + } + + if(visitAppContext.beaconSections == null) { + List? sections = await ApiService.getAllBeacons(client, visitAppContext.instanceId!); + if(sections != null && sections.isNotEmpty) { + List beaconSections = sections.map((e) => BeaconSection(minorBeaconId: e.beaconId, orderInConfig: e.order, configurationId: e.configurationId, sectionId: e.id, sectionType: e.type)).toList(); + visitAppContext.beaconSections = beaconSections; + + try { + // Clear all before + await DatabaseHelper.instance.clearTable(DatabaseTableType.beaconSection); + // Store it locally for offline mode + for(var beaconSection in beaconSections) { + await DatabaseHelper.instance.insert(DatabaseTableType.beaconSection, ModelsHelper.beaconSectionToMap(beaconSection)); + } + print("STORE beaconSection DONE"); + } catch(e) { + print("Issue during beaconSection insertion"); + print(e); + } + + print("Got some Beacons for you"); + print(beaconSections); + appContext.setContext(visitAppContext); + } + } + + return await ApiService.getConfigurations(client, visitAppContext); + } +} \ No newline at end of file diff --git a/lib/Screens/Quizz/quizz_page.dart b/lib/Screens/Quizz/quizz_page.dart index 8f80b3f..bc33156 100644 --- a/lib/Screens/Quizz/quizz_page.dart +++ b/lib/Screens/Quizz/quizz_page.dart @@ -23,17 +23,18 @@ import 'package:mymuseum_visitapp/client.dart'; import 'package:mymuseum_visitapp/constants.dart'; import 'package:provider/provider.dart'; -class QuizzPage extends StatefulWidget { - const QuizzPage({Key? key, required this.visitAppContextIn, required this.sectionId}) : super(key: key); +class QuizPage extends StatefulWidget { + const QuizPage({Key? key, required this.visitAppContextIn, required this.quizDTO, required this.resourcesModel}) : super(key: key); - final String sectionId; + final QuizDTO quizDTO; final VisitAppContext visitAppContextIn; + final List resourcesModel; @override - State createState() => _QuizzPageState(); + State createState() => _QuizPageState(); } -class _QuizzPageState extends State { +class _QuizPageState extends State { SectionDTO? sectionDTO; List resourcesModel = []; ResourceModel? audioResourceModel; @@ -89,42 +90,39 @@ class _QuizzPageState extends State { ), body: OrientationBuilder( builder: (context, orientation) { - return FutureBuilder( - future: getQuizz(appContext, visitAppContext.clientAPI, widget.sectionId), // MAYBE MOVE THAT TO PARENT .. - builder: (context, AsyncSnapshot snapshot) { - if(quizDTO != null && sectionDTO != null) { + if(quizDTO != null && sectionDTO != null) { - if(showResult) { - var goodResponses = 0; - for (var question in _questionsSubDTO) { - if(question.chosen == question.responsesSubDTO!.indexWhere((response) => response.isGood!)) { - goodResponses +=1; - } - } - log("goodResponses =" + goodResponses.toString()); - List levelToShow = []; - var test = goodResponses/quizDTO!.questions!.length; + if(showResult) { + var goodResponses = 0; + for (var question in _questionsSubDTO) { + if(question.chosen == question.responsesSubDTO!.indexWhere((response) => response.isGood!)) { + goodResponses +=1; + } + } + log("goodResponses =" + goodResponses.toString()); + List levelToShow = []; + var test = goodResponses/quizDTO!.questions!.length; - if((0 == test || test < 0.25) && quizDTO!.badLevel != null) { - levelToShow = quizDTO!.badLevel!; - } - if((test>=0.25 && test < 0.5) && quizDTO!.mediumLevel != null) { - levelToShow = quizDTO!.mediumLevel!; - } - if((test>=0.5 && test < 0.75) && quizDTO!.goodLevel != null) { - levelToShow = quizDTO!.goodLevel!; - } - if((test>=0.75 && test <= 1) && quizDTO!.greatLevel != null) { - levelToShow = quizDTO!.greatLevel!; - } + if((0 == test || test < 0.25) && quizDTO!.badLevel != null) { + levelToShow = quizDTO!.badLevel!; + } + if((test>=0.25 && test < 0.5) && quizDTO!.mediumLevel != null) { + levelToShow = quizDTO!.mediumLevel!; + } + if((test>=0.5 && test < 0.75) && quizDTO!.goodLevel != null) { + levelToShow = quizDTO!.goodLevel!; + } + if((test>=0.75 && test <= 1) && quizDTO!.greatLevel != null) { + levelToShow = quizDTO!.greatLevel!; + } - return SizedBox( - width: double.infinity, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - /*Center( + return SizedBox( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + /*Center( child: SizedBox( width: 5, height: 5, @@ -145,78 +143,76 @@ class _QuizzPageState extends State { ), ), ),*/ - if (orientation == Orientation.portrait) - Column( - children: [ - if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) // TODO SUPPORT OTHER THAN IMAGES - resultImage(visitAppContext, size, levelToShow, orientation), - if(!showResponses) - // TEXT BOX WITH MAIN SCORE - Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)), - ], - ), + if (orientation == Orientation.portrait) + Column( + children: [ + if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) // TODO SUPPORT OTHER THAN IMAGES + resultImage(visitAppContext, size, levelToShow, orientation), + if(!showResponses) + // TEXT BOX WITH MAIN SCORE + Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)), + ], + ), - if (orientation == Orientation.landscape) - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - if(!showResponses) - // TEXT BOX WITH MAIN SCORE - Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)), - if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) - resultImage(visitAppContext, size, levelToShow, orientation), - ], - ), + if (orientation == Orientation.landscape) + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + if(!showResponses) + // TEXT BOX WITH MAIN SCORE + Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)), + if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) + resultImage(visitAppContext, size, levelToShow, orientation), + ], + ), - if(!showResponses) - // TEXT BOX WITH LEVEL TEXT RESULT - resultText(size, levelToShow, appContext), - if(showResponses) - QuestionsListWidget( - questionsSubDTO: _questionsSubDTO, - isShowResponse: true, - onShowResponse: () {}, - orientation: orientation, - ), - // RESPONSE BOX - //ShowReponsesWidget(questionsSubDTO: _questionsSubDTO), + if(!showResponses) + // TEXT BOX WITH LEVEL TEXT RESULT + resultText(size, levelToShow, appContext), + if(showResponses) + QuestionsListWidget( + questionsSubDTO: _questionsSubDTO, + isShowResponse: true, + onShowResponse: () {}, + orientation: orientation, + ), + // RESPONSE BOX + //ShowReponsesWidget(questionsSubDTO: _questionsSubDTO), - if(orientation == Orientation.portrait && !showResponses) - // Buttons - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: resultButtons(size, orientation, visitAppContext!), - ), - if(orientation == Orientation.landscape && !showResponses) - // Buttons - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: resultButtons(size, orientation, visitAppContext!), - ), - ], - ), - ); + if(orientation == Orientation.portrait && !showResponses) + // Buttons + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: resultButtons(size, orientation, visitAppContext!), + ), + if(orientation == Orientation.landscape && !showResponses) + // Buttons + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: resultButtons(size, orientation, visitAppContext!), + ), + ], + ), + ); - } else { - return QuestionsListWidget( - isShowResponse: false, - questionsSubDTO: _questionsSubDTO, - onShowResponse: () { - setState(() { - showResult = true; - }); - }, - orientation: orientation, - ); - } - } else { - return const LoadingCommon(); - } + } else { + return QuestionsListWidget( + isShowResponse: false, + questionsSubDTO: _questionsSubDTO, + onShowResponse: () { + setState(() { + showResult = true; + }); + }, + orientation: orientation, + ); } - ); + } else { + return const LoadingCommon(); + } } ), floatingActionButton: showResponses ? FloatingActionButton( @@ -235,7 +231,7 @@ class _QuizzPageState extends State { ); } - Future getQuizz(AppContext appContext, Client client, String sectionId) async { + /*Future getQuizz(AppContext appContext, Client client, String sectionId) async { try { if(sectionDTO == null || quizDTO == null) { bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!; @@ -312,7 +308,7 @@ class _QuizzPageState extends State { print("IN CATCH"); return null; } - } + }*/ resultImage(VisitAppContext visitAppContext, Size size, List levelToShow, Orientation orientation) { return Container( diff --git a/lib/Screens/Scanner/scanner_old.dart b/lib/Screens/Scanner/scanner_old.dart index 82cdd9b..f83fa57 100644 --- a/lib/Screens/Scanner/scanner_old.dart +++ b/lib/Screens/Scanner/scanner_old.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:mymuseum_visitapp/Components/CustomAppBar.dart'; import 'package:mymuseum_visitapp/Models/visitContext.dart'; import 'package:mymuseum_visitapp/Screens/Article/article_page.dart'; +import 'package:mymuseum_visitapp/Screens/section_page.dart'; import 'package:mymuseum_visitapp/app_context.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart'; @@ -180,7 +181,7 @@ class _ScannerPageState extends State { context, MaterialPageRoute( builder: (context) { - return ArticlePage(articleId: code, visitAppContextIn: VisitAppContext()); // will not work.. + return SectionPage(sectionId: code, visitAppContextIn: VisitAppContext()); // will not work.. }, ), ); diff --git a/lib/Screens/Visit/components/body.dart b/lib/Screens/Visit/components/body.dart index 1554b89..5c4d4b0 100644 --- a/lib/Screens/Visit/components/body.dart +++ b/lib/Screens/Visit/components/body.dart @@ -9,6 +9,7 @@ import 'package:mymuseum_visitapp/Helpers/translationHelper.dart'; import 'package:mymuseum_visitapp/Models/visitContext.dart'; import 'package:mymuseum_visitapp/Screens/Article/article_page.dart'; import 'package:mymuseum_visitapp/Screens/Quizz/quizz_page.dart'; +import 'package:mymuseum_visitapp/Screens/section_page.dart'; import 'package:mymuseum_visitapp/Services/apiService.dart'; import 'package:mymuseum_visitapp/app_context.dart'; import 'package:mymuseum_visitapp/constants.dart'; @@ -101,33 +102,15 @@ class _BodyState extends State { itemIndex: index, sectionDTO: sectionsToDisplay[index], press: () { - switch(sectionsToDisplay[index].type) { - case SectionType.Article: - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ArticlePage( - visitAppContextIn: appContext.getContext(), - articleId: sectionsToDisplay[index].id!, - ), - ), - ); - break; - case SectionType.Quiz: - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => QuizzPage( - visitAppContextIn: appContext.getContext(), - sectionId: sectionsToDisplay[index].id!, - ), - ), - ); - break; - default: - // TODO HANDLE, SHOW NOT SUPPORTED - break; - } + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SectionPage( + visitAppContextIn: appContext.getContext(), + sectionId: sectionsToDisplay[index].id!, + ), + ), + ); }, ), ), @@ -137,9 +120,9 @@ class _BodyState extends State { return Text(TranslationHelper.getFromLocale("noData", appContext.getContext())); } else { return Center( - child: Container( + child: SizedBox( height: size.height * 0.15, - child: LoadingCommon() + child: const LoadingCommon() ) ); } diff --git a/lib/Screens/Visit/visit.dart b/lib/Screens/Visit/visit.dart index 1e1d712..579b051 100644 --- a/lib/Screens/Visit/visit.dart +++ b/lib/Screens/Visit/visit.dart @@ -16,6 +16,7 @@ import 'package:mymuseum_visitapp/Models/visitContext.dart'; import 'package:mymuseum_visitapp/Screens/Article/article_page.dart'; import 'package:mymuseum_visitapp/Screens/Quizz/quizz_page.dart'; import 'package:mymuseum_visitapp/Screens/Visit/beaconArticleFound.dart'; +import 'package:mymuseum_visitapp/Screens/section_page.dart'; import 'package:mymuseum_visitapp/app_context.dart'; import 'package:mymuseum_visitapp/constants.dart'; import 'package:permission_handler/permission_handler.dart'; @@ -287,33 +288,15 @@ class _VisitPageState extends State with WidgetsBindingObserver { //visitAppContext.isArticleCurrentlyShown = true; lastTimePopUpWasClosed = DateTime.now(); - switch(beaconSection!.sectionType!) { - case SectionType.Article: - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ArticlePage( - visitAppContextIn: visitAppContext, - articleId: beaconSection.sectionId!, - ), - ), - ); - break; - case SectionType.Quiz: - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => QuizzPage( - visitAppContextIn: visitAppContext, - sectionId: beaconSection.sectionId!, - ), - ), - ); - break; - default: - // TODO HANDLE, SHOW NOT SUPPORTED - break; - } + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SectionPage( + visitAppContextIn: visitAppContext, + sectionId: beaconSection!.sectionId!, + ), + ), + ); }, ) ], diff --git a/lib/Screens/section_page.dart b/lib/Screens/section_page.dart index e957ec6..cfc3099 100644 --- a/lib/Screens/section_page.dart +++ b/lib/Screens/section_page.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'dart:typed_data'; //import 'package:confetti/confetti.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:manager_api_new/api.dart'; import 'package:mymuseum_visitapp/Components/CustomAppBar.dart'; @@ -15,8 +16,10 @@ import 'package:mymuseum_visitapp/Models/ResponseSubDTO.dart'; import 'package:mymuseum_visitapp/Models/articleRead.dart'; import 'package:mymuseum_visitapp/Models/resourceModel.dart'; import 'package:mymuseum_visitapp/Models/visitContext.dart'; +import 'package:mymuseum_visitapp/Screens/Article/article_page.dart'; //import 'package:mymuseum_visitapp/Screens/Quizz/drawPath.dart'; import 'package:mymuseum_visitapp/Screens/Quizz/questions_list.dart'; +import 'package:mymuseum_visitapp/Screens/Quizz/quizz_page.dart'; //import 'package:mymuseum_visitapp/Screens/Quizz/showResponses.dart'; import 'package:mymuseum_visitapp/app_context.dart'; import 'package:mymuseum_visitapp/client.dart'; @@ -38,14 +41,11 @@ class _SectionPageState extends State { SectionDTO? sectionDTO; late VisitAppContext visitAppContext; late dynamic rawSectionData; + List resourcesModel = []; @override void initState() { widget.visitAppContextIn.isContentCurrentlyShown = true; - - //_controllerCenter = ConfettiController(duration: const Duration(seconds: 10)); - //_controllerCenter!.play(); - super.initState(); } @@ -70,127 +70,18 @@ class _SectionPageState extends State { body: OrientationBuilder( builder: (context, orientation) { return FutureBuilder( - future: getSectionDetail(appContext, visitAppContext.clientAPI, widget.sectionId), // MAYBE MOVE THAT TO PARENT .. + future: getSectionDetail(appContext, visitAppContext.clientAPI, widget.sectionId), builder: (context, AsyncSnapshot snapshot) { - if(quizDTO != null && sectionDTO != null) { - - if(showResult) { - var goodResponses = 0; - for (var question in _questionsSubDTO) { - if(question.chosen == question.responsesSubDTO!.indexWhere((response) => response.isGood!)) { - goodResponses +=1; - } - } - log("goodResponses =" + goodResponses.toString()); - List levelToShow = []; - var test = goodResponses/quizDTO!.questions!.length; - - if((0 == test || test < 0.25) && quizDTO!.badLevel != null) { - levelToShow = quizDTO!.badLevel!; - } - if((test>=0.25 && test < 0.5) && quizDTO!.mediumLevel != null) { - levelToShow = quizDTO!.mediumLevel!; - } - if((test>=0.5 && test < 0.75) && quizDTO!.goodLevel != null) { - levelToShow = quizDTO!.goodLevel!; - } - if((test>=0.75 && test <= 1) && quizDTO!.greatLevel != null) { - levelToShow = quizDTO!.greatLevel!; - } - - return SizedBox( - width: double.infinity, - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - /*Center( - child: SizedBox( - width: 5, - height: 5, - child: ConfettiWidget( - confettiController: _controllerCenter!, - blastDirectionality: BlastDirectionality.explosive, - shouldLoop: false, // start again as soon as the animation is finished - colors: const [ - kMainColor, - kSecondColor, - kConfigurationColor, - kMainColor1 - //Colors.pink, - //Colors.orange, - //Colors.purple - ], // manually specify the colors to be used - createParticlePath: drawPath, // define a custom shape/path. - ), - ), - ),*/ - if (orientation == Orientation.portrait) - Column( - children: [ - if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) // TODO SUPPORT OTHER THAN IMAGES - resultImage(visitAppContext, size, levelToShow, orientation), - if(!showResponses) - // TEXT BOX WITH MAIN SCORE - Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)), - ], - ), - - if (orientation == Orientation.landscape) - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - if(!showResponses) - // TEXT BOX WITH MAIN SCORE - Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)), - if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) - resultImage(visitAppContext, size, levelToShow, orientation), - ], - ), - - if(!showResponses) - // TEXT BOX WITH LEVEL TEXT RESULT - resultText(size, levelToShow, appContext), - if(showResponses) - QuestionsListWidget( - questionsSubDTO: _questionsSubDTO, - isShowResponse: true, - onShowResponse: () {}, - orientation: orientation, - ), - // RESPONSE BOX - //ShowReponsesWidget(questionsSubDTO: _questionsSubDTO), - - if(orientation == Orientation.portrait && !showResponses) - // Buttons - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: resultButtons(size, orientation, visitAppContext!), - ), - if(orientation == Orientation.landscape && !showResponses) - // Buttons - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: resultButtons(size, orientation, visitAppContext!), - ), - ], - ), - ); - - } else { - return QuestionsListWidget( - isShowResponse: false, - questionsSubDTO: _questionsSubDTO, - onShowResponse: () { - setState(() { - showResult = true; - }); - }, - orientation: orientation, - ); + if(sectionDTO != null) { + switch(sectionDTO!.type) { + case SectionType.Article: + ArticleDTO articleDTO = ArticleDTO.fromJson(rawSectionData)!; + return ArticlePage(visitAppContextIn: widget.visitAppContextIn, articleDTO: articleDTO, resourcesModel: resourcesModel); + case SectionType.Quiz: + QuizDTO quizDTO = QuizDTO.fromJson(rawSectionData)!; + return QuizPage(visitAppContextIn: widget.visitAppContextIn, quizDTO: quizDTO, resourcesModel: resourcesModel); + default: + return const Center(child: Text("Unsupported type")); } } else { return const LoadingCommon(); @@ -198,20 +89,7 @@ class _SectionPageState extends State { } ); } - ), - floatingActionButton: showResponses ? FloatingActionButton( - onPressed: () { - setState(() { - showResult = false; - showResponses = false; - currentIndex = 1; - _questionsSubDTO = QuestionSubDTO().fromJSON(quizDTO!.questions!); - }); - }, - backgroundColor: kBackgroundSecondGrey, - child: const Icon(Icons.undo), - ) : null, - floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat, + ) ); } @@ -241,49 +119,50 @@ class _SectionPageState extends State { } else { // ONLINE - SectionDTO? sectionOnline = await client.sectionApi!.sectionGetDetail(sectionId); - if(sectionOnline != null) { - sectionDTO = sectionOnline; - } else { - print("EMPTY SECTION"); - } + rawSectionData = await client.sectionApi!.sectionGetDetail(sectionId); + SectionDTO sectionOnline = jsonDecode(jsonEncode(rawSectionData)).map((json) => SectionDTO.fromJson(json)).whereType().toList(); + sectionDTO = sectionOnline; } - if(sectionDTO!.type == SectionType.Quiz) { - quizDTO = QuizDTO.fromJson(jsonDecode(sectionDTO!.data!)); - } - if(quizDTO != null) { - quizDTO!.questions!.sort((a, b) => a.order!.compareTo(b.order!)); - _questionsSubDTO = QuestionSubDTO().fromJSON(quizDTO!.questions!); - if(quizDTO!.questions != null && quizDTO!.questions!.isNotEmpty) { - quizDTO!.questions!.sort((a, b) => a.order!.compareTo(b.order!)); - for (var question in quizDTO!.questions!) { - if(isConfigOffline) - { - // OFFLINE - if(question.imageBackgroundResourceId != null) { - List> ressourceQuizz = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, question.imageBackgroundResourceId!); - if(ressourceQuizz.isNotEmpty) { - resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(ressourceQuizz.first)); - } else { - print("EMPTY resourcesModel - second"); + switch(sectionDTO!.type) + { + case SectionType.Quiz: + QuizDTO? quizDTO = QuizDTO.fromJson(jsonDecode(rawSectionData)); + if(quizDTO != null) { + quizDTO.questions!.sort((a, b) => a.order!.compareTo(b.order!)); + if(quizDTO.questions != null && quizDTO.questions!.isNotEmpty) { + quizDTO.questions!.sort((a, b) => a.order!.compareTo(b.order!)); + for (var question in quizDTO.questions!) { + if(isConfigOffline) + { + // OFFLINE + if(question.imageBackgroundResourceId != null) { + List> ressourceQuizz = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, question.imageBackgroundResourceId!); + if(ressourceQuizz.isNotEmpty) { + resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(ressourceQuizz.first)); + } else { + print("EMPTY resourcesModel - second"); + } + } + } + else + { + // ONLINE + if(question.imageBackgroundResourceId != null) { + resourcesModel.add(ResourceModel(id: question.imageBackgroundResourceId, source: question.imageBackgroundResourceUrl, type: ResourceType.Image)); + } } } } - else - { - // ONLINE - if(question.imageBackgroundResourceId != null) { - resourcesModel.add(ResourceModel(id: question.imageBackgroundResourceId, source: question.imageBackgroundResourceUrl, type: ResourceType.Image)); - } - } } - } + break; + default: + break; } - setState(() { + /*setState(() { //print(sectionDTO!.title); - }); + });*/ } else { return null; // TODO return local list.. } @@ -293,131 +172,4 @@ class _SectionPageState extends State { return null; } } - - resultImage(VisitAppContext visitAppContext, Size size, List levelToShow, Orientation orientation) { - return Container( - //height: size.height * 0.2, - //width: size.width * 0.25, - constraints: BoxConstraints( - maxHeight: size.height * 0.25, - maxWidth: kIsWeb ? size.width * 0.20 : orientation == Orientation.portrait ? size.width * 0.85 : size.width * 0.4, - ), - alignment: Alignment.center, - decoration: BoxDecoration( - image: levelToShow.where((label) => label.language == visitAppContext.language).isNotEmpty ? DecorationImage( - fit: BoxFit.contain, - opacity: 0.85, - image: NetworkImage( - levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource!.url!, - ), - ): null, - borderRadius: const BorderRadius.all( Radius.circular(50.0)), - border: Border.all( - color: kBackgroundGrey, - width: 1.0, - ), - ), - child: Container( - //borderRadius: BorderRadius.all(Radius.circular(25.0)), - decoration: BoxDecoration( - color: const Color(0xff7c94b6), - image: DecorationImage( - image: NetworkImage( - levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource!.url!, // TODO REDUNDANCY here?? - ), - fit: BoxFit.cover, - ), - borderRadius: const BorderRadius.all( Radius.circular(50.0)), - border: Border.all( - color: kBackgroundGrey, - width: 1.0, - ), - ), - ), - ); - } - - resultText(Size size, List levelToShow, AppContext appContext) { - return Padding( - padding: const EdgeInsets.only(bottom: 10), - child: Container( - width: size.width *0.75, - height: kIsWeb ? (showResponses ? size.height *0.10 : size.height *0.20) : size.height *0.25, - decoration: BoxDecoration( - color: kBackgroundLight, //kBackgroundLight - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(10.0), - boxShadow: const [ - BoxShadow( - color: kBackgroundSecondGrey, - spreadRadius: 0.3, - blurRadius: 4, - offset: Offset(0, 2), // changes position of shadow - ), - ], - ), - child: Center( - child: SizedBox( - width: double.infinity, - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: Text(TranslationHelper.getWithResource(levelToShow, appContext.getContext() as VisitAppContext), textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kDescriptionSize : kDescriptionSize)), - ), - ), - ), - ), - ), - ); - } - - resultButtons(Size size, Orientation orientation, VisitAppContext visitAppContext) { - return [ - Padding( - padding: const EdgeInsets.all(4), - child: SizedBox( - height: kIsWeb ? 50 : 40, - width: orientation == Orientation.portrait ? size.width * 0.6 : size.width * 0.35, - child: RoundedButton( - text: TranslationHelper.getFromLocale("restart", visitAppContext), - color: kBackgroundSecondGrey, - textColor: kBackgroundLight, - icon: Icons.undo, - press: () { - setState(() { - showResult = false; - showResponses = false; - currentIndex = 1; - _questionsSubDTO = QuestionSubDTO().fromJSON(quizDTO!.questions!); - }); - }, - fontSize: 18, - horizontal: 20, - vertical: 5 - ), - ), - ), - Padding( - padding: const EdgeInsets.all(4.0), - child: SizedBox( - height: kIsWeb ? 50 : 40, - width: orientation == Orientation.portrait ? size.width * 0.6 : size.width * 0.35, - child: RoundedButton( - text: TranslationHelper.getFromLocale("responses", visitAppContext), - color: kBackgroundSecondGrey, - textColor: kBackgroundLight, - icon: Icons.assignment_turned_in, - press: () { - setState(() { - showResponses = true; - }); - }, - fontSize: 18, - horizontal: 20, - vertical: 5 - ), - ), - ) - ]; - } } diff --git a/lib/Services/apiService.dart b/lib/Services/apiService.dart index 17726ab..610b9cf 100644 --- a/lib/Services/apiService.dart +++ b/lib/Services/apiService.dart @@ -22,7 +22,7 @@ class ApiService { if(configurations.isNotEmpty) { for(var configuration in configurations) { if(configuration.imageId != null) { - await downloadAndPushLocalImage(client, ContentDTO(resource: ResourceDTO(url: configuration.imageSource, id: configuration.imageId))); + await downloadAndPushLocalImage(client, ContentDTO(resourceId: configuration.imageId, resource: ResourceDTO(url: configuration.imageSource, id: configuration.imageId))); } } } @@ -84,7 +84,7 @@ class ApiService { if(isOnline) { ResourceModel? resourceModel = await downloadImage(client, contentDTO); if(resourceModel != null) { - await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap()); + //await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap()); } return true; } else { diff --git a/lib/Services/downloadConfiguration.dart b/lib/Services/downloadConfiguration.dart index 0dc534c..fbcd093 100644 --- a/lib/Services/downloadConfiguration.dart +++ b/lib/Services/downloadConfiguration.dart @@ -176,8 +176,10 @@ class _DownloadConfigurationWidgetState extends State { create: (_) => AppContext(widget.visitAppContext), child: MaterialApp( debugShowCheckedModeBanner: false, - title: 'Fort Saint Héribert', //'Musée de la fraise' + title: 'Carnaval de Marche', //'Musée de la fraise' // Autres // 'Fort Saint Héribert' initialRoute: widget.initialRoute, localizationsDelegates: const [ AppLocalizations.delegate, @@ -101,9 +102,9 @@ class _MyAppState extends State { GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], - supportedLocales: [ - const Locale('en', ''), - const Locale('fr', ''), + supportedLocales: const[ + Locale('en', ''), + Locale('fr', ''), ], theme: ThemeData( primarySwatch: Colors.blue, @@ -116,7 +117,7 @@ class _MyAppState extends State { ), ), routes: { - '/home': (context) => const HomePage(), + '/home': (context) => const HomePage3(), } ), ); diff --git a/pubspec.lock b/pubspec.lock index ade4c98..577d188 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -331,6 +331,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_staggered_grid_view: + dependency: "direct main" + description: + name: flutter_staggered_grid_view + sha256: "19e7abb550c96fbfeb546b23f3ff356ee7c59a019a651f8f102a4ba9b7349395" + url: "https://pub.dev" + source: hosted + version: "0.7.0" flutter_svg: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e41f141..97501c4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,6 +55,7 @@ dependencies: sqflite: #not in web just_audio_cache: ^0.1.2 #not in web flutter_beacon: ^0.5.1 #not in web + flutter_staggered_grid_view: ^0.7.0 manager_api_new: path: manager_api_new