Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions packages/quick_actions/quick_actions_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.0

* Adds support for iOS SF symbols icons for quick actions.

## 1.2.4

* Adds support for UIScene lifecycle.
Expand Down
5 changes: 5 additions & 0 deletions packages/quick_actions/quick_actions_ios/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ dev_dependencies:

flutter:
uses-material-design: true
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
quick_actions_ios: {path: ../../../../packages/quick_actions/quick_actions_ios}
quick_actions_platform_interface: {path: ../../../../packages/quick_actions/quick_actions_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ public final class QuickActionsPlugin: NSObject, FlutterPlugin, IOSQuickActionsA
)
-> UIApplicationShortcutItem?
{
var icon: UIApplicationShortcutIcon? = nil

let icon = (shortcut.icon).map {
UIApplicationShortcutIcon(templateImageName: $0)
if let systemImageName = shortcut.iosSystemIcon {
icon = UIApplicationShortcutIcon(systemImageName: systemImageName)
} else if let templateImageName = shortcut.icon {
icon = UIApplicationShortcutIcon(templateImageName: templateImageName)
}

// type and localizedTitle are required.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.0), do not edit directly.
// Autogenerated from Pigeon (v26.3.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon

import Foundation
Expand Down Expand Up @@ -53,7 +53,7 @@ private func wrapError(_ error: Any) -> [Any?] {
}
return [
"\(error)",
"\(type(of: error))",
"\(Swift.type(of: error))",
"Stacktrace: \(Thread.callStackSymbols)",
]
}
Expand All @@ -73,6 +73,19 @@ private func nilOrValue<T>(_ value: Any?) -> T? {
return value as! T?
}

private func doubleEqualsmessages(_ lhs: Double, _ rhs: Double) -> Bool {
return (lhs.isNaN && rhs.isNaN) || lhs == rhs
}

private func doubleHashmessages(_ value: Double, _ hasher: inout Hasher) {
if value.isNaN {
hasher.combine(0x7FF8_0000_0000_0000)
} else {
// Normalize -0.0 to 0.0
hasher.combine(value == 0 ? 0 : value)
}
}

func deepEqualsmessages(_ lhs: Any?, _ rhs: Any?) -> Bool {
let cleanLhs = nilOrValue(lhs) as Any?
let cleanRhs = nilOrValue(rhs) as Any?
Expand All @@ -83,56 +96,90 @@ func deepEqualsmessages(_ lhs: Any?, _ rhs: Any?) -> Bool {
case (nil, _), (_, nil):
return false

case is (Void, Void):
case (let lhs as AnyObject, let rhs as AnyObject) where lhs === rhs:
return true

case let (cleanLhsHashable, cleanRhsHashable) as (AnyHashable, AnyHashable):
return cleanLhsHashable == cleanRhsHashable
case is (Void, Void):
return true

case let (cleanLhsArray, cleanRhsArray) as ([Any?], [Any?]):
guard cleanLhsArray.count == cleanRhsArray.count else { return false }
for (index, element) in cleanLhsArray.enumerated() {
if !deepEqualsmessages(element, cleanRhsArray[index]) {
case (let lhsArray, let rhsArray) as ([Any?], [Any?]):
guard lhsArray.count == rhsArray.count else { return false }
for (index, element) in lhsArray.enumerated() {
if !deepEqualsmessages(element, rhsArray[index]) {
return false
}
}
return true

case let (cleanLhsDictionary, cleanRhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]):
guard cleanLhsDictionary.count == cleanRhsDictionary.count else { return false }
for (key, cleanLhsValue) in cleanLhsDictionary {
guard cleanRhsDictionary.index(forKey: key) != nil else { return false }
if !deepEqualsmessages(cleanLhsValue, cleanRhsDictionary[key]!) {
case (let lhsArray, let rhsArray) as ([Double], [Double]):
guard lhsArray.count == rhsArray.count else { return false }
for (index, element) in lhsArray.enumerated() {
if !doubleEqualsmessages(element, rhsArray[index]) {
return false
}
}
return true

case (let lhsDictionary, let rhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]):
guard lhsDictionary.count == rhsDictionary.count else { return false }
for (lhsKey, lhsValue) in lhsDictionary {
var found = false
for (rhsKey, rhsValue) in rhsDictionary {
if deepEqualsmessages(lhsKey, rhsKey) {
if deepEqualsmessages(lhsValue, rhsValue) {
found = true
break
} else {
return false
}
}
}
if !found { return false }
}
return true

case (let lhs as Double, let rhs as Double):
return doubleEqualsmessages(lhs, rhs)

case (let lhsHashable, let rhsHashable) as (AnyHashable, AnyHashable):
return lhsHashable == rhsHashable

default:
// Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue.
return false
}
}

func deepHashmessages(value: Any?, hasher: inout Hasher) {
if let valueList = value as? [AnyHashable] {
for item in valueList { deepHashmessages(value: item, hasher: &hasher) }
return
}

if let valueDict = value as? [AnyHashable: AnyHashable] {
for key in valueDict.keys {
hasher.combine(key)
deepHashmessages(value: valueDict[key]!, hasher: &hasher)
let cleanValue = nilOrValue(value) as Any?
if let cleanValue = cleanValue {
if let doubleValue = cleanValue as? Double {
doubleHashmessages(doubleValue, &hasher)
} else if let valueList = cleanValue as? [Any?] {
for item in valueList {
deepHashmessages(value: item, hasher: &hasher)
}
} else if let valueList = cleanValue as? [Double] {
for item in valueList {
doubleHashmessages(item, &hasher)
}
} else if let valueDict = cleanValue as? [AnyHashable: Any?] {
var result = 0
for (key, value) in valueDict {
var entryKeyHasher = Hasher()
deepHashmessages(value: key, hasher: &entryKeyHasher)
var entryValueHasher = Hasher()
deepHashmessages(value: value, hasher: &entryValueHasher)
result = result &+ ((entryKeyHasher.finalize() &* 31) ^ entryValueHasher.finalize())
}
hasher.combine(result)
} else if let hashableValue = cleanValue as? AnyHashable {
hasher.combine(hashableValue)
} else {
hasher.combine(String(describing: cleanValue))
}
return
}

if let hashableValue = value as? AnyHashable {
hasher.combine(hashableValue.hashValue)
} else {
hasher.combine(0)
}

return hasher.combine(String(describing: value))
}

/// Home screen quick-action shortcut item.
Expand All @@ -147,19 +194,23 @@ struct ShortcutItemMessage: Hashable {
var localizedSubtitle: String? = nil
/// Name of native resource to be displayed as the icon for this item.
var icon: String? = nil
/// The name of the SF Symbol to be displayed as the icon for this item on iOS.
var iosSystemIcon: String? = nil

// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> ShortcutItemMessage? {
let type = pigeonVar_list[0] as! String
let localizedTitle = pigeonVar_list[1] as! String
let localizedSubtitle: String? = nilOrValue(pigeonVar_list[2])
let icon: String? = nilOrValue(pigeonVar_list[3])
let iosSystemIcon: String? = nilOrValue(pigeonVar_list[4])

return ShortcutItemMessage(
type: type,
localizedTitle: localizedTitle,
localizedSubtitle: localizedSubtitle,
icon: icon
icon: icon,
iosSystemIcon: iosSystemIcon
)
}
func toList() -> [Any?] {
Expand All @@ -168,13 +219,27 @@ struct ShortcutItemMessage: Hashable {
localizedTitle,
localizedSubtitle,
icon,
iosSystemIcon,
]
}
static func == (lhs: ShortcutItemMessage, rhs: ShortcutItemMessage) -> Bool {
return deepEqualsmessages(lhs.toList(), rhs.toList())
if Swift.type(of: lhs) != Swift.type(of: rhs) {
return false
}
return deepEqualsmessages(lhs.type, rhs.type)
&& deepEqualsmessages(lhs.localizedTitle, rhs.localizedTitle)
&& deepEqualsmessages(lhs.localizedSubtitle, rhs.localizedSubtitle)
&& deepEqualsmessages(lhs.icon, rhs.icon)
&& deepEqualsmessages(lhs.iosSystemIcon, rhs.iosSystemIcon)
}

func hash(into hasher: inout Hasher) {
deepHashmessages(value: toList(), hasher: &hasher)
hasher.combine("ShortcutItemMessage")
deepHashmessages(value: type, hasher: &hasher)
deepHashmessages(value: localizedTitle, hasher: &hasher)
deepHashmessages(value: localizedSubtitle, hasher: &hasher)
deepHashmessages(value: icon, hasher: &hasher)
deepHashmessages(value: iosSystemIcon, hasher: &hasher)
}
}

Expand Down
Loading