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

[iOS] Overflow Actions (onto main branch) #5670

Merged
merged 34 commits into from
Apr 15, 2021
Merged

Conversation

robin-liao
Copy link
Contributor

@robin-liao robin-liao commented Apr 15, 2021

Related Issue

ActionSet overflow flyout (... actions menu) 4715

Description

To introduce a new feature of overflow actions, the implementation follows the spec:

  1. This new feature will bring as part of Schema version 1.5

  2. Introduce a new property field mode to all Action type. Its value can be primary (default) or secondary. For all secondary action instances in the same actions array (either the root level actions section or ActionSet inside card elements) they'll group as overflow actions, wrap up within a "..." button and display flyout context menu when user clicks "..." button.

  3. hostConfig.actions.maxActions doesn't count "..." button itself.

  4. Client callbacks are added to ACRActionDelegate to control overflow button "..." and flyout menu actions rendering:

    • - (BOOL)onRenderOverflowAction:(UIButton *)button forTarget:(ACROverflowTarget *)target isAtRootLevelActions:(BOOL)isAtRootLevelActions;

      • Description: It will be called when “…” overflow button will be rendered.
      • Parameters:
        • button: the current "..." overflow button
        • target: the target to trigger popup menu or current "..." overflow button. Client can access its associated menu item actions through target.menuItems, or add this target to any UIButton to trigger the popup
        • isRootLevelActions: indicates if the current "..." overflow action belongs to root level actions array. If it's NO then it indicates it's in ActionSet as body elements.
      • Return:
        • Client callback requires to return a BOOL. Returning NO means let SDK continue to render "..." button, while returning YES informs SDK don't render the current "..." button.
    • - (BOOL)onDisplayOverflowActionMenu:(NSArray<ACROverflowMenuItem *> *)menuItems alertController:(UIAlertController *)alert;

      • Description: It will be called when overflow context menu will be shown.
      • Parameters:
        • menuItems: the action items on the overflow menu associated with the current triggered overflow "..." button
        • alert: presentable-ready alert controller. Client can just use its view controller to present this. Or client can grab menuItems to prepare its own overflow menu
      • Return:
        • Client callback requires to return aBOOL value. If client returns NO, SDK will continue to present default overflow menu in action sheet, while returning YES informs SDK don't display the popup overflow menu.
    • - (BOOL)shouldAllowMoreThanMaxActionsInOverflowMenu;

      • Client callback requires to return a BOOL value. Returning YES indicates that the actions exceeding the number defined in hostConfig.actions.maxActions will be auto wrapped up as overflow actions and "..." button for context menu will be displayed and NO indicates excess action elements will be left out.

Sample Card

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.5",
  "body": [
    {
      "type": "Image",
      "url": "https://adaptivecards.io/content/adaptive-card-50.png"
    },
    {
      "type": "TextBlock",
      "text": "Overflow Action Test Card!",
      "size": "large",
      "weight": "bolder"
    },
    {
      "type": "TextBlock",
      "text": "ActionSet **all secondary actions**"
    },
    {
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.Submit",
          "title": "Action Submit",
          "data": {
            "key": "Submit from overflow menu"
          },
          "mode": "secondary"
        },
        {
          "type": "Action.OpenUrl",
          "title": "OpenUrl",
          "url": "https://github.com/Microsoft/AdaptiveCards",
          "iconUrl": "https://www.clipartmax.com/png/full/211-2118815_file-novosel-mushroom-svg-mario-mushroom-icon.png",
          "mode": "secondary"
        }
      ]
    },
    {
      "type": "TextBlock",
      "text": "ActionSet **primary + secondary actions**"
    },
    {
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.Submit",
          "title": "Submit",
          "data": {
            "key": "Submit from overflow menu"
          },
          "mode": "Primary"
        },
        {
          "type": "Action.Submit",
          "title": "Edit",
          "data": {
            "key": "Delete from overflow menu"
          },
          "mode": "Secondary"
        },
        {
          "type": "Action.Submit",
          "title": "Delete",
          "data": {
            "key": "Delete"
          },
          "mode": "Secondary"
        }
      ]
    },
    {
      "type": "TextBlock",
      "text": "Check actions.length > maxActions"
    },
    {
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.Submit",
          "title": "Action 1",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 2",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 3",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 4",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 5",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 6",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 7",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 8",
          "mode": "primary"
        },
        {
          "type": "Action.Submit",
          "title": "Action 9",
          "mode": "primary"
        }
      ]
    },
    {
      "type": "TextBlock",
      "text": "========= I am bottom line of body ========="
    }
  ],
  "actions": [
    {
      "type": "Action.OpenUrl",
      "title": "Root - OpenUrl",
      "url": "https://adaptivecards.io"
    },
    {
      "type": "Action.Submit",
      "title": "Root - Submit",
      "data": {
        "key": "Submit from overflow menu"
      },
      "mode": "Secondary"
    },
    {
      "type": "Action.OpenUrl",
      "iconUrl": "https://adaptivecards.io/content/cats/2.png",
      "url": "https://adaptivecards.io",
      "title": "Root - OpenUrl",
      "mode": "Secondary"
    },
    {
      "type": "Action.ShowCard",
      "title": "Root - ShowCard",
      "card": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "text": "What do you think?"
          }
        ],
        "actions": [
          {
            "type": "Action.Submit",
            "title": "Neat!"
          }
        ]
      },
      "mode": "Secondary"
    }
  ]
}

