Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
135988f
[iOS] Fixed #6219
jwoo-msft Aug 20, 2021
84356ba
Merge branch 'main' of github.com:Microsoft/AdaptiveCards into main
jwoo-msft Aug 23, 2021
09cf57c
[iOS] adding padding support to toggle visibility
jwoo-msft Aug 24, 2021
9bbb020
[Padding] Update
jwoo-msft Aug 26, 2021
4a6f43f
Merge branch 'main' into jwoo/ios-toggle-update
jwoo-msft Aug 26, 2021
db38396
[iOS] work in progress
jwoo-msft Aug 30, 2021
7707e80
Merge branch 'main' into jwoo/ios-toggle-update
jwoo-msft Aug 30, 2021
69a4c65
mostly done need to refactor and update padding management code
jwoo-msft Aug 31, 2021
e191f2b
Merge branch 'main' into jwoo/ios-toggle-update
jwoo-msft Sep 2, 2021
583175e
[iOS] refactored
jwoo-msft Sep 3, 2021
0d7199d
Merge branch 'main' into jwoo/ios-toggle-update
jwoo-msft Sep 3, 2021
756a8b1
[iOS] added padding test
jwoo-msft Sep 7, 2021
fd6e00c
Merge branch 'main' into jwoo/ios-toggle-update
jwoo-msft Sep 7, 2021
6aa07d7
refactored the padding configuration in FactSet to Padding Handler
jwoo-msft Sep 7, 2021
0a3d208
Merge branch 'jwoo/ios-toggle-update' into jwoo/ios-unit-test-update
jwoo-msft Sep 7, 2021
82da0ae
[iOS] Updated VerticalContentAlignment and Height
jwoo-msft Sep 16, 2021
6ba3896
Merge branch 'main' into jwoo/ios-unit-test-update
jwoo-msft Sep 16, 2021
45caaeb
Reverts samples card changes
jwoo-msft Sep 16, 2021
8fdf74f
[iOS] code clean-up
jwoo-msft Sep 16, 2021
19ea513
[iOS] Table Update
jwoo-msft Sep 17, 2021
fd5072d
[iOS] Updated Table with better Horizontal Alignment
jwoo-msft Sep 23, 2021
43ebc22
Merge branch 'main' into jwoo/ios-table-update
jwoo-msft Sep 28, 2021
89dc78f
Merge branch 'main' into jwoo/ios-table-update
jwoo-msft Sep 28, 2021
844e7af
Merge branch 'main' into jwoo/ios-table-update
jwoo-msft Sep 28, 2021
0af5629
Merge branch 'main' into jwoo/ios-table-update
paulcam206 Sep 28, 2021
9474a22
Clean-Up
jwoo-msft Sep 28, 2021
74f4fa1
Merge branch 'jwoo/ios-table-update' of github.com:Microsoft/Adaptive…
jwoo-msft Sep 28, 2021
da1415e
Merge branch 'main' into jwoo/ios-table-update
jwoo-msft Sep 28, 2021
d5b2c55
Merge branch 'main' into jwoo/ios-table-update
paulcam206 Sep 28, 2021
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 @@ -1121,7 +1121,7 @@
name = ImageSet;
sourceTree = "<group>";
};
6BFCA139264F548600195CA7 /* TableView */ = {
6BFCA139264F548600195CA7 /* Table */ = {
isa = PBXGroup;
children = (
6BFCA14A265452E000195CA7 /* ACRTableRenderer.h */,
Expand All @@ -1135,7 +1135,7 @@
6BFCA13B264F54B100195CA7 /* ACRTableView.h */,
6BFCA13D264F54B300195CA7 /* ACRTableView.mm */,
);
name = TableView;
name = Table;
sourceTree = "<group>";
};
6BFF99DC2600121A0028069F /* Action.Execute */ = {
Expand Down Expand Up @@ -1198,7 +1198,6 @@
F42979341F3007C500E89914 /* ReadOnlyObjects */,
6B8C766826461F1A009548FA /* Resources */,
F423C0D71EE1FF2F00905679 /* SharedLib */,
6BFCA139264F548600195CA7 /* TableView */,
6B92A71B266FE84F00CAE3BF /* Utilities */,
);
path = AdaptiveCards;
Expand Down Expand Up @@ -1477,6 +1476,7 @@
6B7B1A9520BE2CBB00260731 /* ACRUIImageView.mm */,
F4F44B6A203FA8EF00A2F24C /* ACRUILabel.h */,
F4F44B6D203FAF9300A2F24C /* ACRUILabel.mm */,
6BFCA139264F548600195CA7 /* Table */,
6B124C9626B9F519007E9641 /* Columns */,
6BE6C7C626E7E2A6009E9171 /* ImageSet */,
6BB2120621000024009EA1BA /* Media */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@property (readonly) BOOL isFirstRowAsHeaders;
@property (readonly) ACRVerticalContentAlignment verticalContentAlignment;
@property (readonly) ACRHorizontalAlignment horizontalContentAlignment;
@property (readonly) ACRContainerStyle style;

@property (weak) ACOHostConfig* _Nullable hostConfig;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ @interface ACOContextProperties : NSObject
@property NSNumber *iconPlacement;
@property BOOL hasSelectAction;
@property BOOL isFirstRowAsHeaders;
@property ContainerStyle style;
@end

@implementation ACOContextProperties
Expand All @@ -41,6 +42,7 @@ @implementation ACORenderContext {
NSMutableArray<NSNumber *> *_firstRowsAsheadersContext;
NSMutableArray<NSNumber *> *_verticalAlignmentContext;
NSMutableArray<NSNumber *> *_horizontalAlignmentContext;
NSMutableArray<NSNumber *> *_styleContext;
NSMapTable<NSNumber *, NSObject<ACOIVisibilityManagerFacade> *> *_visibilityMap;
}

Expand All @@ -56,6 +58,7 @@ - (instancetype)init
_firstRowsAsheadersContext = [[NSMutableArray alloc] init];
_verticalAlignmentContext = [[NSMutableArray alloc] init];
_horizontalAlignmentContext = [[NSMutableArray alloc] init];
_styleContext = [[NSMutableArray alloc] init];
_visibilityMap = [NSMapTable mapTableWithKeyOptions:NSMapTableStrongMemory valueOptions:NSMapTableWeakMemory];
}

