-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[file_selector] Migrate to UIScene #10429
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: main
Are you sure you want to change the base?
Conversation
Switches from the global window's view controller to the view controller provided by the new FlutterPluginRegistrar `viewController` method. Updates minimum Flutter version to 3.38 for the new API used. Fixes flutter/flutter#174419
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.
Code Review
This pull request successfully migrates the file_selector_ios plugin to be compatible with UIScene by using the viewController from FlutterPluginRegistrar instead of relying on the application's key window. The implementation uses dependency injection by introducing a ViewPresenterProvider protocol, which improves testability and modernizes the codebase. The related tests and SDK version constraints have been updated accordingly. The changes are well-implemented, but I have a few minor suggestions to improve code style and documentation consistency.
...r/file_selector_ios/ios/file_selector_ios/Sources/file_selector_ios/FileSelectorPlugin.swift
Show resolved
Hide resolved
...lector/file_selector_ios/ios/file_selector_ios/Sources/file_selector_ios/ViewPresenter.swift
Outdated
Show resolved
Hide resolved
...lector/file_selector_ios/ios/file_selector_ios/Sources/file_selector_ios/ViewPresenter.swift
Outdated
Show resolved
Hide resolved
| documentPicker.delegate = completionBridge | ||
|
|
||
| let presenter = | ||
| self.viewPresenterOverride ?? UIApplication.shared.delegate?.window??.rootViewController |
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.
We could keep this override structure instead of adding ViewPresenterProvider, but I thought it was cleaner to reduce test branching in production code.
| } | ||
|
|
||
| /// Non-test implementation of ViewControllerProvider that forwards to the plugin registrar. | ||
| class DefaultViewPresenterProvider: ViewPresenterProvider { |
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 is necessary because FlutterPluginRegistrar is a protocol rather than a class, and the Swift "One Weird Trick" to add protocol conformance only works on classes, not protocols, so we can't do a no-code passthrough to the real registrar using something like line 21 above.
|
Ah right, landing any of these changes is going to require publishing a new |
Switches from the global window's view controller to the view controller provided by the new FlutterPluginRegistrar
viewControllermethod.Updates minimum Flutter version to 3.38 for the new API used.
Fixes flutter/flutter#174419
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3