wip version 3.0

This commit is contained in:
Thomas Fransolet 2025-05-27 16:20:29 +02:00
parent 0cd2b47211
commit 50e2fc393f
14 changed files with 77 additions and 85 deletions

View File

@ -146,7 +146,7 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
TabletAppContext tabletAppContext = appContext.getContext(); TabletAppContext tabletAppContext = appContext.getContext();
return FloatingActionButton( return FloatingActionButton(
backgroundColor: new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)).withOpacity(0.7), backgroundColor: new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16)).withValues(alpha: 0.7),
onPressed: () async { onPressed: () async {
if(!isplaying && !audioplayed){ if(!isplaying && !audioplayed){
//player.play(BytesSource(audiobytes)); //player.play(BytesSource(audiobytes));

View File

@ -74,7 +74,7 @@ class _VideoViewer extends State<VideoViewer> {
if(!_controller.value.isPlaying && _controller.value.isInitialized) if(!_controller.value.isPlaying && _controller.value.isInitialized)
Center( Center(
child: FloatingActionButton( child: FloatingActionButton(
backgroundColor: kTestSecondColor.withOpacity(0.8), backgroundColor: kTestSecondColor.withValues(alpha: 0.8),
onPressed: () { onPressed: () {
setState(() { setState(() {
_controller.value.isPlaying _controller.value.isPlaying

View File

@ -100,7 +100,7 @@ class _AgendaView extends State<AgendaView> {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) { if (snapshot.data == null) {
return Center( return Center(
child: Text("Le json n'est pas valide") child: Text("Le fichier choisi n'est pas valide")
); );
} else { } else {
return Center( return Center(

View File

@ -117,7 +117,7 @@ class _MainViewWidget extends State<MainViewWidget> {
decoration: configurationDTO.imageId != null ? BoxDecoration( decoration: configurationDTO.imageId != null ? BoxDecoration(
image: new DecorationImage( image: new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.grey.withOpacity(0.1), BlendMode.color), colorFilter: new ColorFilter.mode(Colors.grey.withValues(alpha: 0.1), BlendMode.color),
image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!) image: ImageCustomProvider.getImageProvider(appContext, configurationDTO.imageId!, configurationDTO.imageSource!)
), ),
) : null, ) : null,
@ -281,17 +281,9 @@ class _MainViewWidget extends State<MainViewWidget> {
if(isInit) { if(isInit) {
try { try {
final rawList = await tabletAppContext.clientAPI!.sectionApi!.sectionGetFromConfigurationDetail(tabletAppContext.configuration!.id!); final rawList = await tabletAppContext.clientAPI!.sectionApi!.sectionGetFromConfigurationDetail(tabletAppContext.configuration!.id!);
//var sections = rawList.map((json) => SectionDTO.fromJson(json)).toList();
rawSectionsData = jsonDecode(jsonEncode(rawList)); rawSectionsData = jsonDecode(jsonEncode(rawList));
rawSectionsData = rawSectionsData.map((json) => SectionDTO.fromJson(json)).toList(); List<SectionDTO> sectionList = jsonDecode(jsonEncode(rawSectionsData)).map((json) => SectionDTO.fromJson(json)).whereType<SectionDTO>().toList();
List<SectionDTO> sectionList = rawSectionsData.whereType<SectionDTO>().toList();
sectionList.sort((a, b) => a.order!.compareTo(b.order!));
/*List<SectionDTO>? sections = await tabletAppContext.clientAPI!.sectionApi!.sectionGetFromConfiguration(tabletAppContext.configuration!.id!);
sections!.sort((a, b) => a.order!.compareTo(b.order!));*/
sectionsLocal = sectionList; sectionsLocal = sectionList;
isInit = false; isInit = false;
return sectionList; return sectionList;
@ -342,7 +334,7 @@ class _MainViewWidget extends State<MainViewWidget> {
}); });
}, },
child: Container( child: Container(
decoration: isImageBackground ? boxDecoration(appContext, sectionsLocal![index], false) : null, decoration: isImageBackground ? boxDecoration(appContext, sectionsLocal![index], false, rawSectionsData[index]) : null,
//color: Colors.yellow, //color: Colors.yellow,
padding: EdgeInsets.all(isImageBackground ? 18 : 5), padding: EdgeInsets.all(isImageBackground ? 18 : 5),
margin: EdgeInsets.symmetric(vertical: isImageBackground ? 25 : 10, horizontal: 25), margin: EdgeInsets.symmetric(vertical: isImageBackground ? 25 : 10, horizontal: 25),
@ -377,7 +369,7 @@ class _MainViewWidget extends State<MainViewWidget> {
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
image: sectionsLocal![index].imageSource != null || sectionsLocal![index].type == SectionType.Video ? new DecorationImage( image: sectionsLocal![index].imageSource != null || sectionsLocal![index].type == SectionType.Video ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
image: ImageCustomProvider.getImageProvider(appContext, sectionsLocal![index].imageId, sectionsLocal![index].type == SectionType.Video ? getYoutubeThumbnailUrl(sectionsLocal![index]) : sectionsLocal![index].imageSource!), image: ImageCustomProvider.getImageProvider(appContext, sectionsLocal![index].imageId, sectionsLocal![index].type == SectionType.Video ? getYoutubeThumbnailUrl(rawSectionsData[index]) : sectionsLocal![index].imageSource!),
): null, ): null,
), ),
) )
@ -415,7 +407,7 @@ class _MainViewWidget extends State<MainViewWidget> {
} }
} }
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { boxDecoration(AppContext appContext, SectionDTO section, bool isSelected, Object rawSectionData) {
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
return BoxDecoration( return BoxDecoration(
color: !isSelected ? kBackgroundLight : section.imageSource == null ? kBackgroundLight : null, color: !isSelected ? kBackgroundLight : section.imageSource == null ? kBackgroundLight : null,
@ -423,8 +415,8 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
image: section.imageSource != null || section.type == SectionType.Video ? new DecorationImage( image: section.imageSource != null || section.type == SectionType.Video ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withValues(alpha: 0.2), BlendMode.dstATop) : null,
image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(section) : section.imageSource!), image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(rawSectionData) : section.imageSource!),
): null, ): null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
@ -532,7 +524,7 @@ Widget getContent(TabletAppContext tabletAppContext, SectionDTO sectionSelected,
future: getByteIcons(tabletAppContext, mapDTO), future: getByteIcons(tabletAppContext, mapDTO),
builder: (context, AsyncSnapshot<dynamic> snapshot) { builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
return MapView(section: sectionSelected, icons: snapshot.data); return MapView(section: mapDTO, icons: snapshot.data);
} else if (snapshot.connectionState == ConnectionState.none) { } else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data"); return Text("No data");
} else { } else {
@ -580,6 +572,6 @@ Widget getContent(TabletAppContext tabletAppContext, SectionDTO sectionSelected,
WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!; WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!;
return WeatherView(section: weatherDTO); return WeatherView(section: weatherDTO);
default: default:
return Text("Ce type n'est pas supporté"); return Center(child: Text("Ce type n'est pas supporté"));
}; };
} }

View File

@ -249,7 +249,7 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0),
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withValues(alpha: 0.2), BlendMode.dstATop) : null,
image: ImageCustomProvider.getImageProvider(appContext, section.imageId!, section.imageSource!), image: ImageCustomProvider.getImageProvider(appContext, section.imageId!, section.imageSource!),
): null, ): null,
boxShadow: [ boxShadow: [

View File

@ -73,7 +73,7 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
List<TreeNode> nodes = []; List<TreeNode> nodes = [];
// Pour chaque point sans categorie, créer un noeud // Pour chaque point sans categorie, créer un noeud
for(var pointWithoutCat in geoPoints.where((gp) => gp.categorieId == null && gp.categorie == null)) for(var pointWithoutCat in geoPoints.where((gp) => gp.categorieId == null))
{ {
if(pointWithoutCat.title!.where((l) => l.language == widget.language).firstOrNull != null) { if(pointWithoutCat.title!.where((l) => l.language == widget.language).firstOrNull != null) {
TreeNode nodeWithoutCat = TreeNode( TreeNode nodeWithoutCat = TreeNode(
@ -106,7 +106,7 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
); );
// Ajoutez les géopoints correspondant à cette catégorie en tant qu'enfants du nœud parent // Ajoutez les géopoints correspondant à cette catégorie en tant qu'enfants du nœud parent
for (var geoPoint in geoPoints.where((gp) => gp.categorie != null || gp.categorieId != null)) { for (var geoPoint in geoPoints.where((gp) => gp.categorieId != null)) {
if (geoPoint.categorieId == category.id && geoPoint.title!.where((l) => l.language == widget.language).firstOrNull != null) { if (geoPoint.categorieId == category.id && geoPoint.title!.where((l) => l.language == widget.language).firstOrNull != null) {
TreeNode geoPointNode = TreeNode( TreeNode geoPointNode = TreeNode(
id: 000 + int.parse( id: 000 + int.parse(
@ -255,7 +255,7 @@ class _GeoPointFilterState extends State<GeoPointFilter> {
child: Container( child: Container(
width: size.width * 0.3, width: size.width * 0.3,
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundColor.withOpacity(0.78), color: kBackgroundColor.withValues(alpha: 0.78),
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)),
), ),
child: Padding( child: Padding(

View File

@ -51,7 +51,7 @@ class _GoogleMapViewState extends State<GoogleMapView> {
contents: point.contents contents: point.contents
);*/ );*/
if (point.latitude != null && point.longitude != null) { if (point.latitude != null && point.longitude != null) {
var icon = point.categorie == null ? BitmapDescriptor.fromBytes(widget.icons.where((i) => i['id'] == null).first['icon']) : widget.icons.any((i) => i['id'] == point.categorieId) ? BitmapDescriptor.fromBytes(widget.icons.where((i) => i['id'] == point.categorieId).first['icon']) : BitmapDescriptor.fromBytes(widget.icons.where((i) => i['id'] == null).first['icon']); //widget.selectedMarkerIcon,; var icon = point.categorieId == null ? BitmapDescriptor.bytes(widget.icons.where((i) => i['id'] == null).first['icon']) : widget.icons.any((i) => i['id'] == point.categorieId) ? BitmapDescriptor.bytes(widget.icons.where((i) => i['id'] == point.categorieId).first['icon']) : BitmapDescriptor.bytes(widget.icons.where((i) => i['id'] == null).first['icon']); //widget.selectedMarkerIcon,;
markers.add(Marker( markers.add(Marker(
draggable: false, draggable: false,
markerId: MarkerId(parse(textSansHTML.body!.text).documentElement!.text + point.latitude! + point.longitude!), markerId: MarkerId(parse(textSansHTML.body!.text).documentElement!.text + point.latitude! + point.longitude!),

View File

@ -86,7 +86,7 @@ class _MapBoxViewState extends State<MapBoxView> {
symbolSortKey: 10, symbolSortKey: 10,
iconColor: 0, iconColor: 0,
iconImage: null, iconImage: null,
image: point.categorie == null ? widget.icons.where((i) => i['id'] == null).first['icon'] : widget.icons.any((i) => i['id'] == point.categorieId) ? widget.icons.where((i) => i['id'] == point.categorieId).first['icon'] : widget.icons.where((i) => i['id'] == null).first['icon'], //widget.selectedMarkerIcon, image: point.categorieId == null ? widget.icons.where((i) => i['id'] == null).first['icon'] : widget.icons.any((i) => i['id'] == point.categorieId) ? widget.icons.where((i) => i['id'] == point.categorieId).first['icon'] : widget.icons.where((i) => i['id'] == null).first['icon'], //widget.selectedMarkerIcon,
)); // , )); // ,
i++; i++;

View File

@ -274,7 +274,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
pageSnapping: true, pageSnapping: true,
reverse: false, reverse: false,
), ),
items: selectedPoint.contents!.map<Widget>((ContentGeoPoint i) { items: selectedPoint.contents!.map<Widget>((ContentDTO i) {
return Builder( return Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
AppContext appContext = Provider.of<AppContext>(context); AppContext appContext = Provider.of<AppContext>(context);
@ -568,12 +568,12 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
} }
} }
getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoint i, bool addFullScreen) { getElementForResource(BuildContext context, AppContext appContext, ContentDTO i, bool addFullScreen) {
var widgetToInclude; var widgetToInclude;
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
switch(i.resourceType) { switch(i.resource?.type) {
case ResourceType.Image: case ResourceType.Image:
case ResourceType.ImageUrl: case ResourceType.ImageUrl:
widgetToInclude = GestureDetector( widgetToInclude = GestureDetector(
@ -601,7 +601,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)),
), ),
child: PhotoView( child: PhotoView(
imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!),
minScale: PhotoViewComputedScale.contained * 0.8, minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.contained * 3.0, maxScale: PhotoViewComputedScale.contained * 3.0,
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
@ -621,7 +621,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
decoration: BoxDecoration( decoration: BoxDecoration(
//color: kBackgroundLight, //color: kBackgroundLight,
image: DecorationImage( image: DecorationImage(
image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)),
@ -639,7 +639,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
widgetToInclude = GestureDetector( widgetToInclude = GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () { onTap: () {
if(addFullScreen && i.resourceType != ResourceType.Audio) { if(addFullScreen && i.resource!.type != ResourceType.Audio) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -656,7 +656,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
), ),
height: size.height * 0.8, height: size.height * 0.8,
width: size.width * 0.8, width: size.width * 0.8,
child: Center(child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true)), child: Center(child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resource?.url, type: i.resource?.type), appContext, false, true)),
), ),
); );
}, },
@ -664,14 +664,14 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi
} }
}, },
child: IgnorePointer( child: IgnorePointer(
ignoring: i.resourceType != ResourceType.Audio, ignoring: i.resource!.type != ResourceType.Audio,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.yellow, color: Colors.yellow,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0),
), ),
child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resource?.url, type: i.resource?.type), appContext, false, true),
), ),
), ),
); );

View File

@ -1,6 +1,4 @@
import 'dart:convert'; import 'dart:convert';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
@ -8,19 +6,9 @@ import 'package:manager_api_new/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Components/loading_common.dart'; import 'package:tablet_app/Components/loading_common.dart';
import 'package:tablet_app/Helpers/ImageCustomProvider.dart'; import 'package:tablet_app/Helpers/ImageCustomProvider.dart';
import 'package:tablet_app/Models/map-marker.dart';
import 'package:tablet_app/Models/tabletContext.dart'; import 'package:tablet_app/Models/tabletContext.dart';
import 'package:tablet_app/Screens/Agenda/agenda_view.dart';
import 'package:tablet_app/Screens/MainView/main_view.dart'; import 'package:tablet_app/Screens/MainView/main_view.dart';
import 'package:tablet_app/Screens/MainView/section_page_detail.dart'; import 'package:tablet_app/Screens/MainView/section_page_detail.dart';
import 'package:tablet_app/Screens/Map/map_context.dart';
import 'package:tablet_app/Screens/Map/map_view.dart';
import 'package:tablet_app/Screens/PDF/pdf_view.dart';
import 'package:tablet_app/Screens/Puzzle/puzzle_view.dart';
import 'package:tablet_app/Screens/Quizz/quizz_view.dart';
import 'package:tablet_app/Screens/Slider/slider_view.dart';
import 'package:tablet_app/Screens/Video/video_view.dart';
import 'package:tablet_app/Screens/Web/web_view.dart';
import 'package:tablet_app/app_context.dart'; import 'package:tablet_app/app_context.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
@ -34,17 +22,21 @@ class MenuView extends StatefulWidget {
} }
class _MenuView extends State<MenuView> { class _MenuView extends State<MenuView> {
MenuDTO menuDTO = MenuDTO(); //MenuDTO menuDTO = MenuDTO();
SectionDTO? selectedSection; SectionDTO? selectedSection;
bool isImageBackground = false; bool isImageBackground = false;
late List<dynamic> rawSubSectionsData;
late List<SectionDTO> subSections;
@override @override
void initState() { void initState() {
/*print(widget.section.data); /*print(widget.section.data);
menuDTO = MenuDTO.fromJson(jsonDecode(widget.section.data!))!; menuDTO = MenuDTO.fromJson(jsonDecode(widget.section.data!))!;
print(menuDTO);*/ print(menuDTO);*/
menuDTO = widget.section; //menuDTO = widget.section;
menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!)); // useless, we get these after that rawSubSectionsData = jsonDecode(jsonEncode(widget.section.sections));
//menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!)); // useless, we get these after that
subSections = jsonDecode(jsonEncode(rawSubSectionsData)).map((json) => SectionDTO.fromJson(json)).whereType<SectionDTO>().toList();
isImageBackground = widget.isImageBackground; isImageBackground = widget.isImageBackground;
@ -69,11 +61,14 @@ class _MenuView extends State<MenuView> {
child: GridView.builder( child: GridView.builder(
shrinkWrap: true, shrinkWrap: true,
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: kIsWeb ? 1.7 : 1.3), gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: kIsWeb ? 1.7 : 1.3),
itemCount: menuDTO.sections!.length, itemCount: subSections.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return InkWell( return InkWell(
onTap: () async { onTap: () {
SectionDTO? section = await (appContext.getContext() as TabletAppContext).clientAPI!.sectionApi!.sectionGetDetail(menuDTO.sections![index].id!); //SectionDTO? section = await (appContext.getContext() as TabletAppContext).clientAPI!.sectionApi!.sectionGetDetail(menuDTO.sections![index].id!);
SectionDTO section = subSections[index];
var rawSectionData = rawSubSectionsData[index];
setState(() { setState(() {
//selectedSection = section; //selectedSection = section;
//selectedSection = menuDTO.sections![index]; //selectedSection = menuDTO.sections![index];
@ -81,14 +76,14 @@ class _MenuView extends State<MenuView> {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) { builder: (context) {
return SectionPageDetail(configurationDTO: configurationDTO, sectionDTO: section!, textColor: textColor, isImageBackground: isImageBackground, elementToShow: getContent(tabletAppContext, section, isImageBackground), isFromMenu: true); return SectionPageDetail(configurationDTO: configurationDTO, sectionDTO: section, textColor: textColor, isImageBackground: isImageBackground, elementToShow: getContent(tabletAppContext, section, isImageBackground, rawSectionData), isFromMenu: true);
}, },
),// For pushAndRemoveUntil ),// For pushAndRemoveUntil
); );
}); });
}, },
child: Container( child: Container(
decoration: isImageBackground ? boxDecoration(appContext, menuDTO.sections![index], false) : null, decoration: isImageBackground ? boxDecoration(appContext, subSections[index], false, rawSubSectionsData[index]) : null,
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15), margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
child: isImageBackground ? Align( child: isImageBackground ? Align(
@ -100,7 +95,7 @@ class _MenuView extends State<MenuView> {
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: HtmlWidget( child: HtmlWidget(
menuDTO.sections![index].title!.where((translation) => translation.language == appContext.getContext().language).firstOrNull?.value ?? "", subSections[index].title!.where((translation) => translation.language == appContext.getContext().language).firstOrNull?.value ?? "",
customStylesBuilder: (element) { customStylesBuilder: (element) {
return {'text-align': 'right', 'font-family': "Roboto"}; return {'text-align': 'right', 'font-family': "Roboto"};
}, },
@ -126,11 +121,11 @@ class _MenuView extends State<MenuView> {
flex: 7, flex: 7,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: menuDTO.sections![index].imageSource == null && menuDTO.sections![index].type != SectionType.Video ? kBackgroundColor : null, // default color if no image color: subSections[index].imageSource == null && subSections[index].type != SectionType.Video ? kBackgroundColor : null, // default color if no image
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
image: menuDTO.sections![index].imageSource != null || menuDTO.sections![index].type == SectionType.Video ? new DecorationImage( image: subSections[index].imageSource != null || subSections[index].type == SectionType.Video ? new DecorationImage(
fit: BoxFit.contain, // contain or cover ? fit: BoxFit.contain, // contain or cover ?
image: ImageCustomProvider.getImageProvider(appContext, menuDTO.sections![index].imageId, menuDTO.sections![index].type == SectionType.Video ? getYoutubeThumbnailUrl(menuDTO.sections![index]) : menuDTO.sections![index].imageSource!), image: ImageCustomProvider.getImageProvider(appContext, subSections[index].imageId, subSections[index].type == SectionType.Video ? getYoutubeThumbnailUrl(rawSubSectionsData[index]) : subSections[index].imageSource!),
): null, ): null,
), ),
) )
@ -144,7 +139,7 @@ class _MenuView extends State<MenuView> {
), ),
child: Center( child: Center(
child: HtmlWidget( child: HtmlWidget(
menuDTO.sections![index].title!.where((translation) => translation.language == appContext.getContext().language).firstOrNull?.value ?? "", subSections[index].title!.where((translation) => translation.language == appContext.getContext().language).firstOrNull?.value ?? "",
customStylesBuilder: (element) { customStylesBuilder: (element) {
return {'text-align': 'center', 'font-family': "Roboto"}; return {'text-align': 'center', 'font-family': "Roboto"};
}, },
@ -163,7 +158,7 @@ class _MenuView extends State<MenuView> {
} }
} }
boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { boxDecoration(AppContext appContext, SectionDTO section, bool isSelected, Object rawSubSectionData) {
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
return BoxDecoration( return BoxDecoration(
@ -172,8 +167,8 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0),
image: section.imageSource != null || section.type == SectionType.Video ? new DecorationImage( image: section.imageSource != null || section.type == SectionType.Video ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.35), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withValues(alpha: 0.35), BlendMode.dstATop) : null,
image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(section) : section.imageSource!), image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(rawSubSectionData) : section.imageSource!),
): null, ): null,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
@ -186,13 +181,18 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) {
); );
} }
String getYoutubeThumbnailUrl(SectionDTO sectionDTO) { String getYoutubeThumbnailUrl(Object rawSectionData) {
try{ try{
VideoDTO? videoDTO = VideoDTO.fromJson(jsonDecode(sectionDTO.data!)); VideoDTO videoDTO = VideoDTO.fromJson(rawSectionData)!;
Uri uri = Uri.parse(videoDTO!.source_!);
String thumbnailUrl = "";
if(videoDTO.source_ != null) {
//VideoDTO? videoDTO = VideoDTO.fromJson(jsonDecode(sectionDTO.data!));
Uri uri = Uri.parse(videoDTO.source_!);
String videoId = uri.queryParameters['v']!; String videoId = uri.queryParameters['v']!;
// Construire l'URL du thumbnail en utilisant l'identifiant de la vidéo YouTube // Construire l'URL du thumbnail en utilisant l'identifiant de la vidéo YouTube
String thumbnailUrl = 'https://img.youtube.com/vi/$videoId/0.jpg'; thumbnailUrl = 'https://img.youtube.com/vi/$videoId/0.jpg';
}
return thumbnailUrl; return thumbnailUrl;

View File

@ -266,7 +266,7 @@ class _PreviousViewWidget extends State<PreviousViewWidget> with TickerProviderS
child: ChangeNotifierProvider<MapContext>( child: ChangeNotifierProvider<MapContext>(
create: (_) => create: (_) =>
MapContext(null), MapContext(null),
child: MapView(section: SectionDTO(), icons: []) /*FutureBuilder( child: MapView(section: MapDTO(), icons: []) /*FutureBuilder(
future: _url, future: _url,
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
? WebViewWidget(url: snapshot.data,) ? WebViewWidget(url: snapshot.data,)

View File

@ -87,7 +87,7 @@ class _QuizzView extends State<QuizzView> {
goodResponses +=1; goodResponses +=1;
}); });
log("goodResponses =" + goodResponses.toString()); log("goodResponses =" + goodResponses.toString());
LevelDTO? levelToShow; List<TranslationAndResourceDTO>? levelToShow;
var test = goodResponses/quizzDTO.questions!.length; var test = goodResponses/quizzDTO.questions!.length;
if(0 == test || test < 0.25) if(0 == test || test < 0.25)
@ -125,7 +125,7 @@ class _QuizzView extends State<QuizzView> {
), ),
), ),
), ),
if (levelToShow != null && !showResponses && levelToShow.label != null && levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language).resourceId != null) if (levelToShow != null && !showResponses && levelToShow.firstWhere((translation) => translation.language == appContext.getContext().language).resourceId != null)
Container( Container(
//height: size.height * 0.2, //height: size.height * 0.2,
//width: size.width * 0.25, //width: size.width * 0.25,
@ -134,7 +134,7 @@ class _QuizzView extends State<QuizzView> {
maxWidth: kIsWeb ? size.width * 0.20 : size.width * 0.20, //size.width * 0.25 maxWidth: kIsWeb ? size.width * 0.20 : size.width * 0.20, //size.width * 0.25
), ),
alignment: Alignment.center, alignment: Alignment.center,
child : getElementForResource(context, appContext, levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language), true), child : getElementForResource(context, appContext, levelToShow.firstWhere((translation) => translation.language == appContext.getContext().language), true),
), ),
Container( Container(
height: showResponses ? 60 : 90, height: showResponses ? 60 : 90,
@ -169,7 +169,7 @@ class _QuizzView extends State<QuizzView> {
padding: const EdgeInsets.all(15.0), padding: const EdgeInsets.all(15.0),
child: levelToShow != null ? child: levelToShow != null ?
HtmlWidget( HtmlWidget(
levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? levelToShow.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", levelToShow.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? levelToShow.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "",
textStyle: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize), textStyle: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize),
customStylesBuilder: (element) { customStylesBuilder: (element) {
return {'text-align': 'center', 'font-family': "Roboto"}; return {'text-align': 'center', 'font-family': "Roboto"};
@ -546,7 +546,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext;
switch(i.resourceType) { switch(i.resource!.type) {
case ResourceType.Image: case ResourceType.Image:
case ResourceType.ImageUrl: case ResourceType.ImageUrl:
widgetToInclude = GestureDetector( widgetToInclude = GestureDetector(
@ -574,7 +574,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)),
), ),
child: PhotoView( child: PhotoView(
imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!),
minScale: PhotoViewComputedScale.contained * 0.8, minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.contained * 3.0, maxScale: PhotoViewComputedScale.contained * 3.0,
backgroundDecoration: BoxDecoration( backgroundDecoration: BoxDecoration(
@ -594,7 +594,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
decoration: BoxDecoration( decoration: BoxDecoration(
//color: kBackgroundLight, //color: kBackgroundLight,
image: DecorationImage( image: DecorationImage(
image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!),
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)),
@ -612,7 +612,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
widgetToInclude = GestureDetector( widgetToInclude = GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () { onTap: () {
if(addFullScreen && i.resourceType != ResourceType.Audio) { if(addFullScreen && i.resource!.type != ResourceType.Audio) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -629,7 +629,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
), ),
height: size.height * 0.8, height: size.height * 0.8,
width: size.width * 0.8, width: size.width * 0.8,
child: Center(child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true)), child: Center(child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resource!.url, type: i.resource!.type), appContext, false, true)),
), ),
); );
}, },
@ -637,14 +637,14 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn
} }
}, },
child: IgnorePointer( child: IgnorePointer(
ignoring: i.resourceType != ResourceType.Audio, ignoring: i.resource!.type != ResourceType.Audio,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
//color: kBackgroundSecondGrey, //color: kBackgroundSecondGrey,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0), borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0),
), ),
child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true), child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resource!.url, type: i.resource!.type), appContext, false, true),
), ),
), ),
); );

View File

@ -255,7 +255,7 @@ class _WeatherViewState extends State<WeatherView> {
color: Colors.lightBlueAccent, color: Colors.lightBlueAccent,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundGrey.withOpacity(0.6), color: kBackgroundGrey.withValues(alpha: 0.6),
spreadRadius: 0.75, spreadRadius: 0.75,
blurRadius: 3.1, blurRadius: 3.1,
offset: Offset(0, 2.5), // changes position of shadow offset: Offset(0, 2.5), // changes position of shadow
@ -312,7 +312,7 @@ class _WeatherViewState extends State<WeatherView> {
color: Colors.lightBlue, color: Colors.lightBlue,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundGrey.withOpacity(0.5), color: kBackgroundGrey.withValues(alpha: 0.5),
spreadRadius: 0.75, spreadRadius: 0.75,
blurRadius: 3.1, blurRadius: 3.1,
offset: Offset(0, 2.5), // changes position of shadow offset: Offset(0, 2.5), // changes position of shadow

View File

@ -94,7 +94,7 @@ class MenuDTO {
int? beaconId; int? beaconId;
List<SectionDTO>? sections; dynamic? sections;
@override @override
bool operator ==(Object other) => bool operator ==(Object other) =>
@ -286,7 +286,7 @@ class MenuDTO {
meterZoneGPS: mapValueOfType<int>(json, r'meterZoneGPS'), meterZoneGPS: mapValueOfType<int>(json, r'meterZoneGPS'),
isBeacon: mapValueOfType<bool>(json, r'isBeacon'), isBeacon: mapValueOfType<bool>(json, r'isBeacon'),
beaconId: mapValueOfType<int>(json, r'beaconId'), beaconId: mapValueOfType<int>(json, r'beaconId'),
sections: SectionDTO.listFromJson(json[r'sections']), sections: json[r'sections'],
); );
} }
return null; return null;