96 lines
2.8 KiB
Dart
96 lines
2.8 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:manager_app/Screens/Resources/select_resource_modal.dart';
|
|
|
|
class ImageInputContainer extends StatefulWidget {
|
|
final Color color;
|
|
final String label;
|
|
final String initialValue;
|
|
final ValueChanged<String> onChanged;
|
|
const ImageInputContainer({
|
|
Key key,
|
|
this.color = kSecond,
|
|
this.label,
|
|
this.initialValue,
|
|
this.onChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_ImageInputContainerState createState() => _ImageInputContainerState();
|
|
}
|
|
|
|
class _ImageInputContainerState extends State<ImageInputContainer> {
|
|
String resourceIdToShow;
|
|
|
|
@override
|
|
void initState() {
|
|
resourceIdToShow = widget.initialValue;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Size size = MediaQuery.of(context).size;
|
|
return Container(
|
|
child: Row(
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Container(
|
|
width: size.width *0.2,
|
|
child: InkWell(
|
|
onTap: () {
|
|
showSelectResourceModal(
|
|
"Sélectionner une ressource",
|
|
(String resourceId) {
|
|
print('ON GET RESULT PARENT INPUT ');
|
|
widget.onChanged(resourceId);
|
|
setState(() {
|
|
print(resourceId);
|
|
resourceIdToShow = resourceId;
|
|
print('Set State');
|
|
});
|
|
},
|
|
1,
|
|
context
|
|
);
|
|
},
|
|
child: getElement(widget.initialValue, context),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
getElement(String initialValue, BuildContext context) {
|
|
print("getElement");
|
|
print(resourceIdToShow);
|
|
if (resourceIdToShow != null) {
|
|
return Text("Show image todo");
|
|
} else {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: widget.color,
|
|
borderRadius: BorderRadius.circular(50),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 15),
|
|
child: Center(
|
|
child: AutoSizeText(
|
|
"Choisir une image",
|
|
style: TextStyle(color: kWhite),
|
|
maxLines: 2,
|
|
)
|
|
),
|
|
)
|
|
);
|
|
}
|
|
}
|
|
} |