diff --git a/packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md b/packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md index 05f06428ea92..941bed1ba610 100644 --- a/packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md +++ b/packages/quick_actions/quick_actions_platform_interface/CHANGELOG.md @@ -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 diff --git a/packages/quick_actions/quick_actions_platform_interface/lib/method_channel/method_channel_quick_actions.dart b/packages/quick_actions/quick_actions_platform_interface/lib/method_channel/method_channel_quick_actions.dart index 0f936db870c7..2d5b6874344b 100644 --- a/packages/quick_actions/quick_actions_platform_interface/lib/method_channel/method_channel_quick_actions.dart +++ b/packages/quick_actions/quick_actions_platform_interface/lib/method_channel/method_channel_quick_actions.dart @@ -45,6 +45,8 @@ class MethodChannelQuickActions extends QuickActionsPlatform { return { 'type': item.type, 'localizedTitle': item.localizedTitle, + if (item.localizedSubtitle != null) + 'localizedSubtitle': item.localizedSubtitle, 'icon': item.icon, }; } diff --git a/packages/quick_actions/quick_actions_platform_interface/lib/types/shortcut_item.dart b/packages/quick_actions/quick_actions_platform_interface/lib/types/shortcut_item.dart index 1d84e16ac996..81679ddb6c93 100644 --- a/packages/quick_actions/quick_actions_platform_interface/lib/types/shortcut_item.dart +++ b/packages/quick_actions/quick_actions_platform_interface/lib/types/shortcut_item.dart @@ -11,6 +11,7 @@ class ShortcutItem { const ShortcutItem({ required this.type, required this.localizedTitle, + this.localizedSubtitle, this.icon, }); @@ -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; diff --git a/packages/quick_actions/quick_actions_platform_interface/pubspec.yaml b/packages/quick_actions/quick_actions_platform_interface/pubspec.yaml index c9c05c64702f..11ff5823bba1 100644 --- a/packages/quick_actions/quick_actions_platform_interface/pubspec.yaml +++ b/packages/quick_actions/quick_actions_platform_interface/pubspec.yaml @@ -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 diff --git a/packages/quick_actions/quick_actions_platform_interface/test/method_channel_quick_actions_test.dart b/packages/quick_actions/quick_actions_platform_interface/test/method_channel_quick_actions_test.dart index 41e2ed4e7244..0005fda52285 100644 --- a/packages/quick_actions/quick_actions_platform_interface/test/method_channel_quick_actions_test.dart +++ b/packages/quick_actions/quick_actions_platform_interface/test/method_channel_quick_actions_test.dart @@ -61,7 +61,38 @@ void main() { quickActions.initialize((String type) {}); quickActions.setShortcutItems([ const ShortcutItem( - type: 'test', localizedTitle: 'title', icon: 'icon.svg') + type: 'test', + localizedTitle: 'title', + localizedSubtitle: 'subtitle', + icon: 'icon.svg', + ) + ]); + + expect( + log, + [ + isMethodCall('getLaunchAction', arguments: null), + isMethodCall('setShortcutItems', arguments: >[ + { + 'type': 'test', + 'localizedTitle': 'title', + 'localizedSubtitle': 'subtitle', + 'icon': 'icon.svg', + } + ]), + ], + ); + }); + + test('passes shortcutItem through channel with null localizedSubtitle', + () { + quickActions.initialize((String type) {}); + quickActions.setShortcutItems([ + const ShortcutItem( + type: 'test', + localizedTitle: 'title', + icon: 'icon.svg', + ) ]); expect( @@ -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(type: type, localizedTitle: localizedTitle, icon: icon) + ShortcutItem( + type: type, + localizedTitle: localizedTitle, + localizedSubtitle: localizedSubtitle, + icon: icon) ], ); expect( @@ -97,6 +133,7 @@ void main() { { 'type': type, 'localizedTitle': localizedTitle, + 'localizedSubtitle': localizedSubtitle, 'icon': icon, } ], @@ -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); }); });