diff --git a/lib/Components/audio_player.dart b/lib/Components/audio_player.dart index cf16935..65eb775 100644 --- a/lib/Components/audio_player.dart +++ b/lib/Components/audio_player.dart @@ -146,7 +146,7 @@ class _AudioPlayerFloatingContainerState extends State { if(!_controller.value.isPlaying && _controller.value.isInitialized) Center( child: FloatingActionButton( - backgroundColor: kTestSecondColor.withOpacity(0.8), + backgroundColor: kTestSecondColor.withValues(alpha: 0.8), onPressed: () { setState(() { _controller.value.isPlaying diff --git a/lib/Screens/Agenda/agenda_view.dart b/lib/Screens/Agenda/agenda_view.dart index a620fba..e9d7a43 100644 --- a/lib/Screens/Agenda/agenda_view.dart +++ b/lib/Screens/Agenda/agenda_view.dart @@ -100,7 +100,7 @@ class _AgendaView extends State { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.data == null) { return Center( - child: Text("Le json n'est pas valide") + child: Text("Le fichier choisi n'est pas valide") ); } else { return Center( diff --git a/lib/Screens/MainView/main_view.dart b/lib/Screens/MainView/main_view.dart index 484365c..a70dc94 100644 --- a/lib/Screens/MainView/main_view.dart +++ b/lib/Screens/MainView/main_view.dart @@ -117,7 +117,7 @@ class _MainViewWidget extends State { decoration: configurationDTO.imageId != null ? BoxDecoration( image: new DecorationImage( 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!) ), ) : null, @@ -281,17 +281,9 @@ class _MainViewWidget extends State { if(isInit) { try { - final rawList = await tabletAppContext.clientAPI!.sectionApi!.sectionGetFromConfigurationDetail(tabletAppContext.configuration!.id!); - //var sections = rawList.map((json) => SectionDTO.fromJson(json)).toList(); rawSectionsData = jsonDecode(jsonEncode(rawList)); - rawSectionsData = rawSectionsData.map((json) => SectionDTO.fromJson(json)).toList(); - List sectionList = rawSectionsData.whereType().toList(); - sectionList.sort((a, b) => a.order!.compareTo(b.order!)); - - /*List? sections = await tabletAppContext.clientAPI!.sectionApi!.sectionGetFromConfiguration(tabletAppContext.configuration!.id!); - sections!.sort((a, b) => a.order!.compareTo(b.order!));*/ - + List sectionList = jsonDecode(jsonEncode(rawSectionsData)).map((json) => SectionDTO.fromJson(json)).whereType().toList(); sectionsLocal = sectionList; isInit = false; return sectionList; @@ -342,7 +334,7 @@ class _MainViewWidget extends State { }); }, child: Container( - decoration: isImageBackground ? boxDecoration(appContext, sectionsLocal![index], false) : null, + decoration: isImageBackground ? boxDecoration(appContext, sectionsLocal![index], false, rawSectionsData[index]) : null, //color: Colors.yellow, padding: EdgeInsets.all(isImageBackground ? 18 : 5), margin: EdgeInsets.symmetric(vertical: isImageBackground ? 25 : 10, horizontal: 25), @@ -377,7 +369,7 @@ class _MainViewWidget extends State { shape: BoxShape.rectangle, image: sectionsLocal![index].imageSource != null || sectionsLocal![index].type == SectionType.Video ? new DecorationImage( 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, ), ) @@ -415,7 +407,7 @@ class _MainViewWidget extends State { } } -boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { +boxDecoration(AppContext appContext, SectionDTO section, bool isSelected, Object rawSectionData) { TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; return BoxDecoration( 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), image: section.imageSource != null || section.type == SectionType.Video ? new DecorationImage( fit: BoxFit.cover, - colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.2), BlendMode.dstATop) : null, - image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(section) : section.imageSource!), + colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withValues(alpha: 0.2), BlendMode.dstATop) : null, + image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(rawSectionData) : section.imageSource!), ): null, boxShadow: [ BoxShadow( @@ -532,7 +524,7 @@ Widget getContent(TabletAppContext tabletAppContext, SectionDTO sectionSelected, future: getByteIcons(tabletAppContext, mapDTO), builder: (context, AsyncSnapshot snapshot) { 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) { return Text("No data"); } else { @@ -580,6 +572,6 @@ Widget getContent(TabletAppContext tabletAppContext, SectionDTO sectionSelected, WeatherDTO weatherDTO = WeatherDTO.fromJson(rawSectionData)!; return WeatherView(section: weatherDTO); default: - return Text("Ce type n'est pas supporté"); + return Center(child: Text("Ce type n'est pas supporté")); }; } \ No newline at end of file diff --git a/lib/Screens/MainView/section_page_detail.dart b/lib/Screens/MainView/section_page_detail.dart index 12f256d..05a6a76 100644 --- a/lib/Screens/MainView/section_page_detail.dart +++ b/lib/Screens/MainView/section_page_detail.dart @@ -249,7 +249,7 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 30.0), image: section.imageSource != null ? new DecorationImage( 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!), ): null, boxShadow: [ diff --git a/lib/Screens/Map/geo_point_filter.dart b/lib/Screens/Map/geo_point_filter.dart index 0a5aa65..0f3d0a8 100644 --- a/lib/Screens/Map/geo_point_filter.dart +++ b/lib/Screens/Map/geo_point_filter.dart @@ -73,7 +73,7 @@ class _GeoPointFilterState extends State { List nodes = []; // 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) { TreeNode nodeWithoutCat = TreeNode( @@ -106,7 +106,7 @@ class _GeoPointFilterState extends State { ); // 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) { TreeNode geoPointNode = TreeNode( id: 000 + int.parse( @@ -255,7 +255,7 @@ class _GeoPointFilterState extends State { child: Container( width: size.width * 0.3, decoration: BoxDecoration( - color: kBackgroundColor.withOpacity(0.78), + color: kBackgroundColor.withValues(alpha: 0.78), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0)), ), child: Padding( diff --git a/lib/Screens/Map/google_map_view.dart b/lib/Screens/Map/google_map_view.dart index a0eaf7d..e52e066 100644 --- a/lib/Screens/Map/google_map_view.dart +++ b/lib/Screens/Map/google_map_view.dart @@ -51,7 +51,7 @@ class _GoogleMapViewState extends State { contents: point.contents );*/ 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( draggable: false, markerId: MarkerId(parse(textSansHTML.body!.text).documentElement!.text + point.latitude! + point.longitude!), diff --git a/lib/Screens/Map/map_box_view.dart b/lib/Screens/Map/map_box_view.dart index c3100a4..de333ae 100644 --- a/lib/Screens/Map/map_box_view.dart +++ b/lib/Screens/Map/map_box_view.dart @@ -86,7 +86,7 @@ class _MapBoxViewState extends State { symbolSortKey: 10, iconColor: 0, 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++; diff --git a/lib/Screens/Map/marker_view.dart b/lib/Screens/Map/marker_view.dart index 4cbf1bb..ff880eb 100644 --- a/lib/Screens/Map/marker_view.dart +++ b/lib/Screens/Map/marker_view.dart @@ -274,7 +274,7 @@ class _MarkerInfoWidget extends State { pageSnapping: true, reverse: false, ), - items: selectedPoint.contents!.map((ContentGeoPoint i) { + items: selectedPoint.contents!.map((ContentDTO i) { return Builder( builder: (BuildContext context) { AppContext appContext = Provider.of(context); @@ -568,12 +568,12 @@ class _MarkerInfoWidget extends State { } } -getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoint i, bool addFullScreen) { +getElementForResource(BuildContext context, AppContext appContext, ContentDTO i, bool addFullScreen) { var widgetToInclude; Size size = MediaQuery.of(context).size; TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; - switch(i.resourceType) { + switch(i.resource?.type) { case ResourceType.Image: case ResourceType.ImageUrl: widgetToInclude = GestureDetector( @@ -601,7 +601,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), ), child: PhotoView( - imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), + imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!), minScale: PhotoViewComputedScale.contained * 0.8, maxScale: PhotoViewComputedScale.contained * 3.0, backgroundDecoration: BoxDecoration( @@ -621,7 +621,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi decoration: BoxDecoration( //color: kBackgroundLight, image: DecorationImage( - image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), + image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!), fit: BoxFit.cover, ), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), @@ -639,7 +639,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi widgetToInclude = GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - if(addFullScreen && i.resourceType != ResourceType.Audio) { + if(addFullScreen && i.resource!.type != ResourceType.Audio) { showDialog( context: context, builder: (BuildContext context) { @@ -656,7 +656,7 @@ getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoi ), height: size.height * 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( - ignoring: i.resourceType != ResourceType.Audio, + ignoring: i.resource!.type != ResourceType.Audio, child: Container( decoration: BoxDecoration( color: Colors.yellow, shape: BoxShape.rectangle, 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), ), ), ); diff --git a/lib/Screens/Menu/menu_view.dart b/lib/Screens/Menu/menu_view.dart index 30900eb..560545c 100644 --- a/lib/Screens/Menu/menu_view.dart +++ b/lib/Screens/Menu/menu_view.dart @@ -1,6 +1,4 @@ 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/material.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:tablet_app/Components/loading_common.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/Screens/Agenda/agenda_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/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/constants.dart'; @@ -34,17 +22,21 @@ class MenuView extends StatefulWidget { } class _MenuView extends State { - MenuDTO menuDTO = MenuDTO(); + //MenuDTO menuDTO = MenuDTO(); SectionDTO? selectedSection; bool isImageBackground = false; + late List rawSubSectionsData; + late List subSections; @override void initState() { /*print(widget.section.data); menuDTO = MenuDTO.fromJson(jsonDecode(widget.section.data!))!; print(menuDTO);*/ - menuDTO = widget.section; - menuDTO.sections!.sort((a, b) => a.order!.compareTo(b.order!)); // useless, we get these after that + //menuDTO = widget.section; + 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().toList(); isImageBackground = widget.isImageBackground; @@ -69,11 +61,14 @@ class _MenuView extends State { child: GridView.builder( shrinkWrap: true, gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: kIsWeb ? 1.7 : 1.3), - itemCount: menuDTO.sections!.length, + itemCount: subSections.length, itemBuilder: (BuildContext context, int index) { return InkWell( - onTap: () async { - SectionDTO? section = await (appContext.getContext() as TabletAppContext).clientAPI!.sectionApi!.sectionGetDetail(menuDTO.sections![index].id!); + onTap: () { + //SectionDTO? section = await (appContext.getContext() as TabletAppContext).clientAPI!.sectionApi!.sectionGetDetail(menuDTO.sections![index].id!); + SectionDTO section = subSections[index]; + var rawSectionData = rawSubSectionsData[index]; + setState(() { //selectedSection = section; //selectedSection = menuDTO.sections![index]; @@ -81,14 +76,14 @@ class _MenuView extends State { context, MaterialPageRoute( 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 ); }); }, 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), margin: EdgeInsets.symmetric(vertical: 15, horizontal: 15), child: isImageBackground ? Align( @@ -100,7 +95,7 @@ class _MenuView extends State { Align( alignment: Alignment.centerRight, 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) { return {'text-align': 'right', 'font-family': "Roboto"}; }, @@ -126,11 +121,11 @@ class _MenuView extends State { flex: 7, child: Container( 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, - 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 ? - 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, ), ) @@ -144,7 +139,7 @@ class _MenuView extends State { ), child: Center( 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) { return {'text-align': 'center', 'font-family': "Roboto"}; }, @@ -163,7 +158,7 @@ class _MenuView extends State { } } -boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { +boxDecoration(AppContext appContext, SectionDTO section, bool isSelected, Object rawSubSectionData) { TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; return BoxDecoration( @@ -172,8 +167,8 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { borderRadius: BorderRadius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 20.0), image: section.imageSource != null || section.type == SectionType.Video ? new DecorationImage( fit: BoxFit.cover, - colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withOpacity(0.35), BlendMode.dstATop) : null, - image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(section) : section.imageSource!), + colorFilter: !isSelected? new ColorFilter.mode(kBackgroundLight.withValues(alpha: 0.35), BlendMode.dstATop) : null, + image: ImageCustomProvider.getImageProvider(appContext, section.imageId, section.type == SectionType.Video ? getYoutubeThumbnailUrl(rawSubSectionData) : section.imageSource!), ): null, boxShadow: [ BoxShadow( @@ -186,13 +181,18 @@ boxDecoration(AppContext appContext, SectionDTO section, bool isSelected) { ); } -String getYoutubeThumbnailUrl(SectionDTO sectionDTO) { +String getYoutubeThumbnailUrl(Object rawSectionData) { try{ - VideoDTO? videoDTO = VideoDTO.fromJson(jsonDecode(sectionDTO.data!)); - Uri uri = Uri.parse(videoDTO!.source_!); - String videoId = uri.queryParameters['v']!; - // Construire l'URL du thumbnail en utilisant l'identifiant de la vidéo YouTube - String thumbnailUrl = 'https://img.youtube.com/vi/$videoId/0.jpg'; + VideoDTO videoDTO = VideoDTO.fromJson(rawSectionData)!; + + String thumbnailUrl = ""; + if(videoDTO.source_ != null) { + //VideoDTO? videoDTO = VideoDTO.fromJson(jsonDecode(sectionDTO.data!)); + Uri uri = Uri.parse(videoDTO.source_!); + String videoId = uri.queryParameters['v']!; + // Construire l'URL du thumbnail en utilisant l'identifiant de la vidéo YouTube + thumbnailUrl = 'https://img.youtube.com/vi/$videoId/0.jpg'; + } return thumbnailUrl; diff --git a/lib/Screens/Previous/previous_view.dart b/lib/Screens/Previous/previous_view.dart index dc33bad..b0127f4 100644 --- a/lib/Screens/Previous/previous_view.dart +++ b/lib/Screens/Previous/previous_view.dart @@ -266,7 +266,7 @@ class _PreviousViewWidget extends State with TickerProviderS child: ChangeNotifierProvider( create: (_) => MapContext(null), - child: MapView(section: SectionDTO(), icons: []) /*FutureBuilder( + child: MapView(section: MapDTO(), icons: []) /*FutureBuilder( future: _url, builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData ? WebViewWidget(url: snapshot.data,) diff --git a/lib/Screens/Quizz/quizz_view.dart b/lib/Screens/Quizz/quizz_view.dart index e937758..5627223 100644 --- a/lib/Screens/Quizz/quizz_view.dart +++ b/lib/Screens/Quizz/quizz_view.dart @@ -87,7 +87,7 @@ class _QuizzView extends State { goodResponses +=1; }); log("goodResponses =" + goodResponses.toString()); - LevelDTO? levelToShow; + List? levelToShow; var test = goodResponses/quizzDTO.questions!.length; if(0 == test || test < 0.25) @@ -125,7 +125,7 @@ class _QuizzView extends State { ), ), ), - 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( //height: size.height * 0.2, //width: size.width * 0.25, @@ -134,7 +134,7 @@ class _QuizzView extends State { maxWidth: kIsWeb ? size.width * 0.20 : size.width * 0.20, //size.width * 0.25 ), 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( height: showResponses ? 60 : 90, @@ -169,7 +169,7 @@ class _QuizzView extends State { padding: const EdgeInsets.all(15.0), child: levelToShow != null ? 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), customStylesBuilder: (element) { return {'text-align': 'center', 'font-family': "Roboto"}; @@ -546,7 +546,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn Size size = MediaQuery.of(context).size; TabletAppContext tabletAppContext = appContext.getContext() as TabletAppContext; - switch(i.resourceType) { + switch(i.resource!.type) { case ResourceType.Image: case ResourceType.ImageUrl: widgetToInclude = GestureDetector( @@ -574,7 +574,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), ), child: PhotoView( - imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), + imageProvider: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!), minScale: PhotoViewComputedScale.contained * 0.8, maxScale: PhotoViewComputedScale.contained * 3.0, backgroundDecoration: BoxDecoration( @@ -594,7 +594,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn decoration: BoxDecoration( //color: kBackgroundLight, image: DecorationImage( - image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resourceUrl!), + image: ImageCustomProvider.getImageProvider(appContext, i.resourceId!, i.resource!.url!), fit: BoxFit.contain, ), borderRadius: BorderRadius.all(Radius.circular(tabletAppContext.configuration!.roundedValue?.toDouble() ?? 15.0)), @@ -612,7 +612,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn widgetToInclude = GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - if(addFullScreen && i.resourceType != ResourceType.Audio) { + if(addFullScreen && i.resource!.type != ResourceType.Audio) { showDialog( context: context, builder: (BuildContext context) { @@ -629,7 +629,7 @@ getElementForResource(BuildContext context, AppContext appContext, TranslationAn ), height: size.height * 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( - ignoring: i.resourceType != ResourceType.Audio, + ignoring: i.resource!.type != ResourceType.Audio, child: Container( decoration: BoxDecoration( //color: kBackgroundSecondGrey, shape: BoxShape.rectangle, 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), ), ), ); diff --git a/lib/Screens/Weather/weather_view.dart b/lib/Screens/Weather/weather_view.dart index 8ce4326..9c54373 100644 --- a/lib/Screens/Weather/weather_view.dart +++ b/lib/Screens/Weather/weather_view.dart @@ -255,7 +255,7 @@ class _WeatherViewState extends State { color: Colors.lightBlueAccent, boxShadow: [ BoxShadow( - color: kBackgroundGrey.withOpacity(0.6), + color: kBackgroundGrey.withValues(alpha: 0.6), spreadRadius: 0.75, blurRadius: 3.1, offset: Offset(0, 2.5), // changes position of shadow @@ -312,7 +312,7 @@ class _WeatherViewState extends State { color: Colors.lightBlue, boxShadow: [ BoxShadow( - color: kBackgroundGrey.withOpacity(0.5), + color: kBackgroundGrey.withValues(alpha: 0.5), spreadRadius: 0.75, blurRadius: 3.1, offset: Offset(0, 2.5), // changes position of shadow diff --git a/manager_api_new/lib/model/menu_dto.dart b/manager_api_new/lib/model/menu_dto.dart index b94e973..a2cb161 100644 --- a/manager_api_new/lib/model/menu_dto.dart +++ b/manager_api_new/lib/model/menu_dto.dart @@ -94,7 +94,7 @@ class MenuDTO { int? beaconId; - List? sections; + dynamic? sections; @override bool operator ==(Object other) => @@ -286,7 +286,7 @@ class MenuDTO { meterZoneGPS: mapValueOfType(json, r'meterZoneGPS'), isBeacon: mapValueOfType(json, r'isBeacon'), beaconId: mapValueOfType(json, r'beaconId'), - sections: SectionDTO.listFromJson(json[r'sections']), + sections: json[r'sections'], ); } return null;