How Verified

Updated ADCIOSVisualizer "ViewController.m" to test the different scenarios.

Overflow Displaying Menu
image image

robin-liao and others added 30 commits March 1, 2021 12:56
* [JS] Overflow actions #4715

* use global setting to control exceeding actions

* address PR comments

* fix PR build

* fix PR build

* fix PR build

* fix pr build

* address PR comments

* address PR comments

Co-authored-by: David Claux <dclaux@users.noreply.github.com>

Ignoring unrelated Android check failures
…ry on execute (#5449)

* Action.mode designer support
Promote secondary action to primary on execute

* Slight change in behavior for action promotion

* Slight refactor
Enum created for "Mode" with  "Primary" & " Secondary"  constants.
"Mode" is parsed  from the json string.
If allowMoreThanMaxActionsInOverflowMenu  is set, excess buttons will be moved to Overflow,
BottomSheetDoalog is Integrated and DropdownElement is created.
Resource files added for Overflow view & BottomSheetDialog's background.
Scheme keys added.
IOverllowActionRenderer interface created for customizing the Overflow rendering behavior.
Method added for custom context menu .
Version 1.5 introduced and sample json files added.
Additional method added to AdaptiveCardRenderer for customizing OverflowActionRenderer.
OnclickListener added to custom overflow view.
- getRootLevelAction(), shouldDisplayCustomActionMenu() methods removed.
Conflicts:
	samples/v1.5/Elements/SecondaryActions.json
shouldDisplayCustomOverflowActionMenu() added to IOverflowActionRenderer.java
rootLevelFlags added to RenderArgs.
Added Java 8 support.
IoverflowActionRenderer Callbacks refactored.
Swig java object models files committed.
PR comments resolved.
@robin-liao robin-liao enabled auto-merge (squash) April 15, 2021 02:58
Comment on lines +221 to +225
button = [actionRenderer renderButton:rootView
inputs:inputs
superview:superview
baseActionElement:acoElem
hostConfig:config];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment here looks a bit off

@robin-liao robin-liao merged commit a2f6ec1 into main Apr 15, 2021
@robin-liao robin-liao deleted the yilia/overflow-menu-ios branch April 15, 2021 18:05
michaelfarnsworth pushed a commit to michaelfarnsworth/AdaptiveCards that referenced this pull request Nov 10, 2022
* [JS] Overflow actions (flyout menu) microsoft#4715 (Pre-Release) (microsoft#5446)

* [JS] Overflow actions microsoft#4715

* use global setting to control exceeding actions

* address PR comments

* fix PR build

* fix PR build

* fix PR build

* fix pr build

* address PR comments

* address PR comments

Co-authored-by: David Claux <dclaux@users.noreply.github.com>

Ignoring unrelated Android check failures

* [JS] Action.mode designer support + promote secondary action to primary on execute (microsoft#5449)

* Action.mode designer support
Promote secondary action to primary on execute

* Slight change in behavior for action promotion

* Slight refactor

* "Mode" property added to AdaptiveCardSchemaKey.
Enum created for "Mode" with  "Primary" & " Secondary"  constants.
"Mode" is parsed  from the json string.

* allowMoreThanMaxActionsInOverflowMenu flag  added to HostConfig.

If allowMoreThanMaxActionsInOverflowMenu  is set, excess buttons will be moved to Overflow,

* OverflowAction view is rendered for secondary action elements.
BottomSheetDoalog is Integrated and DropdownElement is created.
Resource files added for Overflow view & BottomSheetDialog's background.
Scheme keys added.
IOverllowActionRenderer interface created for customizing the Overflow rendering behavior.

* Unit Test "ActionModePropertiesTest.java" added.
Method added for custom context menu .
Version 1.5 introduced and sample json files added.
Additional method added to AdaptiveCardRenderer for customizing OverflowActionRenderer.

* IOverflowLayout onRenderOverflowAction callback refactored.
OnclickListener added to custom overflow view.

* Addressed PR comments. Code formatted.

* Addressed PR comments.

* Addressed review comments.

* rootLevelAction implementation logic is refactored.

* IOverflowActionRenderer callback methods refactored.

- getRootLevelAction(), shouldDisplayCustomActionMenu() methods removed.

* [iOS] [Preview] Overflow Actions

* merge

* SplitActionMode code moved to AdaptiveCardRenderer.
shouldDisplayCustomOverflowActionMenu() added to IOverflowActionRenderer.java
rootLevelFlags added to RenderArgs.

* update

* address PR comments

* revert unncessary change

* clang-format

* clang-format

* PopupWindow is integrated and BottomSheetDialog dependency is removed.
Added Java 8 support.
IoverflowActionRenderer Callbacks refactored.
Swig java object models files committed.
PR comments resolved.

* Swig files committed.

* address PR comments

* update due to merge

* update due to merge

* fix due to merge

* update callback declaration to conform the spec

* minor update

* icon image lazy load

Co-authored-by: David Claux <dclaux@users.noreply.github.com>
Co-authored-by: REDMOND\kargopal <kargopal@microsoft.com>
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
* [JS] Overflow actions (flyout menu) microsoft#4715 (Pre-Release) (microsoft#5446)

* [JS] Overflow actions microsoft#4715

* use global setting to control exceeding actions

* address PR comments

* fix PR build

* fix PR build

* fix PR build

* fix pr build

* address PR comments

* address PR comments

Co-authored-by: David Claux <dclaux@users.noreply.github.com>

Ignoring unrelated Android check failures

* [JS] Action.mode designer support + promote secondary action to primary on execute (microsoft#5449)

* Action.mode designer support
Promote secondary action to primary on execute

* Slight change in behavior for action promotion

* Slight refactor

* "Mode" property added to AdaptiveCardSchemaKey.
Enum created for "Mode" with  "Primary" & " Secondary"  constants.
"Mode" is parsed  from the json string.

* allowMoreThanMaxActionsInOverflowMenu flag  added to HostConfig.

If allowMoreThanMaxActionsInOverflowMenu  is set, excess buttons will be moved to Overflow,

* OverflowAction view is rendered for secondary action elements.
BottomSheetDoalog is Integrated and DropdownElement is created.
Resource files added for Overflow view & BottomSheetDialog's background.
Scheme keys added.
IOverllowActionRenderer interface created for customizing the Overflow rendering behavior.

* Unit Test "ActionModePropertiesTest.java" added.
Method added for custom context menu .
Version 1.5 introduced and sample json files added.
Additional method added to AdaptiveCardRenderer for customizing OverflowActionRenderer.

* IOverflowLayout onRenderOverflowAction callback refactored.
OnclickListener added to custom overflow view.

* Addressed PR comments. Code formatted.

* Addressed PR comments.

* Addressed review comments.

* rootLevelAction implementation logic is refactored.

* IOverflowActionRenderer callback methods refactored.

- getRootLevelAction(), shouldDisplayCustomActionMenu() methods removed.

* [iOS] [Preview] Overflow Actions

* merge

* SplitActionMode code moved to AdaptiveCardRenderer.
shouldDisplayCustomOverflowActionMenu() added to IOverflowActionRenderer.java
rootLevelFlags added to RenderArgs.

* update

* address PR comments

* revert unncessary change

* clang-format

* clang-format

* PopupWindow is integrated and BottomSheetDialog dependency is removed.
Added Java 8 support.
IoverflowActionRenderer Callbacks refactored.
Swig java object models files committed.
PR comments resolved.

* Swig files committed.

* address PR comments

* update due to merge

* update due to merge

* fix due to merge

* update callback declaration to conform the spec

* minor update

* icon image lazy load

Co-authored-by: David Claux <dclaux@users.noreply.github.com>
Co-authored-by: REDMOND\kargopal <kargopal@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants