manager-app/lib/Screens/Resources/select_resource_modal.dart

97 lines
3.0 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/Screens/Resources/resources_screen.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
showSelectResourceModal (String text, Function onGetResult, int maxLines, BuildContext mainContext) { /*Function onSelect,*/
Size size = MediaQuery.of(mainContext).size;
showDialog(
builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
),
title: Center(child: Text(text)),
content: SingleChildScrollView(
child: Column(
children: [
Container(
width: size.width * 0.6,
height: size.height * 0.6,
child: ResourcesScreen(
onGetResult: (String resourceId) {
if (resourceId != null) {
onGetResult(resourceId);
Navigator.of(mainContext).pop();
}
},
isImage: true,
),
),
/*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);
print("TODO onGetResult");
Navigator.of(context).pop();
},
fontSize: 20,
),
),
/*Container(
width: 180,
height: 70,
child: RoundedButton(
text: "Valider",
icon: Icons.check,
color: kPrimaryColor,
textColor: kWhite,
press: () {
print("TODO Valider resource selected");
Navigator.of(context).pop();
},
fontSize: 20,
),
),*/
],
),
],
), context: mainContext
);
}
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;
}