import 'dart:convert'; import 'package:manager_app/Components/multi_string_input_and_resource_container.dart'; import 'package:manager_app/Components/resource_input_container.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/multi_string_input_container.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:manager_api_new/api.dart'; Future showNewOrUpdatePDFFile(OrderedTranslationAndResourceDTO? inputPdfFile, AppContext appContext, BuildContext context, String text) async { OrderedTranslationAndResourceDTO pdfFileDTO = new OrderedTranslationAndResourceDTO(); if (inputPdfFile != null) { pdfFileDTO = inputPdfFile; } else { pdfFileDTO.translationAndResourceDTOs = []; ManagerAppContext managerAppContext = appContext.getContext(); managerAppContext.selectedConfiguration!.languages!.forEach((element) { var translationMessageDTO = new TranslationAndResourceDTO(); translationMessageDTO.language = element; translationMessageDTO.value = ""; translationMessageDTO.resourceId = null; pdfFileDTO.translationAndResourceDTOs!.add(translationMessageDTO); }); } List newValues = []; List initials = []; languages.forEach((value) { if(initials.map((iv) => iv.language).contains(value)) { newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(initials.firstWhere((element) => element.language == value)))!)!); } else { // New language newValues.add(TranslationDTO(language: value, value: "")); } }); Size size = MediaQuery.of(context).size; var result = await showDialog( builder: (BuildContext dialogContext) => AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(20.0)) ), content: Container( width: size.width *0.5, child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text(text, style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Container( height: size.height * 0.2, constraints: BoxConstraints(minHeight: 50, maxHeight: 80), child: MultiStringInputAndResourceContainer( label: "Fichier et titre pdf :", modalLabel: "Fichier et titre pdf", fontSize: 20, color: kPrimaryColor, initialValue: pdfFileDTO.translationAndResourceDTOs != null ? pdfFileDTO.translationAndResourceDTOs! : [], resourceTypes: [ResourceType.Pdf], onGetResult: (value) { if (pdfFileDTO.translationAndResourceDTOs != value) { pdfFileDTO.translationAndResourceDTOs = value; } }, maxLines: 1, isTitle: true ), ), /*Container( height: size.height * 0.2, constraints: BoxConstraints(minHeight: 50, maxHeight: 80), child: ResourceInputContainer( label: "Icône catégorie :", initialValue: categorieDTO.iconResourceId, color: kPrimaryColor, onChanged: (ResourceDTO resource) { if(resource.id == null) { categorieDTO.iconResourceId = null; categorieDTO.iconUrl = null; } else { categorieDTO.iconResourceId = resource.id; categorieDTO.iconUrl = resource.url; print("Icône catégorieIcône catégorie"); print(categorieDTO); } }, isSmall: true ), ),*/ ], ), ], ), ), ), 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.pop(dialogContext); }, fontSize: 20, ), ), ), Align( alignment: AlignmentDirectional.bottomEnd, child: Container( width: inputPdfFile != null ? 220: 150, height: 70, child: RoundedButton( text: inputPdfFile != null ? "Sauvegarder" : "Créer", icon: Icons.check, color: kPrimaryColor, textColor: kWhite, press: () { if(pdfFileDTO.translationAndResourceDTOs != null && pdfFileDTO.translationAndResourceDTOs!.isNotEmpty) { Navigator.pop(dialogContext, pdfFileDTO); } }, fontSize: 20, ), ), ), ], ), ], ), context: context ); return result; }