Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 68 additions & 0 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -45,29 +46,45 @@
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
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 = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
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 = "<group>";
};
331C8082294A63A400263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
Expand All @@ -94,6 +111,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
0D3E478BAA88EA793F9EFF9B /* Pods */,
9CD7D48BCEEB070AFC1263A2 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -121,6 +140,14 @@
path = Runner;
sourceTree = "<group>";
};
9CD7D48BCEEB070AFC1263A2 /* Frameworks */ = {
isa = PBXGroup;
children = (
8C00575E57111313065C9F9B /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -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 = (
);
Expand Down Expand Up @@ -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;
Expand All @@ -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 */
Expand Down
3 changes: 3 additions & 0 deletions example/ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MyHomePage extends StatefulWidget {

class MyHomePageState extends State<MyHomePage> {
final _formKey = GlobalKey<FormBuilderState>();
bool _useCustomFileViewer = true;
bool _useCustomFileViewer = false;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -69,6 +69,12 @@ class MyHomePageState extends State<MyHomePage> {
? (files, filesSetter) =>
customFileViewerBuilder(files ?? [], (newValue) {})
: null,
onDefaultViewerItemTap:
_useCustomFileViewer
? null
: (PlatformFile file, int index) {
debugPrint(file.name);
},
),
const SizedBox(height: 20),
Row(
Expand All @@ -81,20 +87,18 @@ class MyHomePageState extends State<MyHomePage> {
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(
() => _useCustomFileViewer = !_useCustomFileViewer,
);
},
),
const Spacer(),
ElevatedButton(
child: const Text('Reset'),
onPressed: () {
Expand Down
64 changes: 40 additions & 24 deletions lib/src/form_builder_file_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ typedef FileViewerBuilder =
FormFieldSetter<List<PlatformFile>> filesSetter,
);

typedef OnDefaultFileViewerBuilderItemTap =
void Function(PlatformFile file, int index);

class TypeSelector {
final FileType type;
final Widget selector;
Expand Down Expand Up @@ -77,6 +80,9 @@ class FormBuilderFilePicker
/// Allow to customise the view of the pickers.
final Widget Function(List<Widget> types)? customTypeViewerBuilder;

/// Allow to set file tap functionality callback
final OnDefaultFileViewerBuilderItemTap? onDefaultViewerItemTap;

/// Creates field for image(s) from user device storage
FormBuilderFilePicker({
//From Super
Expand Down Expand Up @@ -110,6 +116,7 @@ class FormBuilderFilePicker
this.compressionQuality = 0,
this.customFileViewerBuilder,
this.customTypeViewerBuilder,
this.onDefaultViewerItemTap,
}) : super(
builder: (FormFieldState<List<PlatformFile>?> field) {
final state = field as _FormBuilderFilePickerState;
Expand Down Expand Up @@ -143,6 +150,7 @@ class FormBuilderFilePicker
: state.defaultFileViewer(
state._files,
(files) => state._setFiles(files ?? [], field),
onDefaultViewerItemTap,
),
],
),
Expand Down Expand Up @@ -238,6 +246,7 @@ class _FormBuilderFilePickerState
Widget defaultFileViewer(
List<PlatformFile> files,
FormFieldSetter<List<PlatformFile>> setter,
OnDefaultFileViewerBuilderItemTap? onItemTap,
) {
final theme = Theme.of(context);

Expand All @@ -260,31 +269,38 @@ class _FormBuilderFilePickerState
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
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),
Expand Down
Loading