Skip to content

Commit

Permalink
[iOS][Sample App]Updated custom image renderer to handle toggle visib…
Browse files Browse the repository at this point in the history
…ility (#3514)

* [iOS][Sample App]Updated custom image renderer to handle toggle visiblity

* toggle visibilty delegate will call action delegate to notify view frame
changes
  • Loading branch information
jwoo-msft authored and paulcam206 committed Nov 4, 2019
1 parent dc5c4c5 commit 984c5c7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import <AdaptiveCards/ACRUIImageView.h>
#import <AdaptiveCards/Image.h>
#import <AdaptiveCards/ACRLongPressGestureRecognizerFactory.h>
#import <AdaptiveCards/UtiliOS.h>

@implementation CustomImageRenderer

Expand Down Expand Up @@ -170,6 +171,8 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
hostConfig:acoConfig];
view.translatesAutoresizingMaskIntoConstraints = NO;
wrappingview.translatesAutoresizingMaskIntoConstraints = NO;
configVisibility(wrappingview, elem);

return wrappingview;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ - (void)didFetchUserResponses:(ACOAdaptiveCard *)card action:(ACOBaseActionEleme
newType.alertController = alertController;
[self presentViewController:alertController animated:YES completion:nil];
}
} else if (action.type == ACRToggleVisibility) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Toggle Visibilty" message:nil preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ @implementation ACRToggleVisibilityTarget
{
ACOHostConfig *_config;
__weak ACRView *_rootView;
std::unique_ptr<ToggleVisibilityAction> _action;
std::shared_ptr<ToggleVisibilityAction> _action;
}

- (instancetype)initWithActionElement:(std::shared_ptr<AdaptiveCards::ToggleVisibilityAction> const &)actionElement
Expand All @@ -29,7 +29,7 @@ - (instancetype)initWithActionElement:(std::shared_ptr<AdaptiveCards::ToggleVisi
{
_config = config;
_rootView = rootView;
_action = std::make_unique<ToggleVisibilityAction>(*(actionElement.get()));
_action = std::make_shared<ToggleVisibilityAction>(*(actionElement.get()));
}
return self;
}
Expand Down Expand Up @@ -64,6 +64,8 @@ - (void)doSelectAction
}
}
}

[_rootView.acrActionDelegate didFetchUserResponses:[_rootView card] action:[[ACOBaseActionElement alloc] initWithBaseActionElement:_action]];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

using namespace AdaptiveCards;

// configures tag and initial visibility of the given view. Toggle visibility action
// will access the view by the tag to change the visibility.
void configVisibility(UIView *view, std::shared_ptr<BaseCardElement> const &visibilityInfo);

void configSeparatorVisibility(ACRSeparator *view,
Expand Down

0 comments on commit 984c5c7

Please sign in to comment.