Add isSmall in image container
This commit is contained in:
parent
b4a4d21c56
commit
9872eeb0e9
@ -1,7 +1,6 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/loading.dart';
|
||||
import 'package:manager_app/Screens/Resources/fetch_image_for_resource.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
import 'package:manager_app/Screens/Resources/select_resource_modal.dart';
|
||||
@ -14,6 +13,7 @@ class ImageInputContainer extends StatefulWidget {
|
||||
final String initialValue;
|
||||
final ValueChanged<ResourceDTO> onChanged;
|
||||
final BoxFit imageFit;
|
||||
final bool isSmall;
|
||||
const ImageInputContainer({
|
||||
Key key,
|
||||
this.color = kSecond,
|
||||
@ -21,6 +21,7 @@ class ImageInputContainer extends StatefulWidget {
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
this.imageFit = BoxFit.cover,
|
||||
this.isSmall = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -47,25 +48,26 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
child: Text(widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
padding: EdgeInsets.only(left: widget.isSmall ? 15 : 50, top: 10, bottom: 10),
|
||||
child: Container(
|
||||
width: size.width *0.08,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showSelectResourceModal(
|
||||
onTap: () async {
|
||||
var result = await showSelectResourceModal(
|
||||
"Sélectionner une ressource",
|
||||
(ResourceDTO resource) {
|
||||
widget.onChanged(resource);
|
||||
setState(() {
|
||||
resourceIdToShow = resource.id;
|
||||
});
|
||||
},
|
||||
1,
|
||||
true,
|
||||
context
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
resourceIdToShow = result.id;
|
||||
});
|
||||
widget.onChanged(result);
|
||||
}
|
||||
},
|
||||
child: getElement(widget.initialValue, context),
|
||||
child: getElement(widget.initialValue, context, widget.isSmall),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -74,7 +76,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
);
|
||||
}
|
||||
|
||||
getElement(String initialValue, BuildContext context) {
|
||||
getElement(String initialValue, BuildContext context, bool isSmall) {
|
||||
if (resourceIdToShow != null) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
@ -83,7 +85,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return Transform.scale(
|
||||
scale: size.aspectRatio * 0.3,
|
||||
scale: isSmall ? size.aspectRatio * 0.5: size.aspectRatio,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 4/4,
|
||||
child: Container(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user