Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1d5609f
converting url_launcher from objc to swift
chrisdlangham Aug 18, 2023
d5727dd
converting tests to swift
chrisdlangham Aug 22, 2023
c4e55fb
converting tests to swift
chrisdlangham Aug 22, 2023
050d6b3
fixing issue where pigeon and method channels were not setup right
chrisdlangham Aug 22, 2023
5278199
formatting
chrisdlangham Aug 22, 2023
55a345b
reverting unintentional local changes
chrisdlangham Aug 22, 2023
8356d7a
fixing issues with Ui tests
chrisdlangham Aug 22, 2023
120b2d4
formating
chrisdlangham Aug 22, 2023
1316f3c
Merge branch 'main' into coverting-objc-to-swift
chrisdlangham Aug 22, 2023
7bd3553
updating version and change log
chrisdlangham Aug 22, 2023
2741de4
converting tests to swift
chrisdlangham Aug 22, 2023
495de26
converting unit tests to swift
chrisdlangham Aug 23, 2023
c898698
Merge branch 'main' into converting-url-launcher-ios-tests-to-swift
chrisdlangham Aug 23, 2023
6a6c8d5
updating change log
chrisdlangham Aug 23, 2023
254b9af
resolving merge conflicts
chrisdlangham Aug 23, 2023
869f18f
formatting
chrisdlangham Aug 23, 2023
1120baa
making test class final and private
chrisdlangham Aug 29, 2023
9f591e3
resolving merge conflicts
chrisdlangham Sep 13, 2023
13cd002
updated tests and formated pigeon file
chrisdlangham Sep 13, 2023
f8f5f0b
updates changelog
chrisdlangham Sep 13, 2023
827204a
Update CHANGELOG.md
chrisdlangham Sep 14, 2023
30568fd
Merge branch 'main' into coverting-objc-to-swift
chrisdlangham Sep 14, 2023
6b5e4cd
uses latest version of pigeon
chrisdlangham Sep 15, 2023
3651a97
updates change log
chrisdlangham Sep 15, 2023
257b7cc
moves setting up the pigeon api to the register function instead of t…
chrisdlangham Sep 15, 2023
3ee9d96
resolving merge conflicts
chrisdlangham Sep 28, 2023
d90702f
Merge branch 'main' into coverting-objc-to-swift
chrisdlangham Oct 7, 2023
7241d20
adds in missing throws keyword
chrisdlangham Oct 7, 2023
9d578f2
addresses feedback
chrisdlangham Oct 7, 2023
657c011
changes pigeon api to not throw errors, and let the dart side throw e…
chrisdlangham Oct 11, 2023
7a2fac5
Merge branch 'main' into coverting-objc-to-swift
chrisdlangham Oct 19, 2023
4d4f1bb
addresses feedback
chrisdlangham Oct 19, 2023
7b6272f
addressing feedback
chrisdlangham Oct 26, 2023
b91dca7
Merge branch 'main' into coverting-objc-to-swift
stuartmorgan-g Oct 26, 2023
e7e011a
Replace default launcher implementation with conformance extension
stuartmorgan-g Oct 26, 2023
d955ef8
swift-format
stuartmorgan-g Oct 26, 2023
1297683
Rework return enum to have different versions
stuartmorgan-g Oct 26, 2023
43966a0
Improve invalid URL testing
stuartmorgan-g Oct 26, 2023
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
Prev Previous commit
Next Next commit
swift-format
  • Loading branch information
