import 'package:flutter/material.dart'; import 'package:manager_app/Components/message_notification.dart'; import 'package:manager_app/Components/rounded_button.dart'; import 'package:manager_app/Components/translation_input_and_resource_container.dart'; import 'package:manager_app/Components/translation_input_container.dart'; import 'package:manager_app/constants.dart'; import 'package:manager_api_new/api.dart'; import 'package:collection/collection.dart'; showMultiStringInputHTML (String label, String modalLabel, bool isTitle, List values, List newValues, Function onGetResult, int maxLines, List? resourceTypes, BuildContext context, bool isMandatory) { showDialog( useRootNavigator: false, builder: (BuildContext context) { return AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(20.0)) ), title: Center(child: Text(modalLabel)), content: SingleChildScrollView( child: TranslationInputContainer(isTitle: isTitle, values: values, newValues: newValues, onGetResult: onGetResult, maxLines: maxLines, resourceTypes: resourceTypes) ), actions: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( width: 180, height: 70, child: RoundedButton( text: "Annuler", icon: Icons.undo, color: kSecond, press: () { onGetResult(values); Navigator.of(context).pop(); }, fontSize: 20, ), ), Container( width: 180, height: 70, child: RoundedButton( text: "Valider", icon: Icons.check, color: kPrimaryColor, textColor: kWhite, press: () { Function deepEq = const DeepCollectionEquality().equals; if (!deepEq(values, newValues)) { if(isMandatory && newValues.any((label) => label.value == null || label.value!.trim() == "")) { showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null); } else { onGetResult(newValues); Navigator.of(context).pop(); } } else { Navigator.of(context).pop(); } }, fontSize: 20, ), ), ], ), ], ); }, context: context ); } showMultiStringInputAndResourceHTML (String label, String modalLabel, bool isTitle, List values, List newValues, Function onGetResult, int maxLines, List? resourceTypes, BuildContext context) { showDialog( useRootNavigator: false, builder: (BuildContext context) { return AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(20.0)) ), title: Center(child: Text(modalLabel)), content: SingleChildScrollView( child: TranslationInputAndResourceContainer(isTitle: isTitle, values: values, newValues: newValues, onGetResult: onGetResult, maxLines: maxLines, resourceTypes: resourceTypes) ), actions: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( width: 180, height: 70, child: RoundedButton( text: "Annuler", icon: Icons.undo, color: kSecond, press: () { onGetResult(values); Navigator.of(context).pop(); }, fontSize: 20, ), ), Container( width: 180, height: 70, child: RoundedButton( text: "Valider", icon: Icons.check, color: kPrimaryColor, textColor: kWhite, press: () { Function deepEq = const DeepCollectionEquality().equals; if (!deepEq(values, newValues)) { if(newValues.any((label) => label.value == null || label.value!.trim() == "")) { showNotification(kPrimaryColor, kWhite, "La traduction n'est pas complète", context, null); } else { onGetResult(newValues); Navigator.of(context).pop(); } } else { Navigator.of(context).pop(); } }, fontSize: 20, ), ), ], ), ], ); }, context: context ); }