manager-app/lib/Components/multi_input_modal.dart

74 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:manager_app/Components/rounded_button.dart';
import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
showMultiStringInput (List<TranslationDTO> values, ValueChanged<List<TranslationDTO>> onChanged, BuildContext context) { /*Function onSelect,*/
List<TranslationDTO> newValues = new List<TranslationDTO>();
newValues = values;
showDialog(
builder: (BuildContext context) => AlertDialog(
content: SingleChildScrollView(
child: 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: () {
onChanged(values);
Navigator.of(context).pop();
},
fontSize: 20,
),
),
Container(
width: 180,
height: 70,
child: RoundedButton(
text: "Valider",
icon: Icons.check,
color: kPrimaryColor,
textColor: kWhite,
press: () {
onChanged(newValues);
Navigator.of(context).pop();
},
fontSize: 20,
),
),
],
),
],
), context: context
);
}
showValues(List<TranslationDTO> newValues) {
List<Widget> valuesToShow = new List<Widget>();
newValues.forEach((newValue) {
valuesToShow.add(
new StringContainer(
color: Colors.lightBlue,
label: newValue.language,
initialValue: newValue.value,
onChanged: (String value) {
newValue.value = value;
},
));
});
return valuesToShow;
}