Skip to content

Commit 7618126

Browse files
authored
[quick_actions_plaform_interface] add localizedSubtitle (flutter#8112)
This is prequel PR for: flutter#8038 Containing only changes to quick_action_platform_interface package. Add the localizedSubtitle field on quick actions for iOS flutter/flutter#129759
1 parent fb8a5e1 commit 7618126

5 files changed

Lines changed: 58 additions & 6 deletions

File tree

packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 1.1.0
22

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

56
## 1.0.6

packages/quick_actions/quick_actions_platform_interface/lib/method_channel/method_channel_quick_actions.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class MethodChannelQuickActions extends QuickActionsPlatform {
4545
return <String, String?>{
4646
'type': item.type,
4747
'localizedTitle': item.localizedTitle,
48+
if (item.localizedSubtitle != null)
49+
'localizedSubtitle': item.localizedSubtitle,
4850
'icon': item.icon,
4951
};
5052
}

packages/quick_actions/quick_actions_platform_interface/lib/types/shortcut_item.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ShortcutItem {
1111
const ShortcutItem({
1212
required this.type,
1313
required this.localizedTitle,
14+
this.localizedSubtitle,
1415
this.icon,
1516
});
1617

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

24+
/// Localized subtitle of the item.
25+
///
26+
/// May be ignored on platforms that don't support localized subtitles.
27+
final String? localizedSubtitle;
28+
2329
/// Name of native resource (xcassets etc; NOT a Flutter asset) to be
2430
/// displayed as the icon for this item.
2531
final String? icon;

packages/quick_actions/quick_actions_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/quick_actions
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+quick_actions%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 1.0.6
7+
version: 1.1.0
88

99
environment:
1010
sdk: ^3.3.0

packages/quick_actions/quick_actions_platform_interface/test/method_channel_quick_actions_test.dart

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,38 @@ void main() {
6161
quickActions.initialize((String type) {});
6262
quickActions.setShortcutItems(<ShortcutItem>[
6363
const ShortcutItem(
64-
type: 'test', localizedTitle: 'title', icon: 'icon.svg')
64+
type: 'test',
65+
localizedTitle: 'title',
66+
localizedSubtitle: 'subtitle',
67+
icon: 'icon.svg',
68+
)
69+
]);
70+
71+
expect(
72+
log,
73+
<Matcher>[
74+
isMethodCall('getLaunchAction', arguments: null),
75+
isMethodCall('setShortcutItems', arguments: <Map<String, String>>[
76+
<String, String>{
77+
'type': 'test',
78+
'localizedTitle': 'title',
79+
'localizedSubtitle': 'subtitle',
80+
'icon': 'icon.svg',
81+
}
82+
]),
83+
],
84+
);
85+
});
86+
87+
test('passes shortcutItem through channel with null localizedSubtitle',
88+
() {
89+
quickActions.initialize((String type) {});
90+
quickActions.setShortcutItems(<ShortcutItem>[
91+
const ShortcutItem(
92+
type: 'test',
93+
localizedTitle: 'title',
94+
icon: 'icon.svg',
95+
)
6596
]);
6697

6798
expect(
@@ -82,10 +113,15 @@ void main() {
82113
test('setShortcutItems with demo data', () async {
83114
const String type = 'type';
84115
const String localizedTitle = 'localizedTitle';
116+
const String localizedSubtitle = 'localizedSubtitle';
85117
const String icon = 'icon';
86118
await quickActions.setShortcutItems(
87119
const <ShortcutItem>[
88-
ShortcutItem(type: type, localizedTitle: localizedTitle, icon: icon)
120+
ShortcutItem(
121+
type: type,
122+
localizedTitle: localizedTitle,
123+
localizedSubtitle: localizedSubtitle,
124+
icon: icon)
89125
],
90126
);
91127
expect(
@@ -97,6 +133,7 @@ void main() {
97133
<String, String>{
98134
'type': type,
99135
'localizedTitle': localizedTitle,
136+
'localizedSubtitle': localizedSubtitle,
100137
'icon': icon,
101138
}
102139
],
@@ -138,13 +175,19 @@ void main() {
138175
test('Shortcut item can be constructed', () {
139176
const String type = 'type';
140177
const String localizedTitle = 'title';
178+
const String localizedSubtitle = 'subtitle';
141179
const String icon = 'foo';
142180

143-
const ShortcutItem item =
144-
ShortcutItem(type: type, localizedTitle: localizedTitle, icon: icon);
181+
const ShortcutItem item = ShortcutItem(
182+
type: type,
183+
localizedTitle: localizedTitle,
184+
localizedSubtitle: localizedSubtitle,
185+
icon: icon,
186+
);
145187

146188
expect(item.type, type);
147189
expect(item.localizedTitle, localizedTitle);
190+
expect(item.localizedSubtitle, localizedSubtitle);
148191
expect(item.icon, icon);
149192
});
150193
});

0 commit comments

Comments
 (0)