Skip to content
Open
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
3 changes: 3 additions & 0 deletions framework/mvc/view/css/Bee_UIStyleParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
- (UITextBorderStyle)parseTextBorderStyleWithKeys:(NSArray *)keys;
- (UITextBorderStyle)parseTextBorderStyleWithKeys:(NSArray *)keys defaultValue:(UITextBorderStyle)defaultValue;

- (UIRectCorner)parseViewCornersStyleWithKeys:(NSArray *)keys;
- (UIRectCorner)parseViewCornersStyleWithKeys:(NSArray *)keys defaultValue:(UIRectCorner)defaultValue;

@end

#endif // #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
42 changes: 42 additions & 0 deletions framework/mvc/view/css/Bee_UIStyleParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,48 @@ - (UITextBorderStyle)parseTextBorderStyleWithKeys:(NSArray *)keys defaultValue:(
return UITextBorderStyleNone;
}

- (UIRectCorner)parseViewCornersStyleWithKeys:(NSArray *)keys
{
return [self parseViewCornersStyleWithKeys:keys defaultValue:UIRectCornerAllCorners];
}

- (UIRectCorner)parseViewCornersStyleWithKeys:(NSArray *)keys defaultValue:(UIRectCorner)defaultValue
{
NSString * value = [self parseStringWithKeys:keys];
if ( nil == value )
{
return defaultValue;
}

NSMutableArray *values = [NSMutableArray arrayWithArray:[value componentsSeparatedByString:@"-"]];
UIRectCorner corners = [self parseCornerByString:[values safeObjectAtIndex:0]];
[values removeObjectAtIndex:0];
for (NSString * str in values) {
corners = corners | [self parseCornerByString:str];
}
return corners;
}

- (UIRectCorner)parseCornerByString:(NSString *)str
{
UIRectCorner corners;
if ( [str matchAnyOf:@[@"BL", @"BottomLeft"]] ) {
corners = UIRectCornerBottomLeft;
}else if ( [str matchAnyOf:@[@"BR", @"BottomRight"]] )
{
corners = UIRectCornerBottomRight;
}else if ( [str matchAnyOf:@[@"TR", @"TopRight"]] )
{
corners = UIRectCornerTopRight;
}else if ( [str matchAnyOf:@[@"TL", @"TopLeft"]] ){
corners = UIRectCornerTopLeft;
}else
{
corners = UIRectCornerAllCorners;
}
return corners;
}

@end

#endif // #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
30 changes: 28 additions & 2 deletions framework/mvc/view/css/extension/UIView+BeeUIStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ - (void)applyStyle
if ( self.UIStyle )
{
[self applyUIStyling:self.UIStyle.properties];
[self applyUICorners:self.UIStyle.properties];
}
}

Expand Down Expand Up @@ -648,8 +649,11 @@ - (void)applyViewBorder:(NSMutableDictionary *)properties

self.layer.borderColor = [properties parseColorWithKeys:@[@"border-color"] defaultValue:[UIColor clearColor]].CGColor;
self.layer.borderWidth = [properties parseFloatWithKeys:@[@"border-width"] defaultValue:0.0f];
if ([properties stringOfAny:@[@"corners"] removeAll:false] != nil) {
return;
}
self.layer.cornerRadius = [properties parseFloatWithKeys:@[@"border-radius", @"corner-radius"] defaultValue:0.0f];

if ( self.layer.cornerRadius > 0.0f )
{
self.layer.masksToBounds = YES;
Expand Down Expand Up @@ -715,7 +719,6 @@ - (void)applyViewShadow:(NSMutableDictionary *)properties
self.layer.shadowOffset = [properties parseSizeWithKeys:@[@"shadow-offset"] defaultValue:CGSizeZero];
self.layer.shadowOpacity = [properties parseFloatWithKeys:@[@"shadow-opacity"] defaultValue:1.0f];
self.layer.shadowRadius = [properties parseFloatWithKeys:@[@"shadow-radius"] defaultValue:1.0f];
// self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
}

- (void)applyUIStyling:(NSDictionary *)properties
Expand All @@ -733,6 +736,29 @@ - (void)applyUIStyling:(NSDictionary *)properties
[super applyUIStyling:propertiesCopy];
}

- (void)applyUICorners:(NSDictionary *)properties
{
NSMutableDictionary * propertiesCopy = [NSMutableDictionary dictionaryWithDictionary:properties];

if ([propertiesCopy stringOfAny:@[@"corners"] removeAll:false] == nil) {
return;
}
float cornerRadius = [propertiesCopy parseFloatWithKeys:@[@"border-radius", @"corner-radius"] defaultValue:0.0f];
if ( cornerRadius > 0.0f )
{
self.layer.cornerRadius = 0;
self.layer.mask = nil;
UIRectCorner corners = [propertiesCopy parseViewCornersStyleWithKeys:@[@"corners"]];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
byRoundingCorners:corners
cornerRadii:CGSizeMake(cornerRadius, 0.0)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
}
}

@end

#endif // #if (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
1 change: 1 addition & 0 deletions framework/mvc/view/dom-capability/Bee_UICapability.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
- (BOOL)supportForUIStyling;

- (void)applyUIStyling:(NSDictionary *)properties;
- (void)applyUICorners:(NSDictionary *)properties;

// resource loading?

Expand Down
5 changes: 5 additions & 0 deletions framework/mvc/view/dom-capability/Bee_UICapability.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ - (void)applyUIStyling:(NSDictionary *)properties
// WARN( @"unrecognized styles for '%@':\n%@", [[self class] description], properties );
}

- (void)applyUICorners:(NSDictionary *)properties
{

}

+ (BOOL)supportForUIResourceLoading
{
return NO;
Expand Down
1 change: 1 addition & 0 deletions framework/mvc/view/dom-layout/Bee_UILayoutBuilder_v1.m
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ - (void)layoutTree:(CGRect)bound
// viewFrame.size.width, viewFrame.size.height );

view.frame = viewFrame;
[view applyUICorners:view.UIStyle.properties];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ Love coding, also skilled in HTML, CSS and JS.
margin-top: 2px;
margin-left: 10px;
background-color: #999;
border-radius: 8px;
border-radius: 20px;
border-color:#000;
border-width:2px;
corners:BL-BR-TL;
}

.profile-right-wrapper {
Expand Down
Loading