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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright © 2018 Microsoft. All rights reserved.
//

#import "ACOBaseCardElement.h"
#import "ACRIBaseInputHandler.h"
#import "ChoiceInput.h"
#import "ChoiceSetInput.h"
Expand All @@ -22,8 +23,10 @@ extern NSString *uncheckedRadioButtonReuseID;
@interface ACRChoiceSetViewDataSource : NSObject <UITableViewDataSource, UITableViewDelegate, ACRIBaseInputHandler>
@property NSString *id;
@property BOOL isMultiChoicesAllowed;
@property ACRContainerStyle parentStyle;

- (instancetype)initWithInputChoiceSet:(std::shared_ptr<AdaptiveCards::ChoiceSetInput> const &)choiceSet WithHostConfig:(std::shared_ptr<AdaptiveCards::HostConfig> const &)hostConfig;

- (instancetype)initWithInputChoiceSet:(std::shared_ptr<AdaptiveCards::ChoiceSetInput> const &)choiceSet;

- (void)getDefaultInput:(NSMutableDictionary *)dictionary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import "ACRChoiceSetViewDataSource.h"
#import "UtiliOS.h"
#import <Foundation/Foundation.h>

using namespace AdaptiveCards;
Expand Down Expand Up @@ -53,9 +54,10 @@ @implementation ACRChoiceSetViewDataSource {
NSMutableSet *_defaultValuesSet;
NSArray *_defaultValuesArray;
BOOL _shouldWrap;
std::shared_ptr<HostConfig> _config;
}

- (instancetype)initWithInputChoiceSet:(std::shared_ptr<AdaptiveCards::ChoiceSetInput> const &)choiceSet
- (instancetype)initWithInputChoiceSet:(std::shared_ptr<AdaptiveCards::ChoiceSetInput> const &)choiceSet WithHostConfig:(std::shared_ptr<AdaptiveCards::HostConfig> const &)hostConfig;
{
self = [super init];
if (self) {
Expand All @@ -66,6 +68,9 @@ - (instancetype)initWithInputChoiceSet:(std::shared_ptr<AdaptiveCards::ChoiceSet
_shouldWrap = choiceSet->GetWrap();
_userSelections = [[NSMutableDictionary alloc] init];
_currentSelectedIndexPath = nil;
_config = hostConfig;
_parentStyle = ACRContainerStyle::ACRNone;

NSString *defaultValues = [NSString stringWithCString:_choiceSetDataSource->GetValue().c_str()
encoding:NSUTF8StringEncoding];
_defaultValuesArray = [defaultValues componentsSeparatedByCharactersInSet:
Expand Down Expand Up @@ -122,6 +127,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSString *title = [NSString stringWithCString:_choiceSetDataSource->GetChoices()[indexPath.row]->GetTitle().c_str()
encoding:NSUTF8StringEncoding];
cell.textLabel.text = title;
cell.textLabel.textColor = getForegroundUIColorFromAdaptiveAttribute(_config, _parentStyle);
cell.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
cell.selectionStyle = UITableViewCellSelectionStyleNone;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
dataSource = [[ACRChoiceSetViewDataSourceCompactStyle alloc] initWithInputChoiceSet:choiceSet rootView:rootView];
[choiceSetView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
} else {
dataSource = [[ACRChoiceSetViewDataSource alloc] initWithInputChoiceSet:choiceSet];
dataSource = [[ACRChoiceSetViewDataSource alloc] initWithInputChoiceSet:choiceSet WithHostConfig:config];

Choose a reason for hiding this comment

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

ceSet:choiceSet WithHostConfig:co [](start = 74, length = 33)

Can we add unit tests for this API/call at all ? or is that not written to support unit tests at this point? If not can we add the sample card + host config you were working with to the samples folder if it doesnt already exist? thanks! Basically whatever it is we need to do to ensure this is part of (eventual automated) test suites/plan that we have.

[choiceSetView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
inputTableView.frame = CGRectMake(0, 0, viewGroup.frame.size.width, viewGroup.frame.size.height);
[inputTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
ACRToggleInputDataSource *dataSource = [[ACRToggleInputDataSource alloc] initWithInputToggle:toggleBlck WithHostConfig:config];
dataSource.parentStyle = viewGroup.style;
inputTableView.delegate = dataSource;
inputTableView.dataSource = dataSource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -14,8 +12,6 @@
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" clearButtonMode="always" id="Lb5-az-8Wv" customClass="ACRTextField">
<rect key="frame" x="0.0" y="0.0" width="97" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="lightTextColor"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<point key="canvasLocation" x="-371" y="-262"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Copyright © 2018 Microsoft. All rights reserved.
//

#import "ACOBaseCardElement.h"
#import "ACRColumnSetView.h"
#import "ACRIBaseCardElementRenderer.h"
#import "ACRIBaseInputHandler.h"
Expand All @@ -13,6 +14,7 @@

@interface ACRToggleInputDataSource : NSObject <UITableViewDataSource, UITableViewDelegate, ACRIBaseInputHandler>

@property ACRContainerStyle parentStyle;
@property NSString *id;
@property NSString *valueOn;
@property NSString *valueOff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "ACRIBaseCardElementRenderer.h"
#import "ACRUILabel.h"
#import "HostConfig.h"
#import "UtiliOS.h"
#import <Foundation/Foundation.h>

using namespace AdaptiveCards;
Expand All @@ -33,6 +34,7 @@ - (instancetype)initWithInputToggle:(std::shared_ptr<ToggleInput> const &)toggle
_toggleSwitch = [[UISwitch alloc] init];
_toggleInputDataSource = toggleInput;
_config = hostConfig;
_parentStyle = ACRContainerStyle::ACRNone;
self.id = [[NSString alloc] initWithCString:_toggleInputDataSource->GetId().c_str()
encoding:NSUTF8StringEncoding];
_shouldWrap = toggleInput->GetWrap();
Expand Down Expand Up @@ -67,6 +69,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
reuseIdentifier:identifier];
}
cell.textLabel.text = _title;
cell.textLabel.textColor = getForegroundUIColorFromAdaptiveAttribute(_config, _parentStyle);
cell.textLabel.adjustsFontSizeToFitWidth = NO;
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ void TextRunToRichTextElementProperties(const std::shared_ptr<TextRun> &textRun,
void buildIntermediateResultForText(ACRView *rootView, ACOHostConfig *hostConfig, RichTextElementProperties const &textProperties, NSString *elementId);

ACOBaseActionElement *deserializeUnknownActionToCustomAction(const std::shared_ptr<UnknownAction> action);

UIColor *getForegroundUIColorFromAdaptiveAttribute(std::shared_ptr<HostConfig> const &config, ACRContainerStyle style, ForegroundColor textColor = ForegroundColor::Default, bool isSubtle = false);
Original file line number Diff line number Diff line change
Expand Up @@ -678,3 +678,9 @@ void TextRunToRichTextElementProperties(const std::shared_ptr<TextRun> &textRun,
}
return customAction;
}

UIColor *getForegroundUIColorFromAdaptiveAttribute(std::shared_ptr<HostConfig> const &config, ACRContainerStyle style, ForegroundColor textColor, bool isSubtle)
{
const std::string str = config->GetForegroundColor([ACOHostConfig getSharedContainerStyle:style], textColor, isSubtle);
return [ACOHostConfig convertHexColorCodeToUIColor:str];
}