Add update resource label possibility + update layout
This commit is contained in:
parent
ac91f114b2
commit
407fe28ead
@ -123,7 +123,6 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
|
||||
return FloatingActionButton(
|
||||
backgroundColor: kPrimaryColor.withOpacity(0.7),
|
||||
onPressed: () async {
|
||||
print("TODO");
|
||||
if(!isplaying && !audioplayed){
|
||||
//player.play(BytesSource(audiobytes));
|
||||
await player.setAudioSource(LoadedSource(audiobytes));
|
||||
|
||||
@ -73,7 +73,8 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
|
||||
} else {
|
||||
return Center(
|
||||
child: Container(
|
||||
height: size.height * 0.2,
|
||||
//height: size.height * 0.2,
|
||||
width: size.width * 0.2,
|
||||
child: LoadingCommon()
|
||||
)
|
||||
);
|
||||
|
||||
@ -70,7 +70,20 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
||||
setState(() {}); // For refresh
|
||||
}
|
||||
} else {
|
||||
showResource(value, appContext, context, size);
|
||||
var result = await showResource(value, appContext, context, size);
|
||||
if(result != null) {
|
||||
// Update resource
|
||||
ManagerAppContext managerAppContext = appContext.getContext() as ManagerAppContext;
|
||||
try{
|
||||
var resourceUpdated = managerAppContext.clientAPI.resourceApi.resourceUpdate(result);
|
||||
setState(() {
|
||||
// refresh ui
|
||||
showNotification(kSuccess, kWhite, 'La ressource a été mise à jour avec succès', context, null);
|
||||
});
|
||||
} catch (e) {
|
||||
print("Error during updating resource");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Result for select modal
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/confirmation_dialog.dart';
|
||||
import 'package:manager_app/Components/message_notification.dart';
|
||||
import 'package:manager_app/Components/rounded_button.dart';
|
||||
import 'package:manager_app/Components/string_input_container.dart';
|
||||
import 'package:manager_app/Models/managerContext.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
@ -9,8 +10,8 @@ import 'package:manager_api_new/api.dart';
|
||||
|
||||
import 'get_element_for_resource.dart';
|
||||
|
||||
void showResource(ResourceDTO resourceDTO, AppContext appContext, BuildContext context, Size size) {
|
||||
showDialog(
|
||||
Future<ResourceDTO> showResource(ResourceDTO resourceDTO, AppContext appContext, BuildContext context, Size size) async {
|
||||
var result = await showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||
@ -18,14 +19,28 @@ void showResource(ResourceDTO resourceDTO, AppContext appContext, BuildContext c
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.6,
|
||||
height: MediaQuery.of(context).size.height * 0.2,
|
||||
child: StringInputContainer(
|
||||
label: "Label :",
|
||||
initialValue: resourceDTO.label != null ? resourceDTO.label : "",
|
||||
onChanged: (value) {
|
||||
resourceDTO.label = value;
|
||||
},
|
||||
),
|
||||
),/*Text(
|
||||
resourceDTO.label == null ? "" : resourceDTO.label,
|
||||
style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||
style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),*/
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: size.height *0.5,
|
||||
height: resourceDTO.type == ResourceType.Audio ? size.height *0.1 : size.height *0.3,
|
||||
width: resourceDTO.type == ResourceType.Audio ? size.width *0.1 : size.width *0.3,
|
||||
child: Center(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
@ -85,11 +100,33 @@ void showResource(ResourceDTO resourceDTO, AppContext appContext, BuildContext c
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.bottomEnd,
|
||||
child: Container(
|
||||
width: 220,
|
||||
height: 70,
|
||||
child: RoundedButton(
|
||||
text: "Sauvegarder",
|
||||
icon: Icons.check,
|
||||
color: kPrimaryColor,
|
||||
press: () {
|
||||
if (resourceDTO.label != null && resourceDTO.label.length > 2) {
|
||||
Navigator.pop(context, resourceDTO);
|
||||
}
|
||||
},
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
), context: context
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<void> delete(ResourceDTO resourceDTO, AppContext appContext, context) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user