Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[file_selector] Basic iOS implementation #5448

Merged
merged 22 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6e7f572
Basic iOS implementation
spesholized Apr 27, 2022
b4e8697
Merge branch 'flutter:main' into main
spesholized Apr 28, 2022
75a1bdc
[file_selector] Basic iOS implementation
spesholized Apr 27, 2022
15f2741
Merge branch 'main' of https://github.com/spesholized/plugins
spesholized Apr 28, 2022
62c60cb
Fix formatting and update environment sdk version
spesholized Apr 28, 2022
696cb78
Basic native unit test for plugin
spesholized Apr 29, 2022
11504f4
Update packages/file_selector/file_selector_ios/example/ios/Runner.xc…
spesholized May 2, 2022
252e110
Add placeholder integration test
spesholized May 3, 2022
cb76a80
Remove unused overrides in file_selector_ios.dart, update pubspec
spesholized May 25, 2022
ecfad9a
Use pigeon, fix Obj-C prefix typo
spesholized May 26, 2022
4ecda0e
Add native unit tests
spesholized May 27, 2022
2a69911
Update tests to use pigeon, change prefix to FFS, update wildcard typ…
spesholized Aug 2, 2022
38742a3
Use non-null properties in messages.dart, use objc associated for the…
spesholized Aug 2, 2022
ec291b6
Merge branch 'main' into file_selector_ios
stuartmorgan-g Aug 19, 2022
f0bbcf1
Remove local analysis options
stuartmorgan-g Aug 19, 2022
edc2881
Resync examples and tweak UTIs
stuartmorgan-g Aug 19, 2022
e521edc
Analysis fixes
stuartmorgan-g Aug 19, 2022
eabcce5
Autoformat
stuartmorgan-g Aug 19, 2022
d39d953
Missing copyright header
stuartmorgan-g Aug 19, 2022
170c260
Supress deprecation warning on legacy codepath
stuartmorgan-g Aug 19, 2022
129a097
Review comments
stuartmorgan-g Aug 21, 2022
0cfa61c
Format
stuartmorgan-g Aug 22, 2022
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 packages/file_selector/file_selector_ios/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#
# Name/Organization <email address>

Google Inc.
Google Inc.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)testPickerPresents {

- (void)testReturnsPickedFiles {
FFSFileSelectorPlugin *plugin = [[FFSFileSelectorPlugin alloc] init];
XCTestExpectation *completionWasCalled = [[XCTestExpectation alloc] init];
XCTestExpectation *completionWasCalled = [self expectationWithDescription:@"completion"];
UIDocumentPickerViewController *picker =
[[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[]
inMode:UIDocumentPickerModeImport];
Expand All @@ -52,13 +52,13 @@ - (void)testReturnsPickedFiles {
didPickDocumentsAtURLs:@[
[NSURL URLWithString:@"file:///file1.txt"], [NSURL URLWithString:@"file:///file2.txt"]
]];
[self waitForExpectations:@[ completionWasCalled ] timeout:1.0];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
}

- (void)testReturnsPickedFileLegacy {
// Tests that it handles the pre iOS 11 UIDocumentPickerDelegate method.
FFSFileSelectorPlugin *plugin = [[FFSFileSelectorPlugin alloc] init];
XCTestExpectation *completionWasCalled = [[XCTestExpectation alloc] init];
XCTestExpectation *completionWasCalled = [self expectationWithDescription:@"completion"];
UIDocumentPickerViewController *picker =
[[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[]
inMode:UIDocumentPickerModeImport];
Expand All @@ -74,7 +74,7 @@ - (void)testReturnsPickedFileLegacy {
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
[plugin documentPicker:picker didPickDocumentAtURL:[NSURL URLWithString:@"file:///file1.txt"]];
#pragma GCC diagnostic pop
[self waitForExpectations:@[ completionWasCalled ] timeout:1.0];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
}

- (void)testCancellingPickerReturnsNil {
Expand All @@ -84,15 +84,15 @@ - (void)testCancellingPickerReturnsNil {
inMode:UIDocumentPickerModeImport];
plugin.documentPickerViewControllerOverride = picker;

XCTestExpectation *completionWasCalled = [[XCTestExpectation alloc] init];
XCTestExpectation *completionWasCalled = [self expectationWithDescription:@"completion"];
[plugin openFileSelectorWithConfig:[FFSFileSelectorConfig makeWithUtis:@[]
allowMultiSelection:@NO]
completion:^(NSArray<NSString *> *paths, FlutterError *error) {
XCTAssertEqual(paths.count, 0);
[completionWasCalled fulfill];
}];
[plugin documentPickerWasCancelled:picker];
[self waitForExpectations:@[ completionWasCalled ] timeout:1.0];
[self waitForExpectationsWithTimeout:1.0 handler:nil];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ - (void)documentPicker:(UIDocumentPickerViewController *)controller
- (void)documentPicker:(UIDocumentPickerViewController *)controller
didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
NSMutableArray *paths = [NSMutableArray arrayWithCapacity:urls.count];
[urls enumerateObjectsUsingBlock:^(NSURL *url, NSUInteger idx, BOOL *stop) {
for (NSURL *url in urls) {
[paths addObject:url.path];
}];
};
[self sendBackResults:paths error:nil forPicker:controller];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// found in the LICENSE file.

#import <Foundation/Foundation.h>
#import <file_selector_ios/FFSFileSelectorPlugin.h>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatter didn't like this:

These files are not formatted correctly (see diff below):
  file_selector/file_selector_ios/ios/Classes/file_selector_ios-umbrella.h

To fix run "pub global activate flutter_plugin_tools && pub global run flutter_plugin_tools format" or copy-paste this command into your terminal:
patch -p1 <<DONE
diff --git a/packages/file_selector/file_selector_ios/ios/Classes/file_selector_ios-umbrella.h b/packages/file_selector/file_selector_ios/ios/Classes/file_selector_ios-umbrella.h
index 122724e46..d79d3642b 100644
--- a/packages/file_selector/file_selector_ios/ios/Classes/file_selector_ios-umbrella.h
+++ b/packages/file_selector/file_selector_ios/ios/Classes/file_selector_ios-umbrella.h
@@ -3,5 +3,4 @@
 // found in the LICENSE file.
 
 #import <Foundation/Foundation.h>
-
 #import <file_selector_ios/FFSFileSelectorPlugin.h>

DONE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, clang-format must assume that any framework-style #import should be a single block. Oh well.

#import <file_selector_ios/FFSFileSelectorPlugin.h>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Displays the native iOS document picker.
s.license = { :type => 'BSD', :file => '../LICENSE' }
s.author = { 'Flutter Dev Team' => '[email protected]' }
s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/file_selector/file_selector_ios' }
s.source_files = 'Classes/**/*'
s.source_files = 'Classes/**/*.{h,m}'
s.module_map = 'Classes/FileSelectorPlugin.modulemap'
s.dependency 'Flutter'
s.platform = :ios, '9.0'
Expand Down