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.source_ != null) { print("inputImageDTO.source_ != null NOT NULLLLL"); imageDTO = inputImageDTO; } else { imageDTO.title = new List(); imageDTO.description = new List(); 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.source_, color: kPrimaryColor, onChanged: (value) { print("received value in grant older"); imageDTO.source_ = value; }, ), 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: [ 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.source_ != null ? 200: 150, height: 70, child: RoundedButton( text: inputImageDTO.source_ != 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 ); }