137 lines
4.9 KiB
Dart
137 lines
4.9 KiB
Dart
import 'package:manager_app/Components/image_input_container.dart';
|
|
import 'package:manager_app/Components/multi_string_input_container.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/rounded_button.dart';
|
|
import 'package:manager_app/Models/managerContext.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:managerapi/api.dart';
|
|
|
|
void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppContext appContext, BuildContext context) {
|
|
ImageDTO imageDTO = new ImageDTO();
|
|
|
|
if (inputImageDTO != null) {
|
|
print("inputImageDTO.source_ != null NOT NULLLLL");
|
|
imageDTO = inputImageDTO;
|
|
} else {
|
|
imageDTO.title = <TranslationDTO>[];
|
|
imageDTO.description = <TranslationDTO>[];
|
|
|
|
ManagerAppContext managerAppContext = appContext.getContext();
|
|
managerAppContext.selectedConfiguration.languages.forEach((element) {
|
|
var translationDTO = new TranslationDTO();
|
|
translationDTO.language = element;
|
|
translationDTO.value = "";
|
|
imageDTO.title.add(translationDTO);
|
|
imageDTO.description.add(translationDTO);
|
|
});
|
|
}
|
|
|
|
print(imageDTO);
|
|
|
|
Size size = MediaQuery.of(context).size;
|
|
showDialog(
|
|
builder: (BuildContext context) => AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
|
),
|
|
content: Container(
|
|
width: size.width *0.5,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Text("Nouvelle image/vidéo", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
|
Column(
|
|
children: [
|
|
ImageInputContainer(
|
|
label: "Image :",
|
|
initialValue: imageDTO.resourceId,
|
|
color: kPrimaryColor,
|
|
onChanged: (ResourceDTO resource) {
|
|
imageDTO.source_ = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
|
imageDTO.resourceId = resource.id;
|
|
},
|
|
),
|
|
MultiStringContainer(
|
|
label: "Titre :",
|
|
color: kPrimaryColor,
|
|
initialValue: imageDTO.title,
|
|
onGetResult: (value) {
|
|
print("Received titres");
|
|
|
|
if (imageDTO.title != value) {
|
|
imageDTO.title = value;
|
|
}
|
|
print(imageDTO.title);
|
|
},
|
|
maxLines: 1,
|
|
),
|
|
MultiStringContainer(
|
|
label: "Description :",
|
|
color: kPrimaryColor,
|
|
initialValue: imageDTO.description,
|
|
onGetResult: (value) {
|
|
print("Received descriptions");
|
|
print(value);
|
|
if (imageDTO.description != value) {
|
|
imageDTO.description = value;
|
|
}
|
|
print(imageDTO.description);
|
|
},
|
|
maxLines: 1,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
child: Container(
|
|
width: 175,
|
|
height: 70,
|
|
child: RoundedButton(
|
|
text: "Annuler",
|
|
icon: Icons.undo,
|
|
color: kSecond,
|
|
press: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
Align(
|
|
alignment: AlignmentDirectional.bottomEnd,
|
|
child: Container(
|
|
width: inputImageDTO != null ? 220: 150,
|
|
height: 70,
|
|
child: RoundedButton(
|
|
text: inputImageDTO != null ? "Sauvegarder" : "Créer",
|
|
icon: Icons.check,
|
|
color: kPrimaryColor,
|
|
textColor: kWhite,
|
|
press: () {
|
|
print("TODO create or update");
|
|
print(imageDTO);
|
|
getResult(imageDTO);
|
|
print("result sent");
|
|
Navigator.of(context).pop();
|
|
},
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
), context: context
|
|
);
|
|
}
|
|
|