Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
929fdea
[quick_actions] add localizedSubtitle for iOS
GiacomoPignoni Jun 23, 2024
4bea2bc
test and changelog
GiacomoPignoni Jun 23, 2024
fd8a73a
add deps override
GiacomoPignoni Jun 26, 2024
4cba4da
update ios changelog
GiacomoPignoni Jun 26, 2024
1886a75
update platform interface changelog
GiacomoPignoni Jun 26, 2024
3dd729f
Merge branch 'main' into quick_action/subtitle
sinyu1012 Nov 8, 2024
bf72048
update changelog
sinyu1012 Nov 8, 2024
a0ac67e
revert quick_actions_android changes
sinyu1012 Nov 8, 2024
ce569d9
opt QuickActionsPlugin
sinyu1012 Nov 8, 2024
2bf8256
update notes
sinyu1012 Nov 8, 2024
f644114
update quick_actions_ios example & UITests
sinyu1012 Nov 13, 2024
4b38b32
format quick_actions_ios/messages.g.swift
sinyu1012 Nov 13, 2024
54e0a39
format swift
sinyu1012 Nov 13, 2024
550dfe3
Update packages/quick_actions/quick_actions_android/example/pubspec.yaml
sinyu1012 Nov 15, 2024
977992e
Update packages/quick_actions/quick_actions_android/pubspec.yaml
sinyu1012 Nov 15, 2024
3568750
update quick_actions example code
sinyu1012 Nov 15, 2024
9fca7cf
Merge branch 'main' into quick_action/subtitle
sinyu1012 Nov 22, 2024
ee8dc3f
update dependencies
sinyu1012 Nov 22, 2024
efb9975
format code
sinyu1012 Nov 22, 2024
8782df8
format code
sinyu1012 Nov 22, 2024
52eb23b
update version
sinyu1012 Nov 22, 2024
4783ff8
Merge branch 'main' into quick_action/subtitle
sinyu1012 Dec 10, 2024
8d663b7
Merge branch 'main' into quick_action/subtitle
sinyu1012 Dec 11, 2024
f42fb39
update dependencies
sinyu1012 Dec 11, 2024
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
format quick_actions_ios/messages.g.swift
  • Loading branch information
sinyu1012 committed Nov 13, 2024
commit 4b38b322a1e7617d0d628cad3bb2283c676eef04
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class PigeonError: Error {
var localizedDescription: String {
return
"PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")"
}
}
}

private func wrapResult(_ result: Any?) -> [Any?] {
Expand Down Expand Up @@ -59,7 +59,9 @@ private func wrapError(_ error: Any) -> [Any?] {
}

private func createConnectionError(withChannelName channelName: String) -> PigeonError {
return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "")
return PigeonError(
code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.",
details: "")
}

private func isNullish(_ value: Any?) -> Bool {
Expand Down Expand Up @@ -107,6 +109,7 @@ struct ShortcutItemMessage {
]
}
}

private class messagesPigeonCodecReader: FlutterStandardReader {
override func readValue(ofType type: UInt8) -> Any? {
switch type {
Expand Down Expand Up @@ -155,10 +158,16 @@ protocol IOSQuickActionsApi {
class IOSQuickActionsApiSetup {
static var codec: FlutterStandardMessageCodec { messagesPigeonCodec.shared }
/// Sets up an instance of `IOSQuickActionsApi` to handle messages through the `binaryMessenger`.
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: IOSQuickActionsApi?, messageChannelSuffix: String = "") {
static func setUp(
binaryMessenger: FlutterBinaryMessenger, api: IOSQuickActionsApi?,
messageChannelSuffix: String = ""
) {
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
/// Sets the dynamic shortcuts for the app.
let setShortcutItemsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.setShortcutItems\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
let setShortcutItemsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.setShortcutItems\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
setShortcutItemsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
Expand All @@ -174,7 +183,10 @@ class IOSQuickActionsApiSetup {
setShortcutItemsChannel.setMessageHandler(nil)
}
/// Removes all dynamic shortcuts.
let clearShortcutItemsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.clearShortcutItems\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
let clearShortcutItemsChannel = FlutterBasicMessageChannel(
name:
"dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.clearShortcutItems\(channelSuffix)",
binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
clearShortcutItemsChannel.setMessageHandler { _, reply in
do {
Expand All @@ -189,11 +201,14 @@ class IOSQuickActionsApiSetup {
}
}
}

/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift.
protocol IOSQuickActionsFlutterApiProtocol {
/// Sends a string representing a shortcut from the native platform to the app.
func launchAction(action actionArg: String, completion: @escaping (Result<Void, PigeonError>) -> Void)
func launchAction(
action actionArg: String, completion: @escaping (Result<Void, PigeonError>) -> Void)
}

class IOSQuickActionsFlutterApi: IOSQuickActionsFlutterApiProtocol {
private let binaryMessenger: FlutterBinaryMessenger
private let messageChannelSuffix: String
Expand All @@ -205,9 +220,13 @@ class IOSQuickActionsFlutterApi: IOSQuickActionsFlutterApiProtocol {
return messagesPigeonCodec.shared
}
/// Sends a string representing a shortcut from the native platform to the app.
func launchAction(action actionArg: String, completion: @escaping (Result<Void, PigeonError>) -> Void) {
let channelName: String = "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsFlutterApi.launchAction\(messageChannelSuffix)"
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
func launchAction(
action actionArg: String, completion: @escaping (Result<Void, PigeonError>) -> Void
) {
let channelName: String =
"dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsFlutterApi.launchAction\(messageChannelSuffix)"
let channel = FlutterBasicMessageChannel(
name: channelName, binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([actionArg] as [Any?]) { response in
guard let listResponse = response as? [Any?] else {
completion(.failure(createConnectionError(withChannelName: channelName)))
Expand All @@ -223,4 +242,4 @@ class IOSQuickActionsFlutterApi: IOSQuickActionsFlutterApiProtocol {
}
}
}
}
}