Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions samples/v1.5/Elements/Input.Text.PasswordStyle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "Input.Text",
"id": "id0",
"placeholder": "password",
"style": "password",
"label": "Input.Text With Password Style"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ + (ACRTextField *)configTextFiled:(std::shared_ptr<TextInput> const &)inputBlock
txtInput = [bundle loadNibNamed:@"ACRTextUrlField" owner:rootView options:nil][0];
break;
}
case TextInputStyle::Password: {
txtInput = [bundle loadNibNamed:@"ACRTextField" owner:rootView options:nil][0];
txtInput.secureTextEntry = YES;
break;
}
case TextInputStyle::Text:
default: {
txtInput = [bundle loadNibNamed:@"ACRTextField" owner:rootView options:nil][0];
Expand All @@ -74,6 +79,7 @@ + (ACRTextField *)configTextFiled:(std::shared_ptr<TextInput> const &)inputBlock
txtInput.placeholder = [NSString stringWithCString:inputBlock->GetPlaceholder().c_str()
encoding:NSUTF8StringEncoding];
txtInput.text = [NSString stringWithCString:inputBlock->GetValue().c_str() encoding:NSUTF8StringEncoding];

txtInput.allowsEditingTextAttributes = YES;
return txtInput;
}
Expand Down Expand Up @@ -107,7 +113,9 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
}

ACRTextInputHandler *textInputHandler = [[ACRTextInputHandler alloc] init:acoElem];
if (inputBlck->GetIsMultiline()) {

BOOL isMultiline = (inputBlck->GetTextInputStyle() != TextInputStyle::Password) && inputBlck->GetIsMultiline();
if (isMultiline) {
if (renderAction) {
// if action is defined, load ACRQuickReplyMultilineView nib for customizable UI
multilineview = [[ACRQuickReplyMultilineView alloc] initWithFrame:CGRectMake(0, 0, viewGroup.frame.size.width, 0)];
Expand Down Expand Up @@ -169,7 +177,7 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup

// configures for action
if (renderAction) {
if (inputBlck->GetIsMultiline()) {
if (isMultiline) {
[inputs addObject:txtview];
} else {
[inputs addObject:inputview];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
//

#import "ACRContentHoldingUIView.h"
#import "ACOBaseCardElementPrivate.h"
#import "ACRRegistration.h"
#import "ACRBaseCardElementRenderer.h"
#import "TextBlock.h"
#import "TextInput.h"
#import "ACRInputLabelView.h"
#import "ACRTextView.h"
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>

using namespace AdaptiveCards;

@interface AdaptiveCardsTests : XCTestCase

@end
Expand Down Expand Up @@ -47,5 +55,73 @@ - (void)testContentHoldingUIViewWithImage
XCTAssertEqualObjects(wrapperView.contentView, imageView);
}

- (void)testPasswordStyleIsCorrectSet
{
std::shared_ptr<AdaptiveCards::TextInput> textInput = std::make_shared<AdaptiveCards::TextInput>();
textInput->SetTextInputStyle(TextInputStyle::Password);
ACOBaseCardElement *baseCardElement = [[ACOBaseCardElement alloc] initWithBaseCardElement:textInput];
ACRRegistration *registration = [ACRRegistration getInstance];
ACRBaseCardElementRenderer *renderer = [registration getRenderer:[NSNumber numberWithInt:ACRTextInput]];
ACRColumnView *viewGroup = [[ACRColumnView alloc] init];
ACRView *rootView = [[ACRView alloc] init];
NSMutableArray *inputs = [[NSMutableArray alloc] init];
ACOHostConfig *config = [[ACOHostConfig alloc] init];
UIView *inputView = [renderer render:viewGroup rootView:rootView inputs:inputs
baseCardElement:baseCardElement
hostConfig:config];
XCTAssertNotNil(inputView);
XCTAssertTrue([inputView isKindOfClass:[ACRInputLabelView class]]);
ACRInputLabelView *labelview = (ACRInputLabelView *)inputView;
XCTAssertNotNil(labelview.inputView);
XCTAssertTrue([labelview.inputView isKindOfClass:[UITextField class]]);
UITextField *textField = (UITextField *)labelview.inputView;
XCTAssertTrue(textField.isSecureTextEntry);
}

- (void)testInputIsSetToACRTextViewWhenMultiline
{
std::shared_ptr<AdaptiveCards::TextInput> textInput = std::make_shared<AdaptiveCards::TextInput>();
textInput->SetIsMultiline(true);
ACOBaseCardElement *baseCardElement = [[ACOBaseCardElement alloc] initWithBaseCardElement:textInput];
ACRRegistration *registration = [ACRRegistration getInstance];
ACRBaseCardElementRenderer *renderer = [registration getRenderer:[NSNumber numberWithInt:ACRTextInput]];
ACRColumnView *viewGroup = [[ACRColumnView alloc] init];
ACRView *rootView = [[ACRView alloc] init];
NSMutableArray *inputs = [[NSMutableArray alloc] init];
ACOHostConfig *config = [[ACOHostConfig alloc] init];
UIView *inputView = [renderer render:viewGroup rootView:rootView inputs:inputs
baseCardElement:baseCardElement
hostConfig:config];
XCTAssertNotNil(inputView);
XCTAssertTrue([inputView isKindOfClass:[ACRInputLabelView class]]);
ACRInputLabelView *labelview = (ACRInputLabelView *)inputView;
XCTAssertNotNil(labelview.inputView);
XCTAssertTrue([labelview.inputView isKindOfClass:[ACRTextView class]]);
}

- (void)testInputIsSetToACRTextFieldWhenMultilineAndPasswordStyleAreSet
{
std::shared_ptr<AdaptiveCards::TextInput> textInput = std::make_shared<AdaptiveCards::TextInput>();
textInput->SetIsMultiline(true);
textInput->SetTextInputStyle(TextInputStyle::Password);
ACOBaseCardElement *baseCardElement = [[ACOBaseCardElement alloc] initWithBaseCardElement:textInput];
ACRRegistration *registration = [ACRRegistration getInstance];
ACRBaseCardElementRenderer *renderer = [registration getRenderer:[NSNumber numberWithInt:ACRTextInput]];
ACRColumnView *viewGroup = [[ACRColumnView alloc] init];
ACRView *rootView = [[ACRView alloc] init];
NSMutableArray *inputs = [[NSMutableArray alloc] init];
ACOHostConfig *config = [[ACOHostConfig alloc] init];
UIView *inputView = [renderer render:viewGroup rootView:rootView inputs:inputs
baseCardElement:baseCardElement
hostConfig:config];
XCTAssertNotNil(inputView);
XCTAssertTrue([inputView isKindOfClass:[ACRInputLabelView class]]);
ACRInputLabelView *labelview = (ACRInputLabelView *)inputView;
XCTAssertNotNil(labelview.inputView);
XCTAssertTrue([labelview.inputView isKindOfClass:[UITextField class]]);
UITextField *textField = (UITextField *)labelview.inputView;
XCTAssertTrue(textField.isSecureTextEntry);
}

@end