[file_selector] Convert iOS to Swift and SPM#6755
[file_selector] Convert iOS to Swift and SPM#6755auto-submit[bot] merged 6 commits intoflutter:mainfrom
Conversation
|
This is the easiest way to remove the use of modulemaps, right? 😁 Let me know if you want me to actually break this up into separate PRs. The overall change isn't actually that big so this seemed potentially easier, but I could easily split it along commit lines. |
eb6df7f to
cb91c01
Compare
cb91c01 to
6ce49a3
Compare
jmagman
left a comment
There was a problem hiding this comment.
@hellohuanlin could you review just the files FileSelectorPlugin.swift ViewPresenter.swift for idiomatic Swift?
LGTM
|
|
||
| @testable import file_selector_ios | ||
|
|
||
| class TestViewPresenter: ViewPresenter { |
| sendResult( | ||
| urls.map({ document in | ||
| document.path | ||
| })) |
There was a problem hiding this comment.
nit: sendResult(urls.map { $0.path })
There was a problem hiding this comment.
Ah right, I forgot Swift has shorthand for this.
There was a problem hiding this comment.
can also use key path urls.map(\.path) which is even shorter. sometimes i forget about it (no need to change tho)
| ?? UIDocumentPickerViewController( | ||
| documentTypes: config.utis.map({ uti in | ||
| // See comment in messages.dart for why this is safe. | ||
| uti! |
There was a problem hiding this comment.
can cast directly config.utis as! [TypeOfThis] without the loop
There was a problem hiding this comment.
Interesting, I guess I've internalized the Dart model of having to cast elements rather than the collections themselves.
| documentTypes: config.utis.map({ uti in | ||
| // See comment in messages.dart for why this is safe. | ||
| uti! | ||
| }), in: UIDocumentPickerMode.import) |
There was a problem hiding this comment.
Done. Someday I'll internalize this one.
| documentPicker.delegate = completionBridge | ||
|
|
||
| let presenter = | ||
| self.viewPresenterOverride ?? UIApplication.shared.delegate?.window??.rootViewController |
There was a problem hiding this comment.
is viewPresenterOverride created for testing purpose?
There was a problem hiding this comment.
Yes, both to avoid actually having modal UI pop up (which causes issues when running multiple tests since we can't dismiss it) and to assert that it's called with expected values.
flutter/packages@6525441...1008d9e 2024-05-23 engine-flutter-autoroll@skia.org Roll Flutter from 73bf206 to 8d955cd (24 revisions) (flutter/packages#6786) 2024-05-23 engine-flutter-autoroll@skia.org Roll Flutter (stable) from 5dcb86f to a14f74f (3 revisions) (flutter/packages#6784) 2024-05-23 stuartmorgan@google.com [file_selector] Convert iOS to Swift and SPM (flutter/packages#6755) 2024-05-23 49699333+dependabot[bot]@users.noreply.github.com [webview]: Bump androidx.webkit:webkit from 1.7.0 to 1.10.0 in /packages/webview_flutter/webview_flutter_android/android (flutter/packages#5996) 2024-05-23 engine-flutter-autoroll@skia.org Roll Flutter from d02292d to 73bf206 (31 revisions) (flutter/packages#6780) 2024-05-23 goderbauer@google.com [rfw] Adds support for `DecorationImage.filterQuality`. (flutter/packages#6781) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@6525441...1008d9e 2024-05-23 engine-flutter-autoroll@skia.org Roll Flutter from 73bf206 to 8d955cd (24 revisions) (flutter/packages#6786) 2024-05-23 engine-flutter-autoroll@skia.org Roll Flutter (stable) from 5dcb86f to a14f74f (3 revisions) (flutter/packages#6784) 2024-05-23 stuartmorgan@google.com [file_selector] Convert iOS to Swift and SPM (flutter/packages#6755) 2024-05-23 49699333+dependabot[bot]@users.noreply.github.com [webview]: Bump androidx.webkit:webkit from 1.7.0 to 1.10.0 in /packages/webview_flutter/webview_flutter_android/android (flutter/packages#5996) 2024-05-23 engine-flutter-autoroll@skia.org Roll Flutter from d02292d to 73bf206 (31 revisions) (flutter/packages#6780) 2024-05-23 goderbauer@google.com [rfw] Adds support for `DecorationImage.filterQuality`. (flutter/packages#6781) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Converts the plugin and its tests to Swift, and re-adds the SPM support that was reverted due to modulemap issues.
In order to avoid the ugliness and loss of type saftey of using associated objects in the Swift version, this replaces that with a bridge object that serves as a delegate instead of the plugin, and manages its own lifetime in coordination with the plugin.
While this is one PR, the conversion was done in individual steps, each of which is a commit:
The changes in the generated Dart files are just due to updating to the latest version of Pigeon (to avoid writing the Swift implementation against an older version of the Swift API, and then having to update again later for breaking changes).
Part of flutter/flutter#119015
Fixes flutter/flutter#146903
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).