Skip to content

Commit

Permalink
fix(ios): restored borderRadius setter (#11951)
Browse files Browse the repository at this point in the history
* fix(ios): restored setter

* test: added unit test

* test(ios): make it ios specific
  • Loading branch information
vijaysingh-axway committed Aug 25, 2020
1 parent cc2a848 commit 0bc833d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
13 changes: 10 additions & 3 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUIView.m
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,11 @@ - (void)addCornerRadius:(NSArray *)radiusArray toLayer:(CALayer *)viewLayer
bottomLeftRadius = radius;
topRightRadius = radius;
} else if (radiusArray.count == 1) {
// For same corner radius, no need to create bezier path. Use CALayer's cornerRadius.
viewLayer.cornerRadius = [self radiusFromObject:radiusArray[0]];
return;
CGFloat radius = [self radiusFromObject:radiusArray[0]];
topLeftRadius = radius;
topRightRadius = radius;
bottomRightRadius = radius;
bottomLeftRadius = radius;
}

CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] initWithLayer:viewLayer];
Expand Down Expand Up @@ -727,6 +729,11 @@ - (void)updateBorderRadius:(id)radius
[self updateClipping];
}

- (void)setBorderRadius_:(id)radius
{
[self updateBorderRadius:radius];
}

- (void)setAnchorPoint_:(id)point
{
self.layer.anchorPoint = [TiUtils pointValue:point];
Expand Down
33 changes: 33 additions & 0 deletions tests/Resources/ti.ui.view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,39 @@ describe('Titanium.UI.View', function () {
win.add(outerView);
win.open();
});

it.ios('set property post layout', finish => {
win = Ti.UI.createWindow({ backgroundColor: 'blue' });
const outerView = Ti.UI.createView({
width: '90px',
height: '90px',
backgroundColor: 'green'
});
const view = Ti.UI.createView({
width: '60px',
height: '60px',
backgroundColor: 'yellow'
});

win.addEventListener('postlayout', function postlayout() {
win.removeEventListener('postlayout', postlayout); // only run once
try {
view.borderRadius = [ '12px', 12 ];
should(view.borderRadius).be.an.Array();
should(view.borderRadius.length).eql(2);
should(view.borderRadius).eql([ '12px', 12 ]);
// should be the exact same as above
should(outerView).matchImage(`snapshots/borderRadius12px_12_${density}x.png`);
} catch (err) {
return finish(err);
}
finish();
});

outerView.add(view);
win.add(outerView);
win.open();
});
});

it.android('touchFeedback', finish => {
Expand Down

0 comments on commit 0bc833d

Please sign in to comment.