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