Skip to content

Commit

Permalink
showcard to call delegate (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoo-msft authored and Gilles Khouzam committed May 21, 2018
1 parent 2bc5d0d commit 7bf87c9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ - (UIButton* )renderButton:(ACRView *)rootView
encoding:NSUTF8StringEncoding];
UIButton *button = [UIButton acr_renderButton:rootView title:title andHostConfig:[acoConfig getHostConfig]];

ACRShowCardTarget *target = [[ACRShowCardTarget alloc] initWithAdaptiveCard:action->GetCard()
config:acoConfig
superview:superview
rootView:rootView];
ACRShowCardTarget *target = [[ACRShowCardTarget alloc] initWithActionElement:action
config:acoConfig
superview:superview
rootView:rootView];
[button addTarget:target action:@selector(toggleVisibilityOfShowCard) forControlEvents:UIControlEventTouchUpInside];

[superview addTarget:target];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ + (UILongPressGestureRecognizer *)getLongPressGestureRecognizer:(UIView<ACRICont
{
std::shared_ptr<ShowCardAction> showCardAction = std::dynamic_pointer_cast<ShowCardAction>(action);
// instantiate a ShowCardTarget
target = [[ACRShowCardTarget alloc] initWithAdaptiveCard:showCardAction->GetCard() config:config superview:viewGroup rootView:rootView];
target = [[ACRShowCardTarget alloc] initWithActionElement:showCardAction config:config superview:viewGroup rootView:rootView];
break;
}
// everything else is not valid request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
#import "SharedAdaptiveCard.h"
#import "ACRLongPressGestureRecognizerEventHandler.h"
#import "ACRView.h"
#import "ShowCardAction.h"

@interface ACRShowCardTarget:NSObject<ACRSelectActionDelegate>

- (instancetype)initWithAdaptiveCard:(std::shared_ptr<AdaptiveCards::AdaptiveCard> const &)adaptiveCard
config:(ACOHostConfig *)config
superview:(UIView<ACRIContentHoldingView> *)superview
rootView:(ACRView *)rootView;
- (instancetype)initWithActionElement:(std::shared_ptr<AdaptiveCards::ShowCardAction> const &)showCardActionElement
config:(ACOHostConfig *)config
superview:(UIView<ACRIContentHoldingView> *)superview
rootView:(ACRView *)rootView;

- (void)createShowCard:(NSMutableArray*)inputs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#import "ACOHostConfigPrivate.h"
#import "ACRContentHoldingUIView.h"
#import "ACRIBaseInputHandler.h"
#import "ACOBaseActionElementPrivate.h"
#import "ACRView.h"
#import "BaseActionElement.h"

@implementation ACRShowCardTarget
{
Expand All @@ -20,21 +22,25 @@ @implementation ACRShowCardTarget
__weak UIView<ACRIContentHoldingView> *_superview;
__weak ACRView *_rootView;
__weak UIView *_adcView;
ACOBaseActionElement *_actionElement;
}

- (instancetype)initWithAdaptiveCard:(std::shared_ptr<AdaptiveCards::AdaptiveCard> const &)adaptiveCard
- (instancetype)initWithActionElement:(std::shared_ptr<AdaptiveCards::ShowCardAction> const &)showCardActionElement
config:(ACOHostConfig *)config
superview:(UIView<ACRIContentHoldingView> *)superview
rootView:(ACRView *)rootView
{
self = [super init];
if(self)
{
_adaptiveCard = adaptiveCard;
_adaptiveCard = showCardActionElement->GetCard();
_config = config;
_superview = superview;
_rootView = rootView;
_adcView = nil;
std::shared_ptr<ShowCardAction> showCardAction = std::make_shared<ShowCardAction>();
showCardAction->SetCard(showCardActionElement->GetCard());
_actionElement = [[ACOBaseActionElement alloc]initWithBaseActionElement:std::dynamic_pointer_cast<BaseActionElement>(showCardAction)];
}
return self;
}
Expand Down Expand Up @@ -125,7 +131,8 @@ - (void)createShowCard:(NSMutableArray*)inputs

- (IBAction)toggleVisibilityOfShowCard
{
_adcView.hidden = (_adcView.hidden == YES)? NO: YES;
_adcView.hidden = (_adcView.hidden == YES)? NO: YES;
[_rootView.acrActionDelegate didFetchUserResponses:[_rootView card] action:_actionElement];
}

- (void)doSelectAction
Expand Down

0 comments on commit 7bf87c9

Please sign in to comment.