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

79 lines
2.4 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';
dynamic showSelectResourceModal (String text, int maxLines, List<ResourceType> resourceTypes, BuildContext mainContext) async { /*Function onSelect,*/
Size size = MediaQuery.of(mainContext).size;
var result = await 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.7,
height: size.height * 0.75,
child: ResourcesScreen(
isAddButton: false,
onGetResult: (ResourceDTO resource) {
if (resource != null) {
var result = resource;
Navigator.pop(context, result);
}
},
resourceTypes: resourceTypes,
),
),
],
)
),
actions: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 180,
height: 70,
child: RoundedButton(
text: "Annuler",
icon: Icons.undo,
color: kSecond,
press: () {
Navigator.of(context).pop();
},
fontSize: 20,
),
),
],
),
],
), context: mainContext
);
return result;
}
showValues(List<TranslationDTO> newValues) {
List<Widget> valuesToShow = <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;
}