diff --git a/lib/Components/image_input_container.dart b/lib/Components/resource_input_container.dart similarity index 91% rename from lib/Components/image_input_container.dart rename to lib/Components/resource_input_container.dart index 0daad0a..9446d5c 100644 --- a/lib/Components/image_input_container.dart +++ b/lib/Components/resource_input_container.dart @@ -8,7 +8,7 @@ import 'package:manager_app/Screens/Resources/select_resource_modal.dart'; import 'package:manager_api_new/api.dart'; import 'package:provider/provider.dart'; -class ImageInputContainer extends StatefulWidget { +class ResourceInputContainer extends StatefulWidget { final Color color; final String label; final String? initialValue; @@ -16,7 +16,8 @@ class ImageInputContainer extends StatefulWidget { final BoxFit imageFit; final bool isSmall; final double fontSize; - const ImageInputContainer({ + final List inResourceTypes; + const ResourceInputContainer({ Key? key, this.color = kSecond, required this.label, @@ -24,14 +25,15 @@ class ImageInputContainer extends StatefulWidget { required this.onChanged, this.imageFit = BoxFit.cover, this.isSmall = false, - this.fontSize = 25 + this.fontSize = 25, + this.inResourceTypes = const [ResourceType.Image, ResourceType.ImageUrl] }) : super(key: key); @override - _ImageInputContainerState createState() => _ImageInputContainerState(); + _ResourceInputContainerState createState() => _ResourceInputContainerState(); } -class _ImageInputContainerState extends State { +class _ResourceInputContainerState extends State { String? resourceIdToShow; @override @@ -68,7 +70,7 @@ class _ImageInputContainerState extends State { ResourceDTO? result = await showSelectResourceModal( "Sélectionner une ressource", 1, - [ResourceType.Image, ResourceType.ImageUrl], + widget.inResourceTypes, context ); @@ -93,6 +95,7 @@ class _ImageInputContainerState extends State { if (resourceIdToShow != null) { Size size = MediaQuery.of(context).size; final appContext = Provider.of(context); + print("TODO get element"); return FutureBuilder( future: getResource(resourceIdToShow!, appContext), builder: (context, AsyncSnapshot snapshot) { @@ -135,7 +138,7 @@ class _ImageInputContainerState extends State { padding: const EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 15), child: Center( child: AutoSizeText( - "Choisir une image", + "Choisir", style: TextStyle(color: kWhite), maxLines: 1, ) diff --git a/lib/Components/upload_image_container.dart b/lib/Components/upload_image_container.dart index f734a31..dea0bfb 100644 --- a/lib/Components/upload_image_container.dart +++ b/lib/Components/upload_image_container.dart @@ -48,7 +48,7 @@ class _UploadContentContainerState extends State with Si type: FileType.custom, dialogTitle: 'Sélectionner un fichier', allowMultiple: true, - allowedExtensions: ['jpg', 'jpeg', 'png', 'mp3', 'mp4', 'pdf', 'json'], + allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'mp3', 'mp4', 'webm', 'pdf', 'json'], ); if (result != null) { @@ -65,7 +65,7 @@ class _UploadContentContainerState extends State with Si type: FileType.custom, dialogTitle: 'Sélectionner un fichier', allowMultiple: true, - allowedExtensions: ['jpg', 'jpeg', 'png', 'mp3', 'mp4', 'pdf', 'json'], + allowedExtensions: ['jpg', 'jpeg', 'png', 'gif', 'mp3', 'mp4', 'webm', 'pdf', 'json'], ); if (result != null) { diff --git a/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart b/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart index 5efaaa7..711edc7 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart @@ -80,7 +80,7 @@ class _GeoPointContentListState extends State { top: 10, left: 10, child: Text( - "Images", + "Ressources", style: TextStyle(fontSize: 15), ), ), @@ -92,13 +92,13 @@ class _GeoPointContentListState extends State { var result = await showSelectResourceModal( "Sélectionner une ressource", 1, - [ResourceType.Image, ResourceType.ImageUrl], + [ResourceType.Image, ResourceType.ImageUrl, ResourceType.Video, ResourceType.VideoUrl, ResourceType.Audio], context ); if (result != null) { setState(() { - ContentGeoPoint newImage = new ContentGeoPoint(resourceId: result.id, resourceUrl: result.url); - //print("REULT IMAGES = "); + ContentGeoPoint newImage = new ContentGeoPoint(resourceId: result.id, resourceUrl: result.url, resourceName: result.label, resourceType: result.type); + //print("RESULT IMAGES = "); //print(newImage); contentsGeo.add(newImage); //print(imagesGeo); diff --git a/lib/Screens/Configurations/Section/SubSection/Map/listView_card_geoPoint_images.dart b/lib/Screens/Configurations/Section/SubSection/Map/listView_card_geoPoint_images.dart index 18133de..b040b4d 100644 --- a/lib/Screens/Configurations/Section/SubSection/Map/listView_card_geoPoint_images.dart +++ b/lib/Screens/Configurations/Section/SubSection/Map/listView_card_geoPoint_images.dart @@ -75,13 +75,14 @@ class _ListViewCardGeoPointContentsState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ // Icon - ImageInputContainer( + ResourceInputContainer( label: "Icône:", initialValue: mapDTO.iconResourceId, color: kPrimaryColor, @@ -142,21 +142,24 @@ class _MapConfigState extends State { ), child: Stack( children: [ - Padding( - padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10), - child: GridView.builder( - shrinkWrap: true, - gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8), - itemCount: mapDTO.points!.length, - itemBuilder: (BuildContext context, int index) { - return - Container( - decoration: boxDecoration(mapDTO.points![index], appContext), - padding: const EdgeInsets.all(5), - margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10), - child: getElement(index, mapDTO.points![index], size, appContext), - ); - } + Container( + constraints: BoxConstraints(minHeight: 100), + child: Padding( + padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10), + child: GridView.builder( + shrinkWrap: true, + gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 8), + itemCount: mapDTO.points!.length, + itemBuilder: (BuildContext context, int index) { + return + Container( + decoration: boxDecoration(mapDTO.points![index], appContext), + padding: const EdgeInsets.all(5), + margin: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + child: getElement(index, mapDTO.points![index], size, appContext), + ); + } + ), ), ), Positioned( diff --git a/lib/Screens/Configurations/Section/SubSection/Menu/showEditSubSection.dart b/lib/Screens/Configurations/Section/SubSection/Menu/showEditSubSection.dart index d5c6099..2a5b160 100644 --- a/lib/Screens/Configurations/Section/SubSection/Menu/showEditSubSection.dart +++ b/lib/Screens/Configurations/Section/SubSection/Menu/showEditSubSection.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; import 'package:manager_app/Components/rounded_button.dart'; @@ -43,7 +43,7 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext subSectionDTO.label = name; }, ), - ImageInputContainer( + ResourceInputContainer( label: "Image :", initialValue: subSectionDTO.imageId, color: kPrimaryColor, diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart index 3d8d307..825214c 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_question_quizz.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; @@ -55,7 +55,7 @@ Future showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - ImageInputContainer( + ResourceInputContainer( label: "Image :", initialValue: questionDTO.resourceId, color: kPrimaryColor, diff --git a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart index ec518cf..ef428d0 100644 --- a/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart +++ b/lib/Screens/Configurations/Section/SubSection/Quizz/new_update_score_quizz.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; import 'package:manager_app/Components/rounded_button.dart'; @@ -44,7 +44,7 @@ Future showNewOrUpdateScoreQuizz(LevelDTO? inputLevelDTO, AppContext mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Center( - child: ImageInputContainer( + child: ResourceInputContainer( label: "Image :", initialValue: levelDTO.resourceId, color: kPrimaryColor, diff --git a/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart b/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart index d09e5fd..0abb4d3 100644 --- a/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart +++ b/lib/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; import 'package:manager_app/Components/rounded_button.dart'; @@ -46,16 +46,17 @@ Future showNewOrUpdateContentSlider(ContentDTO? inputContentDTO, App child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("Image", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), + Text("Ressource", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Center( - child: ImageInputContainer( - label: "Image :", + child: ResourceInputContainer( + label: "Ressource :", initialValue: contentDTO.resourceId, color: kPrimaryColor, fontSize: 20, + inResourceTypes: [ResourceType.Image, ResourceType.ImageUrl, ResourceType.Video, ResourceType.VideoUrl, ResourceType.Audio], onChanged: (ResourceDTO resource) { if(resource.id == null) { contentDTO.resourceId = null; diff --git a/lib/Screens/Configurations/Section/section_detail_screen.dart b/lib/Screens/Configurations/Section/section_detail_screen.dart index 88d5a7b..58e2e84 100644 --- a/lib/Screens/Configurations/Section/section_detail_screen.dart +++ b/lib/Screens/Configurations/Section/section_detail_screen.dart @@ -9,7 +9,7 @@ import 'package:flutter/services.dart'; import 'package:manager_app/Components/check_input_container.dart'; import 'package:manager_app/Components/confirmation_dialog.dart'; import 'package:manager_app/Components/fetch_section_icon.dart'; -import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; import 'package:manager_app/Components/loading_common.dart'; import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/multi_string_input_container.dart'; @@ -90,7 +90,7 @@ class _SectionDetailScreenState extends State { children: [ Container( //color: Colors.orangeAccent, - height: 80, + height: 82, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -267,7 +267,7 @@ class _SectionDetailScreenState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - ImageInputContainer( + ResourceInputContainer( label: "Image :", initialValue: sectionDTO != null ? sectionDTO.imageId : null, color: kPrimaryColor, diff --git a/lib/Screens/Configurations/configuration_detail_screen.dart b/lib/Screens/Configurations/configuration_detail_screen.dart index 515dba8..62f784b 100644 --- a/lib/Screens/Configurations/configuration_detail_screen.dart +++ b/lib/Screens/Configurations/configuration_detail_screen.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'package:manager_app/Components/check_input_container.dart'; import 'package:manager_app/Components/color_picker_input_container.dart'; import 'package:manager_app/Components/confirmation_dialog.dart'; -import 'package:manager_app/Components/image_input_container.dart'; +import 'package:manager_app/Components/resource_input_container.dart'; import 'package:manager_app/Components/loading_common.dart'; import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/multi_select_dropdown_container.dart'; @@ -184,7 +184,7 @@ class _ConfigurationDetailScreenState extends State { //print(configurationDTO.languages); }, ), - ImageInputContainer( + ResourceInputContainer( label: "Image loader :", fontSize: 20, initialValue: configurationDTO.loaderImageId, @@ -284,7 +284,7 @@ class _ConfigurationDetailScreenState extends State { isTitle: true, ), ), - ImageInputContainer( + ResourceInputContainer( label: "Image fond d'écran :", fontSize: 20, initialValue: configurationDTO.imageId, diff --git a/lib/Screens/Configurations/new_section_popup.dart b/lib/Screens/Configurations/new_section_popup.dart index 7fb286a..3a4c38f 100644 --- a/lib/Screens/Configurations/new_section_popup.dart +++ b/lib/Screens/Configurations/new_section_popup.dart @@ -107,6 +107,8 @@ void create(SectionDTO sectionDTO, AppContext appContext, BuildContext context, if (sectionDTO.label != null) { ManagerAppContext managerAppContext = appContext.getContext(); sectionDTO.instanceId = managerAppContext.instanceId; + sectionDTO.isBeacon = false; + sectionDTO.dateCreation = DateTime.now(); SectionDTO? newSection = await managerAppContext.clientAPI!.sectionApi!.sectionCreate(sectionDTO); if (!isSubSection) { diff --git a/lib/Screens/Resources/get_element_for_resource.dart b/lib/Screens/Resources/get_element_for_resource.dart index 6f6ac5c..fdb7f71 100644 --- a/lib/Screens/Resources/get_element_for_resource.dart +++ b/lib/Screens/Resources/get_element_for_resource.dart @@ -87,6 +87,10 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) { return Text("Vidéo locale - aucune visualisation possible"); case ResourceType.VideoUrl: return Text(resourceDTO.url); + case ResourceType.Pdf: + return Text("Fichier pdf - aucune visualisation possible"); + case ResourceType.Json: + return Text("Fichier json - aucune visualisation possible"); } } diff --git a/lib/Screens/Resources/resources_screen.dart b/lib/Screens/Resources/resources_screen.dart index 10ae748..1a723f4 100644 --- a/lib/Screens/Resources/resources_screen.dart +++ b/lib/Screens/Resources/resources_screen.dart @@ -141,6 +141,7 @@ Future?> create(ResourceDTO resourceDTO, List? files, L case 'jpg': case 'jpeg': case 'png': + case 'gif': resourceDTO.type = ResourceType.Image; mimeType = 'image/'+platformFile.extension!; break; @@ -152,6 +153,10 @@ Future?> create(ResourceDTO resourceDTO, List? files, L resourceDTO.type = ResourceType.Video; mimeType = 'video/'+platformFile.extension!; break; + case 'webm': + resourceDTO.type = ResourceType.Video; + mimeType = 'video/'+platformFile.extension!; + break; case 'pdf': resourceDTO.type = ResourceType.Pdf; mimeType = 'application/'+platformFile.extension!; diff --git a/lib/Screens/Resources/select_resource_modal.dart b/lib/Screens/Resources/select_resource_modal.dart index b2ee8b8..afd2d30 100644 --- a/lib/Screens/Resources/select_resource_modal.dart +++ b/lib/Screens/Resources/select_resource_modal.dart @@ -18,8 +18,8 @@ dynamic showSelectResourceModal (String text, int maxLines, List r child: Column( children: [ Container( - width: size.width * 0.7, - height: size.height * 0.75, + width: size.width * 0.85, + height: size.height * 0.85, child: ResourcesScreen( isAddButton: false, onGetResult: (ResourceDTO? resource) { diff --git a/lib/api/swagger.yaml b/lib/api/swagger.yaml index 86fbead..003cd03 100644 --- a/lib/api/swagger.yaml +++ b/lib/api/swagger.yaml @@ -1885,6 +1885,7 @@ components: order: type: integer format: int32 + nullable: true instanceId: type: string nullable: true @@ -2163,7 +2164,7 @@ components: resourceUrl: type: string nullable: true - latitude: + resourceName: type: string nullable: true CategorieDTO: diff --git a/manager_api_new/doc/ContentGeoPoint.md b/manager_api_new/doc/ContentGeoPoint.md index 0594bd9..682228e 100644 --- a/manager_api_new/doc/ContentGeoPoint.md +++ b/manager_api_new/doc/ContentGeoPoint.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes **resourceId** | **String** | | [optional] **resourceType** | [**ResourceType**](ResourceType.md) | | [optional] **resourceUrl** | **String** | | [optional] -**latitude** | **String** | | [optional] +**resourceName** | **String** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/manager_api_new/lib/model/content_geo_point.dart b/manager_api_new/lib/model/content_geo_point.dart index e8fe80f..d299f8a 100644 --- a/manager_api_new/lib/model/content_geo_point.dart +++ b/manager_api_new/lib/model/content_geo_point.dart @@ -16,7 +16,7 @@ class ContentGeoPoint { this.resourceId, this.resourceType, this.resourceUrl, - this.latitude, + this.resourceName, }); String? resourceId; @@ -31,14 +31,14 @@ class ContentGeoPoint { String? resourceUrl; - String? latitude; + String? resourceName; @override bool operator ==(Object other) => identical(this, other) || other is ContentGeoPoint && other.resourceId == resourceId && other.resourceType == resourceType && other.resourceUrl == resourceUrl && - other.latitude == latitude; + other.resourceName == resourceName; @override int get hashCode => @@ -46,10 +46,10 @@ class ContentGeoPoint { (resourceId == null ? 0 : resourceId!.hashCode) + (resourceType == null ? 0 : resourceType!.hashCode) + (resourceUrl == null ? 0 : resourceUrl!.hashCode) + - (latitude == null ? 0 : latitude!.hashCode); + (resourceName == null ? 0 : resourceName!.hashCode); @override - String toString() => 'ContentGeoPoint[resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl, latitude=$latitude]'; + String toString() => 'ContentGeoPoint[resourceId=$resourceId, resourceType=$resourceType, resourceUrl=$resourceUrl, resourceName=$resourceName]'; Map toJson() { final json = {}; @@ -68,10 +68,10 @@ class ContentGeoPoint { } else { json[r'resourceUrl'] = null; } - if (this.latitude != null) { - json[r'latitude'] = this.latitude; + if (this.resourceName != null) { + json[r'resourceName'] = this.resourceName; } else { - json[r'latitude'] = null; + json[r'resourceName'] = null; } return json; } @@ -98,7 +98,7 @@ class ContentGeoPoint { resourceId: mapValueOfType(json, r'resourceId'), resourceType: ResourceType.fromJson(json[r'resourceType']), resourceUrl: mapValueOfType(json, r'resourceUrl'), - latitude: mapValueOfType(json, r'latitude'), + resourceName: mapValueOfType(json, r'resourceName'), ); } return null;