import 'package:auto_size_text/auto_size_text.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/Components/string_input_container.dart'; import 'package:manager_app/Components/text_form_input_container.dart'; import 'package:manager_app/Models/managerContext.dart'; import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/geopoint_image_list.dart'; import 'package:manager_app/app_context.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; void showNewOrUpdateGeoPoint(GeoPointDTO? inputGeoPointDTO, Function getResult, AppContext appContext, BuildContext context) { GeoPointDTO geoPointDTO = new GeoPointDTO(); if (inputGeoPointDTO != null) { geoPointDTO = inputGeoPointDTO; } else { geoPointDTO.title = []; geoPointDTO.description = []; geoPointDTO.contents = []; ManagerAppContext managerAppContext = appContext.getContext(); managerAppContext.selectedConfiguration!.languages!.forEach((element) { var translationDTO = new TranslationDTO(); translationDTO.language = element; translationDTO.value = ""; geoPointDTO.title!.add(translationDTO); geoPointDTO.description!.add(translationDTO); }); } 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.7, child: SingleChildScrollView( child: Column( children: [ Text("Point géographique", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)), Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ StringInputContainer( label: "Latitude (#.#):", initialValue: geoPointDTO.latitude, onChanged: (value) { geoPointDTO.latitude = value; }, ), StringInputContainer( label: "Longitude (#.#):", initialValue: geoPointDTO.longitude, onChanged: (value) { geoPointDTO.longitude = value; }, ) ], ), Container( height: size.height * 0.2, width: double.infinity, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Container( constraints: BoxConstraints(minHeight: 50, maxHeight: 80), child: MultiStringInputContainer( label: "Titre affiché:", modalLabel: "Titre", fontSize: 20, isHTML: true, color: kPrimaryColor, initialValue: geoPointDTO.title != null ? geoPointDTO.title! : [], onGetResult: (value) { if (geoPointDTO.title != value) { geoPointDTO.title = value; } }, maxLines: 1, isTitle: true ), ), Container( constraints: BoxConstraints(minHeight: 50, maxHeight: 80), child: MultiStringInputContainer( label: "Description affichée:", modalLabel: "Description", fontSize: 20, isHTML: true, color: kPrimaryColor, initialValue: geoPointDTO.description != null ? geoPointDTO.description! : [], onGetResult: (value) { if (geoPointDTO.description != value) { geoPointDTO.description = value; } }, maxLines: 1, isTitle: false ), ), ], ), ), Container( height: size.height * 0.33, decoration: BoxDecoration( color: kWhite, shape: BoxShape.rectangle, border: Border.all(width: 1.5, color: kSecond), borderRadius: BorderRadius.circular(10.0), boxShadow: [ BoxShadow( color: kSecond, spreadRadius: 0.5, blurRadius: 5, offset: Offset(0, 1.5), // changes position of shadow ), ], ), child: GeoPointContentList( contents: geoPointDTO.contents!, onChanged: (List contentsOutput) { geoPointDTO.contents = contentsOutput; }, ), ), ], ), ], ), ), ), 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: () { if (inputGeoPointDTO != null) { geoPointDTO.contents = inputGeoPointDTO.contents; } Navigator.of(context).pop(); }, fontSize: 20, ), ), ), Align( alignment: AlignmentDirectional.bottomEnd, child: Container( width: geoPointDTO != null ? 220: 150, height: 70, child: RoundedButton( text: geoPointDTO != null ? "Sauvegarder" : "Créer", icon: Icons.check, color: kPrimaryColor, textColor: kWhite, press: () { if (geoPointDTO.latitude != null && geoPointDTO.longitude != null) { getResult(geoPointDTO); Navigator.of(context).pop(); } }, fontSize: 20, ), ), ), ], ), ], ), context: context ); }