Wip version 3.0.0
This commit is contained in:
parent
53dff98388
commit
878a2e4cf0
@ -6,6 +6,7 @@ import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
|||||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Article/article_page.dart';
|
import 'package:mymuseum_visitapp/Screens/Article/article_page.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Quizz/quizz_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/app_context.dart';
|
||||||
import 'package:mymuseum_visitapp/constants.dart';
|
import 'package:mymuseum_visitapp/constants.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
@ -180,28 +181,14 @@ class _ScannerDialogState extends State<ScannerDialog> {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
SectionDTO section = visitAppContext.currentSections!.firstWhere((cs) => cs!.id == sectionId)!;
|
SectionDTO section = visitAppContext.currentSections!.firstWhere((cs) => cs!.id == sectionId)!;
|
||||||
switch(section.type) {
|
Navigator.pushReplacement(
|
||||||
case SectionType.Article:
|
context,
|
||||||
Navigator.pushReplacement(
|
MaterialPageRoute(
|
||||||
context,
|
builder: (context) {
|
||||||
MaterialPageRoute(
|
return SectionPage(visitAppContextIn: visitAppContext, sectionId: section.id!);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -400,7 +400,7 @@ class DatabaseHelper {
|
|||||||
imageSource: element["imageSource"],
|
imageSource: element["imageSource"],
|
||||||
configurationId: element["configurationId"],
|
configurationId: element["configurationId"],
|
||||||
type: SectionType.values[element["type"]],
|
type: SectionType.values[element["type"]],
|
||||||
data: element["data"],
|
// data: element["data"], // TODO section data
|
||||||
dateCreation: DateTime.tryParse(element["dateCreation"]),
|
dateCreation: DateTime.tryParse(element["dateCreation"]),
|
||||||
order: int.parse(element["orderOfElement"]),
|
order: int.parse(element["orderOfElement"]),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class ModelsHelper {
|
|||||||
'isSubSection': section.isSubSection,
|
'isSubSection': section.isSubSection,
|
||||||
'parentId': section.parentId,
|
'parentId': section.parentId,
|
||||||
'type': section.type!.value,
|
'type': section.type!.value,
|
||||||
'data': section.data,
|
//'data': section.data, // TODO section data
|
||||||
'dateCreation': section.dateCreation!.toUtc().toIso8601String(),
|
'dateCreation': section.dateCreation!.toUtc().toIso8601String(),
|
||||||
'orderOfElement': section.order,
|
'orderOfElement': section.order,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import 'package:mymuseum_visitapp/Models/resourceModel.dart';
|
|||||||
import 'package:mymuseum_visitapp/client.dart';
|
import 'package:mymuseum_visitapp/client.dart';
|
||||||
|
|
||||||
class VisitAppContext with ChangeNotifier {
|
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? id = "";
|
||||||
String? language = "";
|
String? language = "";
|
||||||
|
|||||||
@ -24,10 +24,11 @@ import 'package:path_provider/path_provider.dart';
|
|||||||
import 'audio_player_floating.dart';
|
import 'audio_player_floating.dart';
|
||||||
|
|
||||||
class ArticlePage extends StatefulWidget {
|
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 ArticleDTO articleDTO;
|
||||||
final VisitAppContext visitAppContextIn;
|
final VisitAppContext visitAppContextIn;
|
||||||
|
final List<ResourceModel?> resourcesModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ArticlePage> createState() => _ArticlePageState();
|
State<ArticlePage> createState() => _ArticlePageState();
|
||||||
@ -36,7 +37,6 @@ class ArticlePage extends StatefulWidget {
|
|||||||
class _ArticlePageState extends State<ArticlePage> {
|
class _ArticlePageState extends State<ArticlePage> {
|
||||||
SectionDTO? sectionDTO;
|
SectionDTO? sectionDTO;
|
||||||
ArticleDTO? articleDTO;
|
ArticleDTO? articleDTO;
|
||||||
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
|
||||||
ResourceModel? audioResourceModel;
|
ResourceModel? audioResourceModel;
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
File? audioFile;
|
File? audioFile;
|
||||||
@ -69,19 +69,18 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
isHomeButton: false,
|
isHomeButton: false,
|
||||||
isTextSizeButton: true,
|
isTextSizeButton: true,
|
||||||
),
|
),
|
||||||
body: FutureBuilder(
|
body: OrientationBuilder(
|
||||||
future: getArticle(appContext, visitAppContext.clientAPI, widget.articleDTO.id, false),
|
builder: (context, orientation) {
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
||||||
if(articleDTO != null && sectionDTO != null) {
|
if(articleDTO != null && sectionDTO != null) {
|
||||||
if(size.height > size.width) {
|
if(size.height > size.width) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
if(articleDTO!.isContentTop!)
|
if(articleDTO!.isContentTop!)
|
||||||
getContent(size, appContext),
|
getContent(size, appContext),
|
||||||
if(articleDTO!.isContentTop! && resourcesModel.isNotEmpty)
|
if(articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty)
|
||||||
getImages(size, articleDTO!.isContentTop!),
|
getImages(size, articleDTO!.isContentTop!),
|
||||||
|
|
||||||
if(!articleDTO!.isContentTop! && resourcesModel.isNotEmpty)
|
if(!articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty)
|
||||||
getImages(size, articleDTO!.isContentTop!),
|
getImages(size, articleDTO!.isContentTop!),
|
||||||
if(!articleDTO!.isContentTop!)
|
if(!articleDTO!.isContentTop!)
|
||||||
getContent(size, appContext),
|
getContent(size, appContext),
|
||||||
@ -101,10 +100,10 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
children: [
|
children: [
|
||||||
if(articleDTO!.isContentTop!)
|
if(articleDTO!.isContentTop!)
|
||||||
getContent(size, appContext),
|
getContent(size, appContext),
|
||||||
if(articleDTO!.isContentTop! && resourcesModel.isNotEmpty)
|
if(articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty)
|
||||||
getImages(size, articleDTO!.isContentTop!),
|
getImages(size, articleDTO!.isContentTop!),
|
||||||
|
|
||||||
if(!articleDTO!.isContentTop! && resourcesModel.isNotEmpty)
|
if(!articleDTO!.isContentTop! && widget.resourcesModel.isNotEmpty)
|
||||||
getImages(size, articleDTO!.isContentTop!),
|
getImages(size, articleDTO!.isContentTop!),
|
||||||
if(!articleDTO!.isContentTop!)
|
if(!articleDTO!.isContentTop!)
|
||||||
getContent(size, appContext),
|
getContent(size, appContext),
|
||||||
@ -121,14 +120,9 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
floatingActionButton: FutureBuilder(
|
floatingActionButton: Padding(
|
||||||
future: getArticle(appContext, visitAppContext.clientAPI, widget.articleId, true),
|
padding: const EdgeInsets.only(right: 0, top: 0), //size.height*0.1
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
child: audioResourceModel != null && audioResourceModel!.source != null ? AudioPlayerFloatingContainer(file: audioFile, resourceURl: audioResourceModel!.source!, isAuto: articleDTO!.isReadAudioAuto!) : null,
|
||||||
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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat, //miniEndTop
|
floatingActionButtonLocation: FloatingActionButtonLocation.miniEndFloat, //miniEndTop
|
||||||
);
|
);
|
||||||
@ -153,7 +147,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
boxShadow: const [kDefaultShadow],
|
boxShadow: const [kDefaultShadow],
|
||||||
),
|
),
|
||||||
child: SliderImagesWidget(
|
child: SliderImagesWidget(
|
||||||
resources: resourcesModel,
|
resources: widget.resourcesModel,
|
||||||
height: size.height * 0.29,
|
height: size.height * 0.29,
|
||||||
contentsDTO: articleDTO!.contents!,
|
contentsDTO: articleDTO!.contents!,
|
||||||
)
|
)
|
||||||
@ -178,7 +172,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
boxShadow: const [kDefaultShadow],
|
boxShadow: const [kDefaultShadow],
|
||||||
),
|
),
|
||||||
child: SliderImagesWidget(
|
child: SliderImagesWidget(
|
||||||
resources: resourcesModel,
|
resources: widget.resourcesModel,
|
||||||
height: size.height * 0.29,
|
height: size.height * 0.29,
|
||||||
contentsDTO: articleDTO!.contents!,
|
contentsDTO: articleDTO!.contents!,
|
||||||
)
|
)
|
||||||
@ -262,7 +256,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ArticleDTO?> getArticle(AppContext appContext, Client client, String articleId, bool isAudio) async {
|
/*Future<ArticleDTO?> getArticle(AppContext appContext, Client client, String articleId, bool isAudio) async {
|
||||||
try {
|
try {
|
||||||
if(sectionDTO == null || articleDTO == null) {
|
if(sectionDTO == null || articleDTO == null) {
|
||||||
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
||||||
@ -407,5 +401,5 @@ class _ArticlePageState extends State<ArticlePage> {
|
|||||||
print("IN CATCH");
|
print("IN CATCH");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'package:auto_size_text/auto_size_text.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:manager_api_new/api.dart';
|
import 'package:manager_api_new/api.dart';
|
||||||
import 'package:mymuseum_visitapp/Components/CustomAppBar.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/Components/loading_common.dart';
|
||||||
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
import 'package:mymuseum_visitapp/Helpers/DatabaseHelper.dart';
|
||||||
import 'package:mymuseum_visitapp/Helpers/modelsHelper.dart';
|
import 'package:mymuseum_visitapp/Helpers/modelsHelper.dart';
|
||||||
@ -109,7 +110,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
//floatingActionButton: ScannerBouton(appContext: appContext),
|
// floatingActionButton: ScannerBouton(appContext: appContext),
|
||||||
//floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterFloat,
|
//floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterFloat,
|
||||||
/*bottomNavigationBar: BottomNavigationBar(
|
/*bottomNavigationBar: BottomNavigationBar(
|
||||||
currentIndex: currentIndex,
|
currentIndex: currentIndex,
|
||||||
|
|||||||
360
lib/Screens/Home/home_3.0.dart
Normal file
360
lib/Screens/Home/home_3.0.dart
Normal file
@ -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<HomePage3> createState() => _HomePage3State();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HomePage3State extends State<HomePage3> with WidgetsBindingObserver {
|
||||||
|
int currentIndex = 0;
|
||||||
|
|
||||||
|
late List<ConfigurationDTO> configurations = [];
|
||||||
|
List<String?> alreadyDownloaded = [];
|
||||||
|
late VisitAppContext visitAppContext;
|
||||||
|
|
||||||
|
final List<Color> 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<AppContext>(context);
|
||||||
|
visitAppContext = appContext.getContext();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: FutureBuilder(
|
||||||
|
future: getConfigurationsCall(visitAppContext.clientAPI, appContext),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
configurations = List<ConfigurationDTO>.from(snapshot.data).where((configuration) => configuration.isMobile!).toList();
|
||||||
|
|
||||||
|
//String cleanedTitle = configurations[0].title.replaceAll('\n', ' ').replaceAll('<br>', ' '); // 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<dynamic> 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<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
configurations = List<ConfigurationDTO>.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<List<ConfigurationDTO>?> getConfigurationsCall(Client client, AppContext appContext) async {
|
||||||
|
bool isOnline = await hasNetwork();
|
||||||
|
VisitAppContext visitAppContext = appContext.getContext();
|
||||||
|
|
||||||
|
List<ConfigurationDTO>? configurations;
|
||||||
|
configurations = List<ConfigurationDTO>.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<SectionDTO>.from(await DatabaseHelper.instance.queryWithConfigurationId(DatabaseTableType.sections, configuration.id!));
|
||||||
|
configuration.sectionIds = sections.map((e) => e.id!).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET BEACONS FROM LOCAL
|
||||||
|
List<BeaconSection> beaconSections = List<BeaconSection>.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<SectionDTO>? sections = await ApiService.getAllBeacons(client, visitAppContext.instanceId!);
|
||||||
|
if(sections != null && sections.isNotEmpty) {
|
||||||
|
List<BeaconSection> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,17 +23,18 @@ import 'package:mymuseum_visitapp/client.dart';
|
|||||||
import 'package:mymuseum_visitapp/constants.dart';
|
import 'package:mymuseum_visitapp/constants.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class QuizzPage extends StatefulWidget {
|
class QuizPage extends StatefulWidget {
|
||||||
const QuizzPage({Key? key, required this.visitAppContextIn, required this.sectionId}) : super(key: key);
|
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 VisitAppContext visitAppContextIn;
|
||||||
|
final List<ResourceModel?> resourcesModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<QuizzPage> createState() => _QuizzPageState();
|
State<QuizPage> createState() => _QuizPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _QuizzPageState extends State<QuizzPage> {
|
class _QuizPageState extends State<QuizPage> {
|
||||||
SectionDTO? sectionDTO;
|
SectionDTO? sectionDTO;
|
||||||
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
||||||
ResourceModel? audioResourceModel;
|
ResourceModel? audioResourceModel;
|
||||||
@ -89,42 +90,39 @@ class _QuizzPageState extends State<QuizzPage> {
|
|||||||
),
|
),
|
||||||
body: OrientationBuilder(
|
body: OrientationBuilder(
|
||||||
builder: (context, orientation) {
|
builder: (context, orientation) {
|
||||||
return FutureBuilder(
|
if(quizDTO != null && sectionDTO != null) {
|
||||||
future: getQuizz(appContext, visitAppContext.clientAPI, widget.sectionId), // MAYBE MOVE THAT TO PARENT ..
|
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
||||||
if(quizDTO != null && sectionDTO != null) {
|
|
||||||
|
|
||||||
if(showResult) {
|
if(showResult) {
|
||||||
var goodResponses = 0;
|
var goodResponses = 0;
|
||||||
for (var question in _questionsSubDTO) {
|
for (var question in _questionsSubDTO) {
|
||||||
if(question.chosen == question.responsesSubDTO!.indexWhere((response) => response.isGood!)) {
|
if(question.chosen == question.responsesSubDTO!.indexWhere((response) => response.isGood!)) {
|
||||||
goodResponses +=1;
|
goodResponses +=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log("goodResponses =" + goodResponses.toString());
|
log("goodResponses =" + goodResponses.toString());
|
||||||
List<TranslationAndResourceDTO> levelToShow = [];
|
List<TranslationAndResourceDTO> levelToShow = [];
|
||||||
var test = goodResponses/quizDTO!.questions!.length;
|
var test = goodResponses/quizDTO!.questions!.length;
|
||||||
|
|
||||||
if((0 == test || test < 0.25) && quizDTO!.badLevel != null) {
|
if((0 == test || test < 0.25) && quizDTO!.badLevel != null) {
|
||||||
levelToShow = quizDTO!.badLevel!;
|
levelToShow = quizDTO!.badLevel!;
|
||||||
}
|
}
|
||||||
if((test>=0.25 && test < 0.5) && quizDTO!.mediumLevel != null) {
|
if((test>=0.25 && test < 0.5) && quizDTO!.mediumLevel != null) {
|
||||||
levelToShow = quizDTO!.mediumLevel!;
|
levelToShow = quizDTO!.mediumLevel!;
|
||||||
}
|
}
|
||||||
if((test>=0.5 && test < 0.75) && quizDTO!.goodLevel != null) {
|
if((test>=0.5 && test < 0.75) && quizDTO!.goodLevel != null) {
|
||||||
levelToShow = quizDTO!.goodLevel!;
|
levelToShow = quizDTO!.goodLevel!;
|
||||||
}
|
}
|
||||||
if((test>=0.75 && test <= 1) && quizDTO!.greatLevel != null) {
|
if((test>=0.75 && test <= 1) && quizDTO!.greatLevel != null) {
|
||||||
levelToShow = quizDTO!.greatLevel!;
|
levelToShow = quizDTO!.greatLevel!;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
/*Center(
|
/*Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 5,
|
height: 5,
|
||||||
@ -145,78 +143,76 @@ class _QuizzPageState extends State<QuizzPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),*/
|
),*/
|
||||||
if (orientation == Orientation.portrait)
|
if (orientation == Orientation.portrait)
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) // TODO SUPPORT OTHER THAN IMAGES
|
if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null) // TODO SUPPORT OTHER THAN IMAGES
|
||||||
resultImage(visitAppContext, size, levelToShow, orientation),
|
resultImage(visitAppContext, size, levelToShow, orientation),
|
||||||
if(!showResponses)
|
if(!showResponses)
|
||||||
// TEXT BOX WITH MAIN SCORE
|
// TEXT BOX WITH MAIN SCORE
|
||||||
Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)),
|
Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
if (orientation == Orientation.landscape)
|
if (orientation == Orientation.landscape)
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
if(!showResponses)
|
if(!showResponses)
|
||||||
// TEXT BOX WITH MAIN SCORE
|
// TEXT BOX WITH MAIN SCORE
|
||||||
Text('$goodResponses/${quizDTO!.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 75, color: kBackgroundSecondGrey)),
|
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)
|
if (!showResponses && levelToShow.firstWhere((label) => label.language == visitAppContext.language).resource?.url != null)
|
||||||
resultImage(visitAppContext, size, levelToShow, orientation),
|
resultImage(visitAppContext, size, levelToShow, orientation),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
if(!showResponses)
|
if(!showResponses)
|
||||||
// TEXT BOX WITH LEVEL TEXT RESULT
|
// TEXT BOX WITH LEVEL TEXT RESULT
|
||||||
resultText(size, levelToShow, appContext),
|
resultText(size, levelToShow, appContext),
|
||||||
if(showResponses)
|
if(showResponses)
|
||||||
QuestionsListWidget(
|
QuestionsListWidget(
|
||||||
questionsSubDTO: _questionsSubDTO,
|
questionsSubDTO: _questionsSubDTO,
|
||||||
isShowResponse: true,
|
isShowResponse: true,
|
||||||
onShowResponse: () {},
|
onShowResponse: () {},
|
||||||
orientation: orientation,
|
orientation: orientation,
|
||||||
),
|
),
|
||||||
// RESPONSE BOX
|
// RESPONSE BOX
|
||||||
//ShowReponsesWidget(questionsSubDTO: _questionsSubDTO),
|
//ShowReponsesWidget(questionsSubDTO: _questionsSubDTO),
|
||||||
|
|
||||||
if(orientation == Orientation.portrait && !showResponses)
|
if(orientation == Orientation.portrait && !showResponses)
|
||||||
// Buttons
|
// Buttons
|
||||||
Column(
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: resultButtons(size, orientation, visitAppContext!),
|
children: resultButtons(size, orientation, visitAppContext!),
|
||||||
),
|
),
|
||||||
if(orientation == Orientation.landscape && !showResponses)
|
if(orientation == Orientation.landscape && !showResponses)
|
||||||
// Buttons
|
// Buttons
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: resultButtons(size, orientation, visitAppContext!),
|
children: resultButtons(size, orientation, visitAppContext!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return QuestionsListWidget(
|
return QuestionsListWidget(
|
||||||
isShowResponse: false,
|
isShowResponse: false,
|
||||||
questionsSubDTO: _questionsSubDTO,
|
questionsSubDTO: _questionsSubDTO,
|
||||||
onShowResponse: () {
|
onShowResponse: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
showResult = true;
|
showResult = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
orientation: orientation,
|
orientation: orientation,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return const LoadingCommon();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
} else {
|
||||||
|
return const LoadingCommon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
floatingActionButton: showResponses ? FloatingActionButton(
|
floatingActionButton: showResponses ? FloatingActionButton(
|
||||||
@ -235,7 +231,7 @@ class _QuizzPageState extends State<QuizzPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<QuizDTO?> getQuizz(AppContext appContext, Client client, String sectionId) async {
|
/*Future<QuizDTO?> getQuizz(AppContext appContext, Client client, String sectionId) async {
|
||||||
try {
|
try {
|
||||||
if(sectionDTO == null || quizDTO == null) {
|
if(sectionDTO == null || quizDTO == null) {
|
||||||
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
||||||
@ -312,7 +308,7 @@ class _QuizzPageState extends State<QuizzPage> {
|
|||||||
print("IN CATCH");
|
print("IN CATCH");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
resultImage(VisitAppContext visitAppContext, Size size, List<TranslationAndResourceDTO> levelToShow, Orientation orientation) {
|
resultImage(VisitAppContext visitAppContext, Size size, List<TranslationAndResourceDTO> levelToShow, Orientation orientation) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:mymuseum_visitapp/Components/CustomAppBar.dart';
|
import 'package:mymuseum_visitapp/Components/CustomAppBar.dart';
|
||||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Article/article_page.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:mymuseum_visitapp/app_context.dart';
|
||||||
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
import 'package:qr_code_scanner/qr_code_scanner.dart';
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ class _ScannerPageState extends State<ScannerPage> {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ArticlePage(articleId: code, visitAppContextIn: VisitAppContext()); // will not work..
|
return SectionPage(sectionId: code, visitAppContextIn: VisitAppContext()); // will not work..
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import 'package:mymuseum_visitapp/Helpers/translationHelper.dart';
|
|||||||
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
import 'package:mymuseum_visitapp/Models/visitContext.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Article/article_page.dart';
|
import 'package:mymuseum_visitapp/Screens/Article/article_page.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Quizz/quizz_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/Services/apiService.dart';
|
||||||
import 'package:mymuseum_visitapp/app_context.dart';
|
import 'package:mymuseum_visitapp/app_context.dart';
|
||||||
import 'package:mymuseum_visitapp/constants.dart';
|
import 'package:mymuseum_visitapp/constants.dart';
|
||||||
@ -101,33 +102,15 @@ class _BodyState extends State<Body> {
|
|||||||
itemIndex: index,
|
itemIndex: index,
|
||||||
sectionDTO: sectionsToDisplay[index],
|
sectionDTO: sectionsToDisplay[index],
|
||||||
press: () {
|
press: () {
|
||||||
switch(sectionsToDisplay[index].type) {
|
Navigator.push(
|
||||||
case SectionType.Article:
|
context,
|
||||||
Navigator.push(
|
MaterialPageRoute(
|
||||||
context,
|
builder: (context) => SectionPage(
|
||||||
MaterialPageRoute(
|
visitAppContextIn: appContext.getContext(),
|
||||||
builder: (context) => ArticlePage(
|
sectionId: sectionsToDisplay[index].id!,
|
||||||
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;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -137,9 +120,9 @@ class _BodyState extends State<Body> {
|
|||||||
return Text(TranslationHelper.getFromLocale("noData", appContext.getContext()));
|
return Text(TranslationHelper.getFromLocale("noData", appContext.getContext()));
|
||||||
} else {
|
} else {
|
||||||
return Center(
|
return Center(
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
height: size.height * 0.15,
|
height: size.height * 0.15,
|
||||||
child: LoadingCommon()
|
child: const LoadingCommon()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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/Article/article_page.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Quizz/quizz_page.dart';
|
import 'package:mymuseum_visitapp/Screens/Quizz/quizz_page.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Visit/beaconArticleFound.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/app_context.dart';
|
||||||
import 'package:mymuseum_visitapp/constants.dart';
|
import 'package:mymuseum_visitapp/constants.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
@ -287,33 +288,15 @@ class _VisitPageState extends State<VisitPage> with WidgetsBindingObserver {
|
|||||||
//visitAppContext.isArticleCurrentlyShown = true;
|
//visitAppContext.isArticleCurrentlyShown = true;
|
||||||
lastTimePopUpWasClosed = DateTime.now();
|
lastTimePopUpWasClosed = DateTime.now();
|
||||||
|
|
||||||
switch(beaconSection!.sectionType!) {
|
Navigator.push(
|
||||||
case SectionType.Article:
|
context,
|
||||||
Navigator.push(
|
MaterialPageRoute(
|
||||||
context,
|
builder: (context) => SectionPage(
|
||||||
MaterialPageRoute(
|
visitAppContextIn: visitAppContext,
|
||||||
builder: (context) => ArticlePage(
|
sectionId: beaconSection!.sectionId!,
|
||||||
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;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'dart:developer';
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
//import 'package:confetti/confetti.dart';
|
//import 'package:confetti/confetti.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_api_new/api.dart';
|
import 'package:manager_api_new/api.dart';
|
||||||
import 'package:mymuseum_visitapp/Components/CustomAppBar.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/articleRead.dart';
|
||||||
import 'package:mymuseum_visitapp/Models/resourceModel.dart';
|
import 'package:mymuseum_visitapp/Models/resourceModel.dart';
|
||||||
import 'package:mymuseum_visitapp/Models/visitContext.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/drawPath.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Quizz/questions_list.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/Screens/Quizz/showResponses.dart';
|
||||||
import 'package:mymuseum_visitapp/app_context.dart';
|
import 'package:mymuseum_visitapp/app_context.dart';
|
||||||
import 'package:mymuseum_visitapp/client.dart';
|
import 'package:mymuseum_visitapp/client.dart';
|
||||||
@ -38,14 +41,11 @@ class _SectionPageState extends State<SectionPage> {
|
|||||||
SectionDTO? sectionDTO;
|
SectionDTO? sectionDTO;
|
||||||
late VisitAppContext visitAppContext;
|
late VisitAppContext visitAppContext;
|
||||||
late dynamic rawSectionData;
|
late dynamic rawSectionData;
|
||||||
|
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
widget.visitAppContextIn.isContentCurrentlyShown = true;
|
widget.visitAppContextIn.isContentCurrentlyShown = true;
|
||||||
|
|
||||||
//_controllerCenter = ConfettiController(duration: const Duration(seconds: 10));
|
|
||||||
//_controllerCenter!.play();
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,127 +70,18 @@ class _SectionPageState extends State<SectionPage> {
|
|||||||
body: OrientationBuilder(
|
body: OrientationBuilder(
|
||||||
builder: (context, orientation) {
|
builder: (context, orientation) {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: getSectionDetail(appContext, visitAppContext.clientAPI, widget.sectionId), // MAYBE MOVE THAT TO PARENT ..
|
future: getSectionDetail(appContext, visitAppContext.clientAPI, widget.sectionId),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
if(quizDTO != null && sectionDTO != null) {
|
if(sectionDTO != null) {
|
||||||
|
switch(sectionDTO!.type) {
|
||||||
if(showResult) {
|
case SectionType.Article:
|
||||||
var goodResponses = 0;
|
ArticleDTO articleDTO = ArticleDTO.fromJson(rawSectionData)!;
|
||||||
for (var question in _questionsSubDTO) {
|
return ArticlePage(visitAppContextIn: widget.visitAppContextIn, articleDTO: articleDTO, resourcesModel: resourcesModel);
|
||||||
if(question.chosen == question.responsesSubDTO!.indexWhere((response) => response.isGood!)) {
|
case SectionType.Quiz:
|
||||||
goodResponses +=1;
|
QuizDTO quizDTO = QuizDTO.fromJson(rawSectionData)!;
|
||||||
}
|
return QuizPage(visitAppContextIn: widget.visitAppContextIn, quizDTO: quizDTO, resourcesModel: resourcesModel);
|
||||||
}
|
default:
|
||||||
log("goodResponses =" + goodResponses.toString());
|
return const Center(child: Text("Unsupported type"));
|
||||||
List<TranslationAndResourceDTO> 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,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return const LoadingCommon();
|
return const LoadingCommon();
|
||||||
@ -198,20 +89,7 @@ class _SectionPageState extends State<SectionPage> {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
),
|
)
|
||||||
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<SectionPage> {
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// ONLINE
|
// ONLINE
|
||||||
SectionDTO? sectionOnline = await client.sectionApi!.sectionGetDetail(sectionId);
|
rawSectionData = await client.sectionApi!.sectionGetDetail(sectionId);
|
||||||
if(sectionOnline != null) {
|
SectionDTO sectionOnline = jsonDecode(jsonEncode(rawSectionData)).map((json) => SectionDTO.fromJson(json)).whereType<SectionDTO>().toList();
|
||||||
sectionDTO = sectionOnline;
|
sectionDTO = sectionOnline;
|
||||||
} else {
|
|
||||||
print("EMPTY SECTION");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sectionDTO!.type == SectionType.Quiz) {
|
switch(sectionDTO!.type)
|
||||||
quizDTO = QuizDTO.fromJson(jsonDecode(sectionDTO!.data!));
|
{
|
||||||
}
|
case SectionType.Quiz:
|
||||||
if(quizDTO != null) {
|
QuizDTO? quizDTO = QuizDTO.fromJson(jsonDecode(rawSectionData));
|
||||||
quizDTO!.questions!.sort((a, b) => a.order!.compareTo(b.order!));
|
if(quizDTO != null) {
|
||||||
_questionsSubDTO = QuestionSubDTO().fromJSON(quizDTO!.questions!);
|
quizDTO.questions!.sort((a, b) => a.order!.compareTo(b.order!));
|
||||||
if(quizDTO!.questions != null && quizDTO!.questions!.isNotEmpty) {
|
if(quizDTO.questions != null && quizDTO.questions!.isNotEmpty) {
|
||||||
quizDTO!.questions!.sort((a, b) => a.order!.compareTo(b.order!));
|
quizDTO.questions!.sort((a, b) => a.order!.compareTo(b.order!));
|
||||||
for (var question in quizDTO!.questions!) {
|
for (var question in quizDTO.questions!) {
|
||||||
if(isConfigOffline)
|
if(isConfigOffline)
|
||||||
{
|
{
|
||||||
// OFFLINE
|
// OFFLINE
|
||||||
if(question.imageBackgroundResourceId != null) {
|
if(question.imageBackgroundResourceId != null) {
|
||||||
List<Map<String, dynamic>> ressourceQuizz = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, question.imageBackgroundResourceId!);
|
List<Map<String, dynamic>> ressourceQuizz = await DatabaseHelper.instance.queryWithColumnId(DatabaseTableType.resources, question.imageBackgroundResourceId!);
|
||||||
if(ressourceQuizz.isNotEmpty) {
|
if(ressourceQuizz.isNotEmpty) {
|
||||||
resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(ressourceQuizz.first));
|
resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(ressourceQuizz.first));
|
||||||
} else {
|
} else {
|
||||||
print("EMPTY resourcesModel - second");
|
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);
|
//print(sectionDTO!.title);
|
||||||
});
|
});*/
|
||||||
} else {
|
} else {
|
||||||
return null; // TODO return local list..
|
return null; // TODO return local list..
|
||||||
}
|
}
|
||||||
@ -293,131 +172,4 @@ class _SectionPageState extends State<SectionPage> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resultImage(VisitAppContext visitAppContext, Size size, List<TranslationAndResourceDTO> 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<TranslationAndResourceDTO> 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
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class ApiService {
|
|||||||
if(configurations.isNotEmpty) {
|
if(configurations.isNotEmpty) {
|
||||||
for(var configuration in configurations) {
|
for(var configuration in configurations) {
|
||||||
if(configuration.imageId != null) {
|
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) {
|
if(isOnline) {
|
||||||
ResourceModel? resourceModel = await downloadImage(client, contentDTO);
|
ResourceModel? resourceModel = await downloadImage(client, contentDTO);
|
||||||
if(resourceModel != null) {
|
if(resourceModel != null) {
|
||||||
await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
//await DatabaseHelper.instance.insert(DatabaseTableType.resources, resourceModel.toMap());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -176,8 +176,10 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Endpoint back with all resources ? Just all get all resourceDTO from a configuration..
|
||||||
|
|
||||||
// Download all images..
|
// Download all images..
|
||||||
ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!));
|
/*ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!)); // TODO section data
|
||||||
|
|
||||||
if(articleDTO != null) {
|
if(articleDTO != null) {
|
||||||
for(var image in articleDTO.contents!) {
|
for(var image in articleDTO.contents!) {
|
||||||
@ -200,7 +202,7 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
|
|||||||
//audiosNotWorking = await importAudio(visitAppContext, exportConfigurationDTO, audioId.value!, audiosNotWorking);
|
//audiosNotWorking = await importAudio(visitAppContext, exportConfigurationDTO, audioId.value!, audiosNotWorking);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
newOrder = newOrder + 1;
|
newOrder = newOrder + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart';
|
import 'package:mymuseum_visitapp/Helpers/requirement_state_controller.dart';
|
||||||
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
import 'package:mymuseum_visitapp/Models/articleRead.dart';
|
||||||
import 'package:mymuseum_visitapp/Screens/Home/home.dart';
|
import 'package:mymuseum_visitapp/Screens/Home/home.dart';
|
||||||
|
import 'package:mymuseum_visitapp/Screens/Home/home_3.0.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'Helpers/DatabaseHelper.dart';
|
import 'Helpers/DatabaseHelper.dart';
|
||||||
import 'Models/visitContext.dart';
|
import 'Models/visitContext.dart';
|
||||||
@ -93,7 +94,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
create: (_) => AppContext(widget.visitAppContext),
|
create: (_) => AppContext(widget.visitAppContext),
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
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,
|
initialRoute: widget.initialRoute,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
AppLocalizations.delegate,
|
AppLocalizations.delegate,
|
||||||
@ -101,9 +102,9 @@ class _MyAppState extends State<MyApp> {
|
|||||||
GlobalWidgetsLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
],
|
],
|
||||||
supportedLocales: [
|
supportedLocales: const[
|
||||||
const Locale('en', ''),
|
Locale('en', ''),
|
||||||
const Locale('fr', ''),
|
Locale('fr', ''),
|
||||||
],
|
],
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
@ -116,7 +117,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
routes: {
|
routes: {
|
||||||
'/home': (context) => const HomePage(),
|
'/home': (context) => const HomePage3(),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -331,6 +331,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
flutter_svg:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -55,6 +55,7 @@ dependencies:
|
|||||||
sqflite: #not in web
|
sqflite: #not in web
|
||||||
just_audio_cache: ^0.1.2 #not in web
|
just_audio_cache: ^0.1.2 #not in web
|
||||||
flutter_beacon: ^0.5.1 #not in web
|
flutter_beacon: ^0.5.1 #not in web
|
||||||
|
flutter_staggered_grid_view: ^0.7.0
|
||||||
|
|
||||||
manager_api_new:
|
manager_api_new:
|
||||||
path: manager_api_new
|
path: manager_api_new
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user