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

* Adds localizedSubtitle field for iOS quick actions.

## 1.0.8

* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
Expand Down
2 changes: 1 addition & 1 deletion packages/quick_actions/quick_actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Finally, manage the app's quick actions, for instance:
```dart
quickActions.setShortcutItems(<ShortcutItem>[
const ShortcutItem(type: 'action_main', localizedTitle: 'Main view', icon: 'icon_main'),
const ShortcutItem(type: 'action_help', localizedTitle: 'Help', icon: 'icon_help')
const ShortcutItem(type: 'action_help', localizedTitle: 'Help', localizedSubtitle: 'Tap to get help', icon: 'icon_help')
]);
```

Expand Down
8 changes: 5 additions & 3 deletions packages/quick_actions/quick_actions/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ class _MyHomePageState extends State<MyHomePage> {
const ShortcutItem(
type: 'action_one',
localizedTitle: 'Action one',
localizedSubtitle: 'Action one subtitle',
icon: 'AppIcon',
),
// NOTE: This second action icon will only work on Android.
// In a real world project keep the same file name for both platforms.
const ShortcutItem(
type: 'action_two',
localizedTitle: 'Action two',
icon: 'ic_launcher'),
type: 'action_two',
localizedTitle: 'Action two',
icon: 'ic_launcher',
),
]).then((void _) {
setState(() {
if (shortcut == 'no action set') {
Expand Down
4 changes: 2 additions & 2 deletions packages/quick_actions/quick_actions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for creating shortcuts on home screen, also known as
Quick Actions on iOS and App Shortcuts on Android.
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+quick_actions%22
version: 1.0.8
version: 1.0.9

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

dev_dependencies:
flutter_test:
Expand Down
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.1.2

* 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
8 changes: 7 additions & 1 deletion packages/quick_actions/quick_actions_ios/lib/messages.g.dart
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.1.2

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,
);
}