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/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<ScannerDialog> {
|
||||
|
||||
} 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!);
|
||||
return SectionPage(visitAppContextIn: visitAppContext, sectionId: 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"],
|
||||
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"]),
|
||||
);
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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 = "";
|
||||
|
||||
@ -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<ResourceModel?> resourcesModel;
|
||||
|
||||
@override
|
||||
State<ArticlePage> createState() => _ArticlePageState();
|
||||
@ -36,7 +37,6 @@ class ArticlePage extends StatefulWidget {
|
||||
class _ArticlePageState extends State<ArticlePage> {
|
||||
SectionDTO? sectionDTO;
|
||||
ArticleDTO? articleDTO;
|
||||
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
||||
ResourceModel? audioResourceModel;
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
File? audioFile;
|
||||
@ -69,19 +69,18 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
isHomeButton: false,
|
||||
isTextSizeButton: true,
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: getArticle(appContext, visitAppContext.clientAPI, widget.articleDTO.id, false),
|
||||
builder: (context, AsyncSnapshot<dynamic> 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<ArticlePage> {
|
||||
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<ArticlePage> {
|
||||
}
|
||||
}
|
||||
),
|
||||
floatingActionButton: FutureBuilder(
|
||||
future: getArticle(appContext, visitAppContext.clientAPI, widget.articleId, true),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(right: 0, top: 0), //size.height*0.1
|
||||
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<ArticlePage> {
|
||||
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<ArticlePage> {
|
||||
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<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 {
|
||||
if(sectionDTO == null || articleDTO == null) {
|
||||
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
||||
@ -407,5 +401,5 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
print("IN CATCH");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@ -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<HomePage> with WidgetsBindingObserver {
|
||||
],
|
||||
)
|
||||
),
|
||||
//floatingActionButton: ScannerBouton(appContext: appContext),
|
||||
// floatingActionButton: ScannerBouton(appContext: appContext),
|
||||
//floatingActionButtonLocation: FloatingActionButtonLocation.miniCenterFloat,
|
||||
/*bottomNavigationBar: BottomNavigationBar(
|
||||
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: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<ResourceModel?> resourcesModel;
|
||||
|
||||
@override
|
||||
State<QuizzPage> createState() => _QuizzPageState();
|
||||
State<QuizPage> createState() => _QuizPageState();
|
||||
}
|
||||
|
||||
class _QuizzPageState extends State<QuizzPage> {
|
||||
class _QuizPageState extends State<QuizPage> {
|
||||
SectionDTO? sectionDTO;
|
||||
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
||||
ResourceModel? audioResourceModel;
|
||||
@ -89,9 +90,6 @@ class _QuizzPageState extends State<QuizzPage> {
|
||||
),
|
||||
body: OrientationBuilder(
|
||||
builder: (context, orientation) {
|
||||
return FutureBuilder(
|
||||
future: getQuizz(appContext, visitAppContext.clientAPI, widget.sectionId), // MAYBE MOVE THAT TO PARENT ..
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if(quizDTO != null && sectionDTO != null) {
|
||||
|
||||
if(showResult) {
|
||||
@ -216,8 +214,6 @@ class _QuizzPageState extends State<QuizzPage> {
|
||||
return const LoadingCommon();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
),
|
||||
floatingActionButton: showResponses ? FloatingActionButton(
|
||||
onPressed: () {
|
||||
@ -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 {
|
||||
if(sectionDTO == null || quizDTO == null) {
|
||||
bool isConfigOffline = (appContext.getContext() as VisitAppContext).configuration!.isOffline!;
|
||||
@ -312,7 +308,7 @@ class _QuizzPageState extends State<QuizzPage> {
|
||||
print("IN CATCH");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
resultImage(VisitAppContext visitAppContext, Size size, List<TranslationAndResourceDTO> levelToShow, Orientation orientation) {
|
||||
return Container(
|
||||
|
||||
@ -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<ScannerPage> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
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/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<Body> {
|
||||
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(
|
||||
builder: (context) => SectionPage(
|
||||
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()));
|
||||
} else {
|
||||
return Center(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
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/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<VisitPage> with WidgetsBindingObserver {
|
||||
//visitAppContext.isArticleCurrentlyShown = true;
|
||||
lastTimePopUpWasClosed = DateTime.now();
|
||||
|
||||
switch(beaconSection!.sectionType!) {
|
||||
case SectionType.Article:
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ArticlePage(
|
||||
builder: (context) => SectionPage(
|
||||
visitAppContextIn: visitAppContext,
|
||||
articleId: beaconSection.sectionId!,
|
||||
sectionId: 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 '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<SectionPage> {
|
||||
SectionDTO? sectionDTO;
|
||||
late VisitAppContext visitAppContext;
|
||||
late dynamic rawSectionData;
|
||||
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
||||
|
||||
@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<SectionPage> {
|
||||
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<dynamic> 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<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,
|
||||
);
|
||||
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<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,23 +119,20 @@ class _SectionPageState extends State<SectionPage> {
|
||||
} else
|
||||
{
|
||||
// ONLINE
|
||||
SectionDTO? sectionOnline = await client.sectionApi!.sectionGetDetail(sectionId);
|
||||
if(sectionOnline != null) {
|
||||
rawSectionData = await client.sectionApi!.sectionGetDetail(sectionId);
|
||||
SectionDTO sectionOnline = jsonDecode(jsonEncode(rawSectionData)).map((json) => SectionDTO.fromJson(json)).whereType<SectionDTO>().toList();
|
||||
sectionDTO = sectionOnline;
|
||||
} else {
|
||||
print("EMPTY SECTION");
|
||||
}
|
||||
}
|
||||
|
||||
if(sectionDTO!.type == SectionType.Quiz) {
|
||||
quizDTO = QuizDTO.fromJson(jsonDecode(sectionDTO!.data!));
|
||||
}
|
||||
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!));
|
||||
_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!) {
|
||||
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
|
||||
@ -280,10 +155,14 @@ class _SectionPageState extends State<SectionPage> {
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
/*setState(() {
|
||||
//print(sectionDTO!.title);
|
||||
});
|
||||
});*/
|
||||
} else {
|
||||
return null; // TODO return local list..
|
||||
}
|
||||
@ -293,131 +172,4 @@ class _SectionPageState extends State<SectionPage> {
|
||||
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) {
|
||||
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 {
|
||||
|
||||
@ -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..
|
||||
ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!));
|
||||
/*ArticleDTO? articleDTO = ArticleDTO.fromJson(jsonDecode(section.data!)); // TODO section data
|
||||
|
||||
if(articleDTO != null) {
|
||||
for(var image in articleDTO.contents!) {
|
||||
@ -200,7 +202,7 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
|
||||
//audiosNotWorking = await importAudio(visitAppContext, exportConfigurationDTO, audioId.value!, audiosNotWorking);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
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/Models/articleRead.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 'Helpers/DatabaseHelper.dart';
|
||||
import 'Models/visitContext.dart';
|
||||
@ -93,7 +94,7 @@ class _MyAppState extends State<MyApp> {
|
||||
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<MyApp> {
|
||||
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<MyApp> {
|
||||
),
|
||||
),
|
||||
routes: {
|
||||
'/home': (context) => const HomePage(),
|
||||
'/home': (context) => const HomePage3(),
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user