update service generation + gif and webm + wip select resource

This commit is contained in:
Thomas Fransolet 2023-12-23 14:34:28 +01:00
parent 6b65bcbf66
commit 4b7dac07a8
18 changed files with 100 additions and 73 deletions

View File

@ -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<ResourceType> 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<ImageInputContainer> {
class _ResourceInputContainerState extends State<ResourceInputContainer> {
String? resourceIdToShow;
@override
@ -68,7 +70,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
ResourceDTO? result = await showSelectResourceModal(
"Sélectionner une ressource",
1,
[ResourceType.Image, ResourceType.ImageUrl],
widget.inResourceTypes,
context
);
@ -93,6 +95,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
if (resourceIdToShow != null) {
Size size = MediaQuery.of(context).size;
final appContext = Provider.of<AppContext>(context);
print("TODO get element");
return FutureBuilder(
future: getResource(resourceIdToShow!, appContext),
builder: (context, AsyncSnapshot<dynamic> snapshot) {
@ -135,7 +138,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
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,
)

View File

@ -48,7 +48,7 @@ class _UploadContentContainerState extends State<UploadContentContainer> 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<UploadContentContainer> 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) {

View File

@ -80,7 +80,7 @@ class _GeoPointContentListState extends State<GeoPointContentList> {
top: 10,
left: 10,
child: Text(
"Images",
"Ressources",
style: TextStyle(fontSize: 15),
),
),
@ -92,13 +92,13 @@ class _GeoPointContentListState extends State<GeoPointContentList> {
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);

View File

@ -75,13 +75,14 @@ class _ListViewCardGeoPointContentsState extends State<ListViewCardGeoPointConte
}
getElement(int index, ContentGeoPoint contentGeoPoint, Size size, AppContext appContext) {
return Container(
width: double.infinity,
height: double.infinity,
child: Stack(
children: [
Center(
child: Image.network( // TODO support video etc
if(contentGeoPoint.resourceType == ResourceType.Image || contentGeoPoint.resourceType == ResourceType.ImageUrl) {
return Container(
width: double.infinity,
height: double.infinity,
child: Stack(
children: [
Center(
child: Image.network( // TODO support video etc
contentGeoPoint.resourceUrl!,
fit:BoxFit.scaleDown,
loadingBuilder: (BuildContext context, Widget child,
@ -99,9 +100,9 @@ class _ListViewCardGeoPointContentsState extends State<ListViewCardGeoPointConte
),
);
},
),
)
/*Align(
),
)
/*Align(
alignment: Alignment.center,
child: AutoSizeText(
imageGeoPoint.,
@ -110,7 +111,7 @@ class _ListViewCardGeoPointContentsState extends State<ListViewCardGeoPointConte
textAlign: TextAlign.center,
),
),*/
/*Positioned(
/*Positioned(
top: 20,
left: 20,
child: Icon(
@ -119,9 +120,16 @@ class _ListViewCardGeoPointContentsState extends State<ListViewCardGeoPointConte
size: 18.0,
),
),*/
],
),
);
],
),
);
} else {
return Container(
child: Center(
child: Text(contentGeoPoint.resourceName!),
)
);
}
}
}

View File

@ -2,7 +2,7 @@ import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.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/multi_select_container.dart';
import 'package:manager_app/Components/slider_input_container.dart';
import 'package:manager_app/Models/managerContext.dart';
@ -87,7 +87,7 @@ class _MapConfigState extends State<MapConfig> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// Icon
ImageInputContainer(
ResourceInputContainer(
label: "Icône:",
initialValue: mapDTO.iconResourceId,
color: kPrimaryColor,
@ -142,21 +142,24 @@ class _MapConfigState extends State<MapConfig> {
),
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(

View File

@ -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,

View File

@ -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<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO? inputQuestionDTO,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ImageInputContainer(
ResourceInputContainer(
label: "Image :",
initialValue: questionDTO.resourceId,
color: kPrimaryColor,

View File

@ -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<LevelDTO?> showNewOrUpdateScoreQuizz(LevelDTO? inputLevelDTO, AppContext
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Center(
child: ImageInputContainer(
child: ResourceInputContainer(
label: "Image :",
initialValue: levelDTO.resourceId,
color: kPrimaryColor,

View File

@ -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<ContentDTO> 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;

View File

@ -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<SectionDetailScreen> {
children: [
Container(
//color: Colors.orangeAccent,
height: 80,
height: 82,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -267,7 +267,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ImageInputContainer(
ResourceInputContainer(
label: "Image :",
initialValue: sectionDTO != null ? sectionDTO.imageId : null,
color: kPrimaryColor,

View File

@ -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<ConfigurationDetailScreen> {
//print(configurationDTO.languages);
},
),
ImageInputContainer(
ResourceInputContainer(
label: "Image loader :",
fontSize: 20,
initialValue: configurationDTO.loaderImageId,
@ -284,7 +284,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
isTitle: true,
),
),
ImageInputContainer(
ResourceInputContainer(
label: "Image fond d'écran :",
fontSize: 20,
initialValue: configurationDTO.imageId,

View File

@ -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) {

View File

@ -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");
}
}

View File

@ -141,6 +141,7 @@ Future<List<ResourceDTO?>?> create(ResourceDTO resourceDTO, List<File>? files, L
case 'jpg':
case 'jpeg':
case 'png':
case 'gif':
resourceDTO.type = ResourceType.Image;
mimeType = 'image/'+platformFile.extension!;
break;
@ -152,6 +153,10 @@ Future<List<ResourceDTO?>?> create(ResourceDTO resourceDTO, List<File>? 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!;

View File

@ -18,8 +18,8 @@ dynamic showSelectResourceModal (String text, int maxLines, List<ResourceType> 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) {

View File

@ -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:

View File

@ -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)

View File

@ -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<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -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<String>(json, r'resourceId'),
resourceType: ResourceType.fromJson(json[r'resourceType']),
resourceUrl: mapValueOfType<String>(json, r'resourceUrl'),
latitude: mapValueOfType<String>(json, r'latitude'),
resourceName: mapValueOfType<String>(json, r'resourceName'),
);
}
return null;