-
Notifications
You must be signed in to change notification settings - Fork 847
Implement shared Darwin source code between iOS and macOS #1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…idating shared code for macOS and iOS. Deleted unused utility classes and updated podspec and package files to reflect changes in structure. Enhanced pubspec.yaml to enable sharedDarwinSource for iOS and macOS platforms.
| class FilePickerUtils { | ||
| static func resolveType(_ type: String) -> [String] { | ||
| // Implement mapping from "audio", "image", "video", "any" to UTTypes | ||
| return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it still need an implementation? Or is it unused?
| let package = Package( | ||
| name: "file_picker", | ||
| platforms: [ | ||
| .iOS("14.0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put the change to iOS 14.0 in the changelog?
|
|
||
| public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { | ||
| #if os(iOS) | ||
| self.result = result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like the wrong place to do this? Not all methods resolve the result at a later time, in an escaping way
| case "getDirectoryPath": | ||
| handleDirectorySelection(call, result: result) | ||
| case "pickFileAndDirectoryPaths": | ||
| #if os(macOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like how the "handlers" are just a bunch of if os() checks.
Can we follow the same pattern, where iOS / MacOS delegates to a class, that contains the handler methods?
Maybe we can do one
#if os(macOS)
let delegate = FilePickerMacOS()
#else
let delegate = FilePickerIOS()
#endif
and move the handlers to those methods.
|
|
||
| // MARK: - Common Handlers | ||
|
|
||
| private func handleFileSelection(_ call: FlutterMethodCall, result: @escaping FlutterResult) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vicajilau I don't like how this file now becomes one big file with everything in it.
It makes reviewing it quite the task.
Can you create the /darwin/file_picker/Sources/file_picker folder in a separate PR,
which then also contains FilePickerUtils.swift and FilePickerMacOS.swift / FilePickerIOS.swift ?
Then I'll review those first. Afterwards, this PR will be much easier to review. (since then this PR is actually setting up the usage of the FilePickerPlugin.swift + usage of the delegates)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @navaronbracke, it looks pretty bad. I had the same feeling as I was writing it. I'm going to come up with a new approach and I'll leave this as a draft in case I want to revise anything.
This PR implements
sharedDarwinSourcebetween iOS and macOS platforms, using the macOS implementation as the base for unified code.Changes
sharedDarwinSource: truefor both iOS and macOS platforms inpubspec.yamlPHPickerViewControllerandPHPickerResult)