Update media_picker.dart

This commit is contained in:
Bram Bakker 2023-03-29 16:10:44 +02:00
parent 4a8138f4f7
commit be6c331e0b

View file

@ -109,6 +109,7 @@ class MediaPicker extends StatefulWidget {
this.horizontalSpacing = 0, this.horizontalSpacing = 0,
this.verticalSpacing = 0, this.verticalSpacing = 0,
this.loadingIconColor, this.loadingIconColor,
this.disabledPickers,
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@ -118,6 +119,7 @@ class MediaPicker extends StatefulWidget {
final double horizontalSpacing; final double horizontalSpacing;
final double verticalSpacing; final double verticalSpacing;
final Color? loadingIconColor; final Color? loadingIconColor;
final List<String>? disabledPickers;
final Widget Function( final Widget Function(
Widget displayResult, Widget displayResult,
Map<String, dynamic>? inputSettings, Map<String, dynamic>? inputSettings,
@ -148,7 +150,6 @@ class _MediaPickerState extends State<MediaPicker> {
} }
var theme = Theme.of(context); var theme = Theme.of(context);
return Wrap( return Wrap(
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
direction: widget.inputsDirection, direction: widget.inputsDirection,
@ -165,41 +166,81 @@ class _MediaPickerState extends State<MediaPicker> {
), ),
] else ...[ ] else ...[
for (final input in inputs) ...[ for (final input in inputs) ...[
GestureDetector( if (widget.disabledPickers!.contains(input.label) == true) ...[
onTap: () async { IgnorePointer(
setState(() { child: GestureDetector(
_isLoading = true; onTap: () async {
}); setState(() {
await onPressedMediaType(context, input); _isLoading = true;
}, });
child: Wrap( await onPressedMediaType(context, input);
children: [ },
input.widget ?? child: Wrap(
Container( children: [
height: 55, input.widget ??
width: MediaQuery.of(context).size.width * 0.9, Container(
decoration: const BoxDecoration( height: 55,
border: Border( width: MediaQuery.of(context).size.width * 0.9,
bottom: BorderSide( decoration: const BoxDecoration(
color: Color(0xFF979797), border: Border(
width: 1, bottom: BorderSide(
color: Color(0xFF979797),
width: 1,
),
),
),
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Text(
input.label,
style: theme.textTheme.titleLarge,
),
),
), ),
), ),
), ],
child: Align( ),
alignment: Alignment.centerLeft, ),
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Text(
input.label,
style: theme.textTheme.titleLarge,
),
),
),
),
],
), ),
), ] else ...[
GestureDetector(
onTap: () async {
setState(() {
_isLoading = true;
});
await onPressedMediaType(context, input);
},
child: Wrap(
children: [
input.widget ??
Container(
height: 55,
width: MediaQuery.of(context).size.width * 0.9,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: Color(0xFF979797),
width: 1,
),
),
),
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 15),
child: Text(
input.label,
style: theme.textTheme.titleLarge,
),
),
),
),
],
),
),
],
] ]
] ]
], ],