Expand Down Expand Up @@ -133,6 +136,17 @@ - (ACRHorizontalAlignment)horizontalContentAlignment
return ACRLeft;
}

- (ACRContainerStyle)style
{
if (_styleContext && [_styleContext count]) {
NSNumber *number = [_styleContext lastObject];
if (number) {
return (ACRContainerStyle)[number intValue];
}
}
return ACRNone;
}

- (void)pushBaseActionElementContext:(ACOBaseActionElement *)element
{
return;
Expand Down Expand Up @@ -184,6 +198,12 @@ - (void)addToANewContext:(ACOContextProperties *)properties key:(NSNumber *)key
[_verticalAlignmentContext addObject:[NSNumber numberWithInt:(int)(*properties.verticalAlignment)]];
[contexts addObject:_verticalAlignmentContext];
}

if (properties.style != ContainerStyle::None) {
shouldPush = YES;
[_styleContext addObject:[NSNumber numberWithInt:(int)(properties.style)]];
[contexts addObject:_styleContext];
}

if (shouldPush) {
_internalIdContext[key] = contexts;
Expand All @@ -210,6 +230,7 @@ - (void)pushBaseCardElementContext:(ACOBaseCardElement *)acoElement additionalPr
if (table) {
properties.horizontalAlignment = table->GetHorizontalCellContentAlignment();
properties.verticalAlignment = table->GetVerticalCellContentAlignment();
properties.style = table->GetGridStyle();
}
}

Expand All @@ -228,14 +249,20 @@ - (void)pushBaseCardElementContext:(ACOBaseCardElement *)acoElement additionalPr
if (row) {
properties.horizontalAlignment = row->GetHorizontalCellContentAlignment();
properties.verticalAlignment = row->GetVerticalCellContentAlignment();
properties.style = row->GetStyle();
}
}

