Merge pull request #14 from Iconica-Development/feature/disableable

Feature/disableable
This commit is contained in:
Gorter-dev 2023-03-30 10:26:05 +02:00 committed by GitHub
commit 2094383f46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 37 deletions

View file

@ -1,7 +1,12 @@
## 0.5.0
- added the ability to disable certain pickers in the code
## 0.4.0 ## 0.4.0
- Bump `flutter_form_wizard` to version 6.0.0 - Bump `flutter_form_wizard` to version 6.0.0
- Remove unnecessary `riverpod` dependency - Remove unnecessary `riverpod` dependency
## 0.3.5 ## 0.3.5
- Fixed left button - Fixed left button
@ -13,6 +18,7 @@
## 0.3.3 ## 0.3.3
- Added optional left button on audio picker - Added optional left button on audio picker
## 0.3.2 ## 0.3.2
- Fixed an incorrect import on web - Fixed an incorrect import on web

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,13 @@ 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: gestureDetectorWidget(input, theme),
_isLoading = true; )
}); ] else ...[
await onPressedMediaType(context, input); gestureDetectorWidget(input, theme),
},
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,
),
),
),
),
], ],
),
),
] ]
] ]
], ],
@ -254,4 +227,42 @@ class _MediaPickerState extends State<MediaPicker> {
bool _hasContent(MediaResult content) { bool _hasContent(MediaResult content) {
return content.fileValue != null || content.textValue != null; return content.fileValue != null || content.textValue != null;
} }
Widget gestureDetectorWidget(MediaPickerInput input, ThemeData theme) {
return 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,
),
),
),
),
],
),
);
}
} }

View file

@ -1,6 +1,6 @@
name: flutter_media_picker name: flutter_media_picker
description: A new Flutter package project. description: A new Flutter package project.
version: 0.4.0 version: 0.5.0
homepage: https://github.com/Iconica-Development/flutter_media_picker homepage: https://github.com/Iconica-Development/flutter_media_picker
publish_to: "none" publish_to: "none"