stuartmorgan-g committed Oct 26, 2023
commit d955ef8d75ea6151f294e51fc5e57a4cccc4931c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public final class URLLauncherPlugin: NSObject, FlutterPlugin, UrlLauncherApi {
extension UIViewController {
var topViewController: UIViewController {
if let navigationController = self as? UINavigationController {
return navigationController.viewControllers.last?.topViewController ?? navigationController
return navigationController.viewControllers.last?.topViewController
?? navigationController
.visibleViewController ?? navigationController
}
if let tabBarController = self as? UITabBarController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
// See also: https://pub.dev/packages/pigeon

import Foundation

#if os(iOS)
import Flutter
import Flutter
#elseif os(macOS)
import FlutterMacOS
import FlutterMacOS
#else
#error("Unsupported platform.")
#error("Unsupported platform.")
#endif

private func isNullish(_ value: Any?) -> Bool {
Expand All @@ -26,13 +27,13 @@ private func wrapError(_ error: Any) -> [Any?] {
return [
flutterError.code,
flutterError.message,
flutterError.details
flutterError.details,
]
}
return [
"\(error)",
"\(type(of: error))",
"Stacktrace: \(Thread.callStackSymbols)"
"Stacktrace: \(Thread.callStackSymbols)",
]
}

Expand All @@ -56,10 +57,13 @@ protocol UrlLauncherApi {
/// Returns true if the URL can definitely be launched.
func canLaunchUrl(url: String) throws -> LaunchResult
/// Opens the URL externally, returning true if successful.
func launchUrl(url: String, universalLinksOnly: Bool, completion: @escaping (Result<LaunchResult, Error>) -> Void)
func launchUrl(
url: String, universalLinksOnly: Bool,
completion: @escaping (Result<LaunchResult, Error>) -> Void)
/// Opens the URL in an in-app SFSafariViewController, returning true
/// when it has loaded successfully.
func openUrlInSafariViewController(url: String, completion: @escaping (Result<LaunchResult, Error>) -> Void)
func openUrlInSafariViewController(
url: String, completion: @escaping (Result<LaunchResult, Error>) -> Void)
/// Closes the view controller opened by [openUrlInSafariViewController].
func closeSafariViewController() throws
}
Expand All @@ -70,7 +74,9 @@ class UrlLauncherApiSetup {
/// Sets up an instance of `UrlLauncherApi` to handle messages through the `binaryMessenger`.
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: UrlLauncherApi?) {
/// Returns true if the URL can definitely be launched.
let canLaunchUrlChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.canLaunchUrl", binaryMessenger: binaryMessenger)
let canLaunchUrlChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.canLaunchUrl",
binaryMessenger: binaryMessenger)
if let api = api {
canLaunchUrlChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
Expand All @@ -86,18 +92,20 @@ class UrlLauncherApiSetup {
canLaunchUrlChannel.setMessageHandler(nil)
}
/// Opens the URL externally, returning true if successful.
let launchUrlChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.launchUrl", binaryMessenger: binaryMessenger)
let launchUrlChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.launchUrl",
binaryMessenger: binaryMessenger)
if let api = api {
launchUrlChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let urlArg = args[0] as! String
let universalLinksOnlyArg = args[1] as! Bool
api.launchUrl(url: urlArg, universalLinksOnly: universalLinksOnlyArg) { result in
switch result {
case .success(let res):
reply(wrapResult(res.rawValue))
case .failure(let error):
reply(wrapError(error))
case .success(let res):
reply(wrapResult(res.rawValue))
case .failure(let error):
reply(wrapError(error))
}
}
}
Expand All @@ -106,25 +114,29 @@ class UrlLauncherApiSetup {
}
/// Opens the URL in an in-app SFSafariViewController, returning true
/// when it has loaded successfully.
let openUrlInSafariViewControllerChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.openUrlInSafariViewController", binaryMessenger: binaryMessenger)
let openUrlInSafariViewControllerChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.openUrlInSafariViewController",
binaryMessenger: binaryMessenger)
if let api = api {
openUrlInSafariViewControllerChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let urlArg = args[0] as! String
api.openUrlInSafariViewController(url: urlArg) { result in
switch result {
case .success(let res):
reply(wrapResult(res.rawValue))
case .failure(let error):
reply(wrapError(error))
case .success(let res):
reply(wrapResult(res.rawValue))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
openUrlInSafariViewControllerChannel.setMessageHandler(nil)
}
/// Closes the view controller opened by [openUrlInSafariViewController].
let closeSafariViewControllerChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.closeSafariViewController", binaryMessenger: binaryMessenger)
let closeSafariViewControllerChannel = FlutterBasicMessageChannel(
name: "dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.closeSafariViewController",
binaryMessenger: binaryMessenger)
if let api = api {
closeSafariViewControllerChannel.setMessageHandler { _, reply in
do {
Expand Down