diff --git a/example/ios/Podfile b/example/ios/Podfile index bb026eb..63b4e6c 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '11.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 6991b50..2889752 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -59,11 +59,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 - file_picker: ce3938a0df3cc1ef404671531facef740d03f920 - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + file_picker: a0560bc09d61de87f12d246fc47d2119e6ef37be + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 SDWebImage: 1c39de67663e5eebb2f41324d5d580eeea12dd4c SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f -PODFILE CHECKSUM: 241ff90fd4cafe2ad317569236de3a478bea1b03 +PODFILE CHECKSUM: c72a7f1dd1e058573ba6fd9cf4f251b60434bc5b -COCOAPODS: 1.11.3 +COCOAPODS: 1.16.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 53556f4..bcab0b0 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + DBD69ACC5CC460CA051D29E5 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C00575E57111313065C9F9B /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -45,9 +46,11 @@ 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 4E85868E43666D91678AA906 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 8C00575E57111313065C9F9B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -55,6 +58,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C77E02D8A7E5743EE4395169 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + DB04B01663E9E9EC2B4EF6FF /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -62,12 +67,24 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DBD69ACC5CC460CA051D29E5 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0D3E478BAA88EA793F9EFF9B /* Pods */ = { + isa = PBXGroup; + children = ( + C77E02D8A7E5743EE4395169 /* Pods-Runner.debug.xcconfig */, + 4E85868E43666D91678AA906 /* Pods-Runner.release.xcconfig */, + DB04B01663E9E9EC2B4EF6FF /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 331C8082294A63A400263BE5 /* RunnerTests */ = { isa = PBXGroup; children = ( @@ -94,6 +111,8 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, + 0D3E478BAA88EA793F9EFF9B /* Pods */, + 9CD7D48BCEEB070AFC1263A2 /* Frameworks */, ); sourceTree = ""; }; @@ -121,6 +140,14 @@ path = Runner; sourceTree = ""; }; + 9CD7D48BCEEB070AFC1263A2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 8C00575E57111313065C9F9B /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -145,12 +172,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 60E42B1B857F2D5CEDD1379F /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + E7ED4D797A3AECC834B9126D /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -238,6 +267,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 60E42B1B857F2D5CEDD1379F /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -253,6 +304,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + E7ED4D797A3AECC834B9126D /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/example/lib/main.dart b/example/lib/main.dart index 24b23e4..fcb5a04 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -26,7 +26,7 @@ class MyHomePage extends StatefulWidget { class MyHomePageState extends State { final _formKey = GlobalKey(); - bool _useCustomFileViewer = true; + bool _useCustomFileViewer = false; @override Widget build(BuildContext context) { @@ -69,6 +69,12 @@ class MyHomePageState extends State { ? (files, filesSetter) => customFileViewerBuilder(files ?? [], (newValue) {}) : null, + onDefaultViewerItemTap: + _useCustomFileViewer + ? null + : (PlatformFile file, int index) { + debugPrint(file.name); + }, ), const SizedBox(height: 20), Row( @@ -81,12 +87,11 @@ class MyHomePageState extends State { debugPrint(_formKey.currentState!.value.toString()); }, ), - const Spacer(), ElevatedButton( child: Text( _useCustomFileViewer - ? 'Use Default File Viewer' - : 'Use Custom File Viewer', + ? 'Use Default Viewer' + : 'Use Custom Viewer', ), onPressed: () { setState( @@ -94,7 +99,6 @@ class MyHomePageState extends State { ); }, ), - const Spacer(), ElevatedButton( child: const Text('Reset'), onPressed: () { diff --git a/lib/src/form_builder_file_picker.dart b/lib/src/form_builder_file_picker.dart index abb153e..a23b59f 100644 --- a/lib/src/form_builder_file_picker.dart +++ b/lib/src/form_builder_file_picker.dart @@ -20,6 +20,9 @@ typedef FileViewerBuilder = FormFieldSetter> filesSetter, ); +typedef OnDefaultFileViewerBuilderItemTap = + void Function(PlatformFile file, int index); + class TypeSelector { final FileType type; final Widget selector; @@ -77,6 +80,9 @@ class FormBuilderFilePicker /// Allow to customise the view of the pickers. final Widget Function(List types)? customTypeViewerBuilder; + /// Allow to set file tap functionality callback + final OnDefaultFileViewerBuilderItemTap? onDefaultViewerItemTap; + /// Creates field for image(s) from user device storage FormBuilderFilePicker({ //From Super @@ -110,6 +116,7 @@ class FormBuilderFilePicker this.compressionQuality = 0, this.customFileViewerBuilder, this.customTypeViewerBuilder, + this.onDefaultViewerItemTap, }) : super( builder: (FormFieldState?> field) { final state = field as _FormBuilderFilePickerState; @@ -143,6 +150,7 @@ class FormBuilderFilePicker : state.defaultFileViewer( state._files, (files) => state._setFiles(files ?? [], field), + onDefaultViewerItemTap, ), ], ), @@ -238,6 +246,7 @@ class _FormBuilderFilePickerState Widget defaultFileViewer( List files, FormFieldSetter> setter, + OnDefaultFileViewerBuilderItemTap? onItemTap, ) { final theme = Theme.of(context); @@ -260,31 +269,38 @@ class _FormBuilderFilePickerState child: Stack( alignment: Alignment.bottomCenter, children: [ - Container( - alignment: Alignment.center, - child: - (imageFileExts.contains( - files[index].extension!.toLowerCase(), - ) && - widget.previewImages) - ? widget.withData - ? Image.memory( - files[index].bytes!, - fit: BoxFit.cover, - ) - : Image.file( - File(files[index].path!), - fit: BoxFit.cover, - ) - : Container( - alignment: Alignment.center, - color: theme.primaryColor, - child: Icon( - getIconData(files[index].extension!), - color: Colors.white, - size: 56, + InkWell( + onTap: () { + if (onItemTap != null) { + onItemTap(files[index], index); + } + }, + child: Container( + alignment: Alignment.center, + child: + (imageFileExts.contains( + files[index].extension!.toLowerCase(), + ) && + widget.previewImages) + ? widget.withData + ? Image.memory( + files[index].bytes!, + fit: BoxFit.cover, + ) + : Image.file( + File(files[index].path!), + fit: BoxFit.cover, + ) + : Container( + alignment: Alignment.center, + color: theme.primaryColor, + child: Icon( + getIconData(files[index].extension!), + color: Colors.white, + size: 56, + ), ), - ), + ), ), Container( padding: const EdgeInsets.symmetric(horizontal: 2),