Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[quick_actions_plaform_interface] add localizedSubtitle #8112

Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 1.1.0

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

## 1.0.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class MethodChannelQuickActions extends QuickActionsPlatform {
return <String, String?>{
'type': item.type,
'localizedTitle': item.localizedTitle,
if (item.localizedSubtitle != null)
'localizedSubtitle': item.localizedSubtitle,
'icon': item.icon,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ShortcutItem {
const ShortcutItem({
required this.type,
required this.localizedTitle,
this.localizedSubtitle,
this.icon,
});

Expand All @@ -20,6 +21,11 @@ class ShortcutItem {
/// Localized title of the item.
final String localizedTitle;

/// Localized subtitle of the item.
///
/// May be ignored on platforms that don't support localized subtitles.
final String? localizedSubtitle;

/// Name of native resource (xcassets etc; NOT a Flutter asset) to be
/// displayed as the icon for this item.
final String? icon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/quick_actions
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+quick_actions%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.0.6
version: 1.1.0

environment:
sdk: ^3.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,38 @@ void main() {
quickActions.initialize((String type) {});
quickActions.setShortcutItems(<ShortcutItem>[
const ShortcutItem(
type: 'test', localizedTitle: 'title', icon: 'icon.svg')
type: 'test',
localizedTitle: 'title',
localizedSubtitle: 'subtitle',
icon: 'icon.svg',
)
]);

expect(
log,
<Matcher>[
isMethodCall('getLaunchAction', arguments: null),
isMethodCall('setShortcutItems', arguments: <Map<String, String>>[
<String, String>{
'type': 'test',
'localizedTitle': 'title',
'localizedSubtitle': 'subtitle',
'icon': 'icon.svg',
}
]),
],
);
});

test('passes shortcutItem through channel with null localizedSubtitle',
() {
quickActions.initialize((String type) {});
quickActions.setShortcutItems(<ShortcutItem>[
const ShortcutItem(
type: 'test',
localizedTitle: 'title',
icon: 'icon.svg',
)
]);

expect(
Expand All @@ -82,10 +113,15 @@ void main() {
test('setShortcutItems with demo data', () async {
const String type = 'type';
const String localizedTitle = 'localizedTitle';
const String localizedSubtitle = 'localizedSubtitle';
const String icon = 'icon';
await quickActions.setShortcutItems(
const <ShortcutItem>[
ShortcutItem(type: type, localizedTitle: localizedTitle, icon: icon)
ShortcutItem(
type: type,
localizedTitle: localizedTitle,
localizedSubtitle: localizedSubtitle,
icon: icon)
],
);
expect(
Expand All @@ -97,6 +133,7 @@ void main() {
<String, String>{
'type': type,
'localizedTitle': localizedTitle,
'localizedSubtitle': localizedSubtitle,
'icon': icon,
}
],
Expand Down Expand Up @@ -138,13 +175,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