if (acoElement.type == ACRTableCell) {
const std::shared_ptr<TableCell> &cell = std::dynamic_pointer_cast<TableCell>(element);
properties.crtl = cell->GetRtl();
if (cell->GetSelectAction()) {
properties.hasSelectAction = YES;
if (cell) {
if (cell->GetSelectAction()) {
properties.hasSelectAction = YES;
}

properties.verticalAlignment = cell->GetVerticalContentAlignment();
properties.style = cell->GetStyle();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,7 @@ - (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup

[viewGroup addArrangedSubview:container];

if (acoElem.type == ACRTableCell) {
CGFloat top, left, bottom, right;
top = left = bottom = right = [acoConfig getHostConfig]->GetSpacing().paddingSpacing;
[container removeConstraints:container.constraints];
[container applyPaddingToTop:top
left:left
bottom:bottom
right:right
priority:1000
location:ACRBleedToAll];
} else {
configBleed(rootView, elem, container, acoConfig);
}
configBleed(rootView, elem, container, acoConfig);

renderBackgroundImage(containerElem->GetBackgroundImage(), container, rootView);

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

@interface ACRContentStackView : UIView <ACRIContentHoldingView, ACOIVisibilityManagerFacade> {
@protected
UIStackView *_stackView;
ACOFillerSpaceManager *_paddingHandler;
NSMutableArray<UIView *> *_paddings;
ACOVisibilityManager *_visibilityManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ @implementation ACRContentStackView {
NSMutableArray *_targets;
NSMutableArray<ACRShowCardTarget *> *_showcardTargets;
ACRContainerStyle _style;
UIStackView *_stackView;
NSMutableDictionary<NSString *, NSValue *> *_subviewIntrinsicContentSizeCollection;
ACRRtl _rtl;
NSMutableSet *_invisibleViews;
ACRVerticalContentAlignment _verticalContentAlignment;
ACRHorizontalAlignment _horizontalAlignment;
}

- (instancetype)initWithStyle:(ACRContainerStyle)style
Expand Down Expand Up @@ -211,6 +211,11 @@ - (void)config:(nullable NSDictionary<NSString *, id> *)attributes
if ([topPaddingAttrib boolValue]) {
top = [topPaddingAttrib floatValue];
}

NSNumber *horizontalAlignment = attributes[@"horizontal-alignment"];
if ([horizontalAlignment intValue]) {
_horizontalAlignment = (ACRHorizontalAlignment)[horizontalAlignment intValue];
}
}

[self applyPaddingToTop:top
Expand Down Expand Up @@ -352,13 +357,40 @@ - (void)applyPaddingToTop:(CGFloat)top
CGFloat topPadding = (location & ACRBleedToTopEdge) ? top : 0;
CGFloat bottomPadding = (location & ACRBleedToBottomEdge) ? bottom : 0;

NSString *horString = [[NSString alloc] initWithFormat:@"H:|-(%f@%u)-[_stackView]-(%f@%u)-|",
leadingPadding, priority, trailingPadding, priority];
NSMutableArray<NSLayoutConstraint *> *constraints = [[NSMutableArray alloc] init];
NSDictionary *dictionary = nil;

if (_horizontalAlignment == ACRRight || _horizontalAlignment == ACRCenter) {
UILayoutGuide *leftSpacer = [[UILayoutGuide alloc] init];
[self addLayoutGuide:leftSpacer];
[constraints addObject:[self.centerYAnchor constraintEqualToAnchor:leftSpacer.centerYAnchor]];
NSLayoutConstraint *leftSpacerWidthConstraint = [leftSpacer.widthAnchor constraintEqualToConstant:0];
leftSpacerWidthConstraint.priority = UILayoutPriorityDefaultLow;
[constraints addObject:leftSpacerWidthConstraint];
if (_horizontalAlignment == ACRCenter) {
UILayoutGuide *rightSpacer = [[UILayoutGuide alloc] init];
[self addLayoutGuide:rightSpacer];
[constraints addObject:[self.centerYAnchor constraintEqualToAnchor:rightSpacer.centerYAnchor]];
NSLayoutConstraint *rightSpacerWidthConstraint = [rightSpacer.widthAnchor constraintEqualToConstant:0];
rightSpacerWidthConstraint.priority = UILayoutPriorityDefaultLow;
[constraints addObject:rightSpacerWidthConstraint];
[constraints addObject:[rightSpacer.widthAnchor constraintEqualToAnchor:leftSpacer.widthAnchor]];
dictionary = NSDictionaryOfVariableBindings(_stackView, rightSpacer, leftSpacer);
} else {
dictionary = NSDictionaryOfVariableBindings(_stackView, leftSpacer);
}
} else {
dictionary = NSDictionaryOfVariableBindings(_stackView);
}

NSString *leftSpacerStr = (_horizontalAlignment == ACRRight || _horizontalAlignment == ACRCenter) ? @"[leftSpacer]-" : @"";
NSString *rightSpacerStr = (_horizontalAlignment == ACRCenter) ? @"[rightSpacer]-" : @"";

NSString *horString = [[NSString alloc] initWithFormat:@"H:|-(%f@%u)-%@[_stackView]-%@(%f@%u)-|",
leadingPadding, priority, leftSpacerStr, rightSpacerStr, trailingPadding, priority];
NSString *verString = [[NSString alloc] initWithFormat:@"V:|-(%f@%u)-[_stackView]-(%f@%u)-|",
topPadding, priority, bottomPadding, priority];

NSDictionary *dictionary = NSDictionaryOfVariableBindings(_stackView);

_widthconstraint = [NSLayoutConstraint constraintsWithVisualFormat:horString
options:0
metrics:nil
Expand All @@ -368,8 +400,10 @@ - (void)applyPaddingToTop:(CGFloat)top
metrics:nil
views:dictionary];

[self addConstraints:_widthconstraint];
[self addConstraints:_heightconstraint];
[constraints addObjectsFromArray:_widthconstraint];
[constraints addObjectsFromArray:_heightconstraint];

[NSLayoutConstraint activateConstraints:constraints];
}

// target is the background view, it will be pinned to parent according to the direction set by bleed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
//

#import "ACRTableCellRenderer.h"
#import "ACOBaseCardElementPrivate.h"
#import "ACOHostConfigPrivate.h"
#import "ACRRendererPrivate.h"
#import "ACRTableCellView.h"
#import "TableCell.h"
#import "UtiliOS.h"

@implementation ACRTableCellRenderer

Expand All @@ -20,4 +26,41 @@ + (ACRCardElementType)elemType
return ACRTableCell;
}


- (UIView *)render:(UIView<ACRIContentHoldingView> *)viewGroup
rootView:(ACRView *)rootView
inputs:(NSMutableArray *)inputs
baseCardElement:(ACOBaseCardElement *)acoElem
hostConfig:(ACOHostConfig *)acoConfig;
{
std::shared_ptr<BaseCardElement> elem = [acoElem element];
auto cellElement = std::dynamic_pointer_cast<TableCell>(elem);

ACRColumnView *cell = (ACRColumnView *)viewGroup;

cell.rtl = rootView.context.rtl;

renderBackgroundImage(cellElement->GetBackgroundImage(), cell, rootView);

[ACRRenderer render:cell
rootView:rootView
inputs:inputs
withCardElems:cellElement->GetItems()
andHostConfig:acoConfig];

[cell setClipsToBounds:NO];

std::shared_ptr<BaseActionElement> selectAction = cellElement->GetSelectAction();
ACOBaseActionElement *acoSelectAction = [ACOBaseActionElement getACOActionElementFromAdaptiveElement:selectAction];
[cell configureForSelectAction:acoSelectAction rootView:rootView];

[cell configureLayoutAndVisibility:rootView.context.verticalContentAlignment
minHeight:cellElement->GetMinHeight()
heightType:GetACRHeight(cellElement->GetHeight())
type:ACRContainer];

return cell;
}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// Copyright © 2021 Microsoft. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "AdaptiveCards.h"
#import "ACRContentStackView.h"
#import "AdaptiveCards.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -17,17 +17,17 @@ NS_ASSUME_NONNULL_BEGIN
@property ACRContainerStyle style;
@property ACRVerticalContentAlignment verticalAlignment;
@property ACRHorizontalAlignment horizontalAlignment;
@property CGFloat cellSpacing;

@end

@interface ACRTableCellView : ACRContentStackView
@interface ACRTableCellView : ACRColumnView

- (instancetype)init:(ACOBaseCardElement *)baseCardElement
cellDefinition:(ACRTableCellDefinition *)definition
cellDefinition:(ACRTableCellDefinition *)definition
rootView:(ACRView *)rootView
inputs:(NSMutableArray *)inputs
hostConfig:(ACOHostConfig *)acoConfig;

@end

NS_ASSUME_NONNULL_END
Loading