From be6c331e0b786c8e0e83f8ce309eb89b97b14bb4 Mon Sep 17 00:00:00 2001 From: Bram Bakker Date: Wed, 29 Mar 2023 16:10:44 +0200 Subject: [PATCH 1/3] Update media_picker.dart --- lib/src/media_picker.dart | 107 ++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 33 deletions(-) diff --git a/lib/src/media_picker.dart b/lib/src/media_picker.dart index 82c0961..5a068cc 100644 --- a/lib/src/media_picker.dart +++ b/lib/src/media_picker.dart @@ -109,6 +109,7 @@ class MediaPicker extends StatefulWidget { this.horizontalSpacing = 0, this.verticalSpacing = 0, this.loadingIconColor, + this.disabledPickers, Key? key, }) : super(key: key); @@ -118,6 +119,7 @@ class MediaPicker extends StatefulWidget { final double horizontalSpacing; final double verticalSpacing; final Color? loadingIconColor; + final List? disabledPickers; final Widget Function( Widget displayResult, Map? inputSettings, @@ -148,7 +150,6 @@ class _MediaPickerState extends State { } var theme = Theme.of(context); - return Wrap( alignment: WrapAlignment.center, direction: widget.inputsDirection, @@ -165,41 +166,81 @@ class _MediaPickerState extends State { ), ] else ...[ for (final input in inputs) ...[ - 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, + if (widget.disabledPickers!.contains(input.label) == true) ...[ + IgnorePointer( + child: 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, + ), + ), ), ), - ), - 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, + ), + ), + ), + ), + ], + ), + ), + ], ] ] ], From cfcbf051359cf3851168e9248a4281b981913b6c Mon Sep 17 00:00:00 2001 From: Bram Bakker Date: Wed, 29 Mar 2023 16:59:03 +0200 Subject: [PATCH 2/3] moved gestureDetector into Widget class --- lib/src/media_picker.dart | 112 ++++++++++++++------------------------ 1 file changed, 41 insertions(+), 71 deletions(-) diff --git a/lib/src/media_picker.dart b/lib/src/media_picker.dart index 5a068cc..c5c4e35 100644 --- a/lib/src/media_picker.dart +++ b/lib/src/media_picker.dart @@ -168,78 +168,10 @@ class _MediaPickerState extends State { for (final input in inputs) ...[ if (widget.disabledPickers!.contains(input.label) == true) ...[ IgnorePointer( - child: 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, - ), - ), - ), - ), - ], - ), - ), - ), + child: gestureDetectorWidget(input, theme), + ) ] 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, - ), - ), - ), - ), - ], - ), - ), + gestureDetectorWidget(input, theme), ], ] ] @@ -295,4 +227,42 @@ class _MediaPickerState extends State { bool _hasContent(MediaResult content) { 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, + ), + ), + ), + ), + ], + ), + ); + } } From 51351137c1a968b32ba05f827d488306b4094085 Mon Sep 17 00:00:00 2001 From: Bram Bakker Date: Thu, 30 Mar 2023 10:23:52 +0200 Subject: [PATCH 3/3] Updated version nr and changelog --- CHANGELOG.md | 6 ++++++ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bf3b6b..be5b147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ +## 0.5.0 + +- added the ability to disable certain pickers in the code + ## 0.4.0 - Bump `flutter_form_wizard` to version 6.0.0 - Remove unnecessary `riverpod` dependency + ## 0.3.5 - Fixed left button @@ -13,6 +18,7 @@ ## 0.3.3 - Added optional left button on audio picker + ## 0.3.2 - Fixed an incorrect import on web diff --git a/pubspec.yaml b/pubspec.yaml index 53fcc8a..ef1475a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_media_picker description: A new Flutter package project. -version: 0.4.0 +version: 0.5.0 homepage: https://github.com/Iconica-Development/flutter_media_picker publish_to: "none"