Skip to content
Merged
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
3 changes: 2 additions & 1 deletion packages/quick_actions/quick_actions_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 1.2.0

* Adds localizedSubtitle field for iOS quick actions.
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.

## 1.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class RunnerUITests: XCTestCase {
}

findAndTapQuickActionButton(
buttonName: "Action one", quickActionsAppIcon: quickActionsAppIcon, springboard: springboard)
buttonName: "Action one, Action one subtitle", quickActionsAppIcon: quickActionsAppIcon,
springboard: springboard)

let actionOneConfirmation = exampleApp.otherElements["action_one"]
if !actionOneConfirmation.waitForExistence(timeout: elementWaitingTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _MyHomePageState extends State<MyHomePage> {
const ShortcutItem(
type: 'action_one',
localizedTitle: 'Action one',
localizedSubtitle: 'Action one subtitle',
icon: 'AppIcon',
),
const ShortcutItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,15 @@ public final class QuickActionsPlugin: NSObject, FlutterPlugin, IOSQuickActionsA
-> UIApplicationShortcutItem?
{

let type = shortcut.type
let localizedTitle = shortcut.localizedTitle

let icon = (shortcut.icon).map {
UIApplicationShortcutIcon(templateImageName: $0)
}

// type and localizedTitle are required.
return UIApplicationShortcutItem(
type: type,
localizedTitle: localizedTitle,
localizedSubtitle: nil,
type: shortcut.type,
localizedTitle: shortcut.localizedTitle,
localizedSubtitle: shortcut.localizedSubtitle,
icon: icon,
userInfo: nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,35 @@ struct ShortcutItemMessage {
var type: String
/// Localized title of the item.
var localizedTitle: String
/// Localized subtitle of the item.
var localizedSubtitle: String? = nil
/// Name of native resource to be displayed as the icon for this item.
var icon: String? = nil

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

return ShortcutItemMessage(
type: type,
localizedTitle: localizedTitle,
localizedSubtitle: localizedSubtitle,
icon: icon
)
}
func toList() -> [Any?] {
return [
type,
localizedTitle,
localizedSubtitle,
icon,
]
}
}

private class messagesPigeonCodecReader: FlutterStandardReader {
override func readValue(ofType type: UInt8) -> Any? {
switch type {
Expand Down Expand Up @@ -195,12 +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)
}

class IOSQuickActionsFlutterApi: IOSQuickActionsFlutterApiProtocol {
private let binaryMessenger: FlutterBinaryMessenger
private let messageChannelSuffix: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ShortcutItemMessage {
ShortcutItemMessage({
required this.type,
required this.localizedTitle,
this.localizedSubtitle,
this.icon,
});

Expand All @@ -43,13 +44,17 @@ class ShortcutItemMessage {
/// Localized title of the item.
String localizedTitle;

/// Localized subtitle of the item.
String? localizedSubtitle;

/// Name of native resource to be displayed as the icon for this item.
String? icon;

Object encode() {
return <Object?>[
type,
localizedTitle,
localizedSubtitle,
icon,
];
}
Expand All @@ -59,7 +64,8 @@ class ShortcutItemMessage {
return ShortcutItemMessage(
type: result[0]! as String,
localizedTitle: result[1]! as String,
icon: result[2] as String?,
localizedSubtitle: result[2] as String?,
icon: result[3] as String?,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class QuickActionsIos extends QuickActionsPlatform {
return ShortcutItemMessage(
type: item.type,
localizedTitle: item.localizedTitle,
localizedSubtitle: item.localizedSubtitle,
icon: item.icon,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ShortcutItemMessage {
ShortcutItemMessage(
this.type,
this.localizedTitle,
this.localizedSubtitle,
this.icon,
);

Expand All @@ -24,6 +25,9 @@ class ShortcutItemMessage {
/// Localized title of the item.
String localizedTitle;

/// Localized subtitle of the item.
String? localizedSubtitle;

/// Name of native resource to be displayed as the icon for this item.
String? icon;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/quick_actions/quick_actions_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: quick_actions_ios
description: An implementation for the iOS platform of the Flutter `quick_actions` plugin.
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 1.1.1
version: 1.2.0

environment:
sdk: ^3.3.0
Expand All @@ -19,7 +19,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
quick_actions_platform_interface: ^1.0.0
quick_actions_platform_interface: ^1.1.0

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,28 @@ void main() {

test('setShortcutItems', () async {
await quickActions.initialize((String type) {});
const ShortcutItem item =
ShortcutItem(type: 'test', localizedTitle: 'title', icon: 'icon.svg');
const ShortcutItem item = ShortcutItem(
type: 'test',
localizedTitle: 'title',
localizedSubtitle: 'subtitle',
icon: 'icon.svg',
);
await quickActions.setShortcutItems(<ShortcutItem>[item]);

expect(api.items.first.type, item.type);
expect(api.items.first.localizedTitle, item.localizedTitle);
expect(api.items.first.localizedSubtitle, item.localizedSubtitle);
expect(api.items.first.icon, item.icon);
});

test('clearShortCutItems', () {
quickActions.initialize((String type) {});
const ShortcutItem item =
ShortcutItem(type: 'test', localizedTitle: 'title', icon: 'icon.svg');
const ShortcutItem item = ShortcutItem(
type: 'test',
localizedTitle: 'title',
localizedSubtitle: 'subtitle',
icon: 'icon.svg',
);
quickActions.setShortcutItems(<ShortcutItem>[item]);
quickActions.clearShortcutItems();

Expand All @@ -48,13 +57,19 @@ void main() {
test('Shortcut item can be constructed', () {
const String type = 'type';
const String localizedTitle = 'title';
const String localizedSubtitle = 'subtitle';
const String icon = 'foo';

const ShortcutItem item =
ShortcutItem(type: type, localizedTitle: localizedTitle, icon: icon);
const ShortcutItem item = ShortcutItem(
type: type,
localizedTitle: localizedTitle,
localizedSubtitle: localizedSubtitle,
icon: icon,
);

expect(item.type, type);
expect(item.localizedTitle, localizedTitle);
expect(item.localizedSubtitle, localizedSubtitle);
expect(item.icon, icon);
});
}
Expand Down Expand Up @@ -83,6 +98,7 @@ ShortcutItem shortcutItemMessageToShortcutItem(ShortcutItemMessage item) {
return ShortcutItem(
type: item.type,
localizedTitle: item.localizedTitle,
localizedSubtitle: item.localizedSubtitle,
icon: item.icon,
);
}
Loading