View audio title on audio selection + add possibility to choose null on select resource
This commit is contained in:
parent
144722feea
commit
fb5973d016
@ -64,7 +64,7 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
|
||||
height: size.width *0.08,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
var result = await showSelectResourceModal(
|
||||
ResourceDTO result = await showSelectResourceModal(
|
||||
"Sélectionner une ressource",
|
||||
1,
|
||||
[ResourceType.Audio],
|
||||
@ -73,12 +73,12 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
|
||||
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
resourceIdToShow = result.id;
|
||||
resourceIdToShow = result.id != null ? result.id : null;
|
||||
});
|
||||
widget.onChanged(result);
|
||||
}
|
||||
},
|
||||
child: getElement(widget.initialValue, context, widget.isSmall),
|
||||
child: getElement(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -88,18 +88,18 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
|
||||
);
|
||||
}
|
||||
|
||||
getElement(String initialValue, BuildContext context, bool isSmall) {
|
||||
getElement(BuildContext context) {
|
||||
if (resourceIdToShow != null) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
return FutureBuilder(
|
||||
future: getResource(resourceIdToShow, appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
builder: (context, AsyncSnapshot<ResourceDTO> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data != null) {
|
||||
return Container(
|
||||
decoration: boxDecoration(snapshot.data, appContext),
|
||||
child: Center(child: AutoSizeText("Audio")),
|
||||
child: Center(child: AutoSizeText(snapshot.data.label, textAlign: TextAlign.center)),
|
||||
);
|
||||
} else {
|
||||
return Text("No data");
|
||||
@ -139,8 +139,8 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
|
||||
|
||||
Future<ResourceDTO> getResource(String resourceIdToShow, dynamic appContext) async {
|
||||
// Just in resource tab detail not here
|
||||
//ResourceDTO resource = await appContext.getContext().clientAPI.resourceApi.resourceGetDetail(resourceIdToShow);
|
||||
return new ResourceDTO();
|
||||
ResourceDTO resource = await appContext.getContext().clientAPI.resourceApi.resourceGetDetail(resourceIdToShow);
|
||||
return resource;
|
||||
}
|
||||
|
||||
boxDecoration(ResourceDTO resourceDTO, appContext) {
|
||||
|
||||
@ -64,7 +64,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
height: size.width *0.08,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
var result = await showSelectResourceModal(
|
||||
ResourceDTO result = await showSelectResourceModal(
|
||||
"Sélectionner une ressource",
|
||||
1,
|
||||
[ResourceType.Image, ResourceType.ImageUrl],
|
||||
@ -73,7 +73,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
resourceIdToShow = result.id;
|
||||
resourceIdToShow = result.id != null ? result.id : null;
|
||||
});
|
||||
widget.onChanged(result);
|
||||
}
|
||||
|
||||
@ -91,8 +91,13 @@ class _MapConfigState extends State<MapConfig> {
|
||||
color: kPrimaryColor,
|
||||
imageFit: BoxFit.contain,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
mapDTO.iconSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
mapDTO.iconResourceId = resource.id;
|
||||
if(resource.id == null) {
|
||||
mapDTO.iconSource = null;
|
||||
mapDTO.iconResourceId = null;
|
||||
} else {
|
||||
mapDTO.iconResourceId = resource.id;
|
||||
mapDTO.iconSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
widget.onChanged(jsonEncode(mapDTO).toString());
|
||||
},
|
||||
isSmall: true
|
||||
|
||||
@ -47,8 +47,13 @@ void showEditSubSection(SectionDTO subSectionDTO, Function getResult, AppContext
|
||||
initialValue: subSectionDTO.imageId,
|
||||
color: kPrimaryColor,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
subSectionDTO.imageId = resource.id;
|
||||
subSectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
if(resource.id == null) {
|
||||
subSectionDTO.imageId = null;
|
||||
subSectionDTO.imageSource = null;
|
||||
} else {
|
||||
subSectionDTO.imageId = resource.id;
|
||||
subSectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
},
|
||||
isSmall: true,
|
||||
),
|
||||
|
||||
@ -54,9 +54,13 @@ Future<QuestionDTO> showNewOrUpdateQuestionQuizz(QuestionDTO inputQuestionDTO, A
|
||||
initialValue: questionDTO.resourceId,
|
||||
color: kPrimaryColor,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
var result = resource;
|
||||
questionDTO.source_ = result.type == ResourceType.ImageUrl ? result.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ result.id;
|
||||
questionDTO.resourceId = result.id;
|
||||
if(resource.id == null) {
|
||||
questionDTO.resourceId = null;
|
||||
questionDTO.source_ = null;
|
||||
} else {
|
||||
questionDTO.resourceId = resource.id;
|
||||
questionDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
},
|
||||
isSmall: true
|
||||
),
|
||||
|
||||
@ -48,9 +48,13 @@ Future<LevelDTO> showNewOrUpdateScoreQuizz(LevelDTO inputLevelDTO, AppContext ap
|
||||
initialValue: levelDTO.resourceId,
|
||||
color: kPrimaryColor,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
var result = resource;
|
||||
levelDTO.source_ = result.type == ResourceType.ImageUrl ? result.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ result.id;
|
||||
levelDTO.resourceId = result.id;
|
||||
if(resource.id == null) {
|
||||
levelDTO.resourceId = null;
|
||||
levelDTO.source_ = null;
|
||||
} else {
|
||||
levelDTO.resourceId = resource.id;
|
||||
levelDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
},
|
||||
isSmall: true
|
||||
),
|
||||
|
||||
@ -54,9 +54,13 @@ Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext a
|
||||
initialValue: imageDTO.resourceId,
|
||||
color: kPrimaryColor,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
var result = resource;
|
||||
imageDTO.source_ = result.type == ResourceType.ImageUrl ? result.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ result.id;
|
||||
imageDTO.resourceId = result.id;
|
||||
if(resource.id == null) {
|
||||
imageDTO.resourceId = null;
|
||||
imageDTO.source_ = null;
|
||||
} else {
|
||||
imageDTO.resourceId = resource.id;
|
||||
imageDTO.source_ = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
},
|
||||
isSmall: true
|
||||
),
|
||||
|
||||
@ -248,8 +248,13 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||
initialValue: sectionDTO != null ? sectionDTO.imageId : "",
|
||||
color: kPrimaryColor,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
sectionDTO.imageId = resource.id;
|
||||
sectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
if(resource.id == null) {
|
||||
sectionDTO.imageId = null;
|
||||
sectionDTO.imageSource = null;
|
||||
} else {
|
||||
sectionDTO.imageId = resource.id;
|
||||
sectionDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -286,8 +286,13 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
||||
initialValue: configurationDTO != null ? configurationDTO.imageId : "",
|
||||
color: kPrimaryColor,
|
||||
onChanged: (ResourceDTO resource) {
|
||||
configurationDTO.imageId = resource.id;
|
||||
configurationDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
if(resource.id == null) {
|
||||
configurationDTO.imageId = null;
|
||||
configurationDTO.imageSource = null;
|
||||
} else {
|
||||
configurationDTO.imageId = resource.id;
|
||||
configurationDTO.imageSource = resource.type == ResourceType.ImageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||
}
|
||||
},
|
||||
),
|
||||
])
|
||||
|
||||
@ -174,7 +174,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
|
||||
);
|
||||
} else {
|
||||
return Icon(
|
||||
Icons.add,
|
||||
Icons.close,
|
||||
color: kTextLightColor,
|
||||
size: 80.0,
|
||||
);
|
||||
@ -190,7 +190,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
|
||||
|
||||
boxDecoration(dynamic resourceDetailDTO, appContext) {
|
||||
return BoxDecoration(
|
||||
color: resourceDetailDTO.id == null ? kSuccess : kBackgroundColor,
|
||||
color: resourceDetailDTO.id == null ? kSecond : kBackgroundColor,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
image: resourceDetailDTO.id != null && (resourceDetailDTO.type == ResourceType.Image || resourceDetailDTO.data != null && resourceDetailDTO.type == ResourceType.ImageUrl)? new DecorationImage(
|
||||
|
||||
@ -47,8 +47,14 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if(snapshot.data != null) {
|
||||
var tempOutput = new List<ResourceDTO>.from(snapshot.data);
|
||||
// tempOutput.add(ResourceDTO(id: null));
|
||||
List<ResourceDTO> tempOutput = [];
|
||||
if(!widget.isAddButton) {
|
||||
tempOutput.add(ResourceDTO());
|
||||
tempOutput.addAll(new List<ResourceDTO>.from(snapshot.data));
|
||||
} else {
|
||||
tempOutput = new List<ResourceDTO>.from(snapshot.data);
|
||||
}
|
||||
|
||||
return ResourceBodyGrid(
|
||||
resources: tempOutput,
|
||||
resourceTypesIn: widget.isImage ? resource_types.where((rt) => rt.type == ResourceType.Image || rt.type == ResourceType.ImageUrl).map((rt) => rt.type).toList() : widget.resourceTypes,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user