169 lines
5.9 KiB
Dart
169 lines
5.9 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/Components/rounded_button.dart';
|
|
import 'package:manager_app/Components/text_form_input_container.dart';
|
|
import 'package:manager_app/Models/managerContext.dart';
|
|
import 'package:manager_app/Screens/Resources/select_resource_modal.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:manager_api_new/api.dart';
|
|
import 'package:collection/collection.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'audio_input_container.dart';
|
|
|
|
|
|
showMultiStringInput (String label, String modalLabel, bool isTitle, List<TranslationDTO> values, List<TranslationDTO> newValues, Function onGetResult, int maxLines, bool isAudio, BuildContext context) { /*Function onSelect,*/
|
|
showDialog(
|
|
builder: (BuildContext context) => AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
|
),
|
|
title: Center(child: Text(modalLabel)),
|
|
content: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: getTranslations(context, Provider.of<AppContext>(context), label, isTitle, isAudio, newValues),
|
|
),
|
|
),
|
|
),
|
|
/*Container(
|
|
width: 500,
|
|
height: 200,
|
|
child: TranslationTab(
|
|
translations: newValues,
|
|
maxLines: maxLines
|
|
)
|
|
),*/
|
|
/*Column(
|
|
children: showValues(newValues),
|
|
),*/
|
|
],
|
|
)
|
|
),
|
|
actions: <Widget>[
|
|
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)) {
|
|
onGetResult(newValues);
|
|
}
|
|
Navigator.of(context).pop();
|
|
},
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
), context: context
|
|
);
|
|
}
|
|
|
|
getTranslations(BuildContext context, AppContext appContext, String label, bool isTitle, bool isAudio, List<TranslationDTO> newValues) {
|
|
List<Widget> translations = <Widget>[];
|
|
ManagerAppContext managerAppContext = appContext.getContext();
|
|
for(var language in managerAppContext.selectedConfiguration.languages) {
|
|
translations.add(
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
width: MediaQuery.of(context).size.width *0.05,
|
|
height: MediaQuery.of(context).size.height *0.10,
|
|
decoration: BoxDecoration(
|
|
border: Border(
|
|
right: BorderSide(width: 1.5, color: kSecond),
|
|
),
|
|
),
|
|
child: Center(child: AutoSizeText(language.toUpperCase()))
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
child: Container(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
!isAudio ?
|
|
TextFormInputContainer(
|
|
label: label,
|
|
color: kWhite,
|
|
isTitle: isTitle,
|
|
initialValue: newValues.where((element) => element.language == language).first.value,
|
|
onChanged: (value) {
|
|
newValues.where((element) => element.language == language).first.value = value;
|
|
},
|
|
) :
|
|
Container(
|
|
width: 250,
|
|
height: 120,
|
|
child: AudioInputContainer(
|
|
label: "Audio :",
|
|
initialValue: newValues.where((element) => element.language == language).first.value,
|
|
color: kPrimaryColor,
|
|
onChanged: (ResourceDTO resource) {
|
|
newValues.where((element) => element.language == language).first.value = resource.id;
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
)
|
|
);
|
|
}
|
|
return translations;
|
|
}
|
|
/*
|
|
showValues(List<TranslationDTO> newValues) {
|
|
List<Widget> valuesToShow = new List<Widget>();
|
|
newValues.forEach((newValue) {
|
|
valuesToShow.add(
|
|
new StringInputContainer(
|
|
color: Colors.lightBlue,
|
|
label: newValue.language,
|
|
initialValue: newValue.value,
|
|
onChanged: (String value) {
|
|
newValue.value = value;
|
|
},
|
|
));
|
|
});
|
|
return valuesToShow;
|
|
}*/
|