From 4b1a982e8566370f5dac430d3017768ea94bddc1 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 23 Oct 2019 20:06:21 +0800 Subject: [PATCH] rename add doric prefix --- iOS/Example/Example/ViewController.m | 6 +- iOS/Pod/Classes/Shader/DoricGroupNode.h | 2 +- iOS/Pod/Classes/Shader/DoricGroupNode.m | 18 +- iOS/Pod/Classes/Shader/DoricHLayoutNode.h | 2 +- iOS/Pod/Classes/Shader/DoricHLayoutNode.m | 10 +- .../{DoricLinearLayout.h => DoricLayouts.h} | 40 ++--- .../{DoricLinearLayout.m => DoricLayouts.m} | 160 +++++++++--------- iOS/Pod/Classes/Shader/DoricRootNode.h | 2 +- iOS/Pod/Classes/Shader/DoricRootNode.m | 2 +- iOS/Pod/Classes/Shader/DoricStackNode.h | 2 +- iOS/Pod/Classes/Shader/DoricStackNode.m | 14 +- iOS/Pod/Classes/Shader/DoricVLayoutNode.h | 2 +- iOS/Pod/Classes/Shader/DoricVLayoutNode.m | 10 +- iOS/Pod/Classes/Shader/DoricViewNode.h | 4 +- 14 files changed, 137 insertions(+), 137 deletions(-) rename iOS/Pod/Classes/Shader/{DoricLinearLayout.h => DoricLayouts.h} (65%) rename iOS/Pod/Classes/Shader/{DoricLinearLayout.m => DoricLayouts.m} (70%) diff --git a/iOS/Example/Example/ViewController.m b/iOS/Example/Example/ViewController.m index 806bc11d..e638a42a 100644 --- a/iOS/Example/Example/ViewController.m +++ b/iOS/Example/Example/ViewController.m @@ -13,7 +13,7 @@ #import "DoricNativePlugin.h" #import "DoricRootNode.h" #import "DoricLocalServer.h" -#import "DoricLinearLayout.h" +#import "DoricLayouts.h" #import "DoricExtensions.h" @interface ViewController () @@ -29,8 +29,8 @@ - (void)viewDidLoad { NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Snake" ofType:@"js"]; NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; self.doricContext = [[DoricContext alloc] initWithScript:jsContent source:@"test.js"]; - [self.doricContext.rootNode setupRootView:[[Stack new] also:^(Stack *it) { - it.layoutConfig = [[StackLayoutConfig alloc] initWithWidth:LayoutParamAtMost height:LayoutParamAtMost]; + [self.doricContext.rootNode setupRootView:[[DoricStackView new] also:^(DoricStackView *it) { + it.layoutConfig = [[DoricStackConfig alloc] initWithWidth:DoricLayoutAtMost height:DoricLayoutAtMost]; [self.view addSubview:it]; }]]; [self.doricContext initContextWithWidth:self.view.width height:self.view.height]; diff --git a/iOS/Pod/Classes/Shader/DoricGroupNode.h b/iOS/Pod/Classes/Shader/DoricGroupNode.h index fe717a3a..413de989 100644 --- a/iOS/Pod/Classes/Shader/DoricGroupNode.h +++ b/iOS/Pod/Classes/Shader/DoricGroupNode.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface DoricGroupNode : DoricViewNode +@interface DoricGroupNode : DoricViewNode @property(nonatomic, strong) NSMutableDictionary *children; @property(nonatomic, strong) NSMutableArray *indexedChildren; diff --git a/iOS/Pod/Classes/Shader/DoricGroupNode.m b/iOS/Pod/Classes/Shader/DoricGroupNode.m index ba5c6764..7cf1d71e 100644 --- a/iOS/Pod/Classes/Shader/DoricGroupNode.m +++ b/iOS/Pod/Classes/Shader/DoricGroupNode.m @@ -73,7 +73,7 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop [tobeRemoved addObject:old]; } - LayoutConfig *params = node.layoutConfig; + DoricLayoutConfig *params = node.layoutConfig; if (params == nil) { params = [self generateDefaultLayoutParams]; node.layoutConfig = params; @@ -109,31 +109,31 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop } } -- (LayoutConfig *)generateDefaultLayoutParams { - LayoutConfig *params = [[LayoutConfig alloc] init]; +- (DoricLayoutConfig *)generateDefaultLayoutParams { + DoricLayoutConfig *params = [[DoricLayoutConfig alloc] init]; return params; } - (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutConfig { - LayoutConfig *params = child.layoutConfig; + DoricLayoutConfig *params = child.layoutConfig; [layoutConfig[@"widthSpec"] also:^(NSNumber *it) { if (it) { - params.widthSpec = (LayoutParam) [it integerValue]; + params.widthSpec = (DoricLayoutSpec) [it integerValue]; } }]; [layoutConfig[@"heightSpec"] also:^(NSNumber *it) { if (it) { - params.heightSpec = (LayoutParam) [it integerValue]; + params.heightSpec = (DoricLayoutSpec) [it integerValue]; } }]; - if ([params isKindOfClass:MarginLayoutConfig.class]) { - MarginLayoutConfig *marginParams = (MarginLayoutConfig *) params; + if ([params isKindOfClass:DoricMarginConfig.class]) { + DoricMarginConfig *marginParams = (DoricMarginConfig *) params; NSDictionary *margin = layoutConfig[@"margin"]; if (margin) { - marginParams.margin = MarginMake( + marginParams.margin = DoricMarginMake( [(NSNumber *) margin[@"left"] floatValue], [(NSNumber *) margin[@"top"] floatValue], [(NSNumber *) margin[@"right"] floatValue], diff --git a/iOS/Pod/Classes/Shader/DoricHLayoutNode.h b/iOS/Pod/Classes/Shader/DoricHLayoutNode.h index d429f102..4e754d28 100644 --- a/iOS/Pod/Classes/Shader/DoricHLayoutNode.h +++ b/iOS/Pod/Classes/Shader/DoricHLayoutNode.h @@ -22,5 +22,5 @@ #import "DoricGroupNode.h" -@interface DoricHLayoutNode : DoricGroupNode +@interface DoricHLayoutNode : DoricGroupNode @end diff --git a/iOS/Pod/Classes/Shader/DoricHLayoutNode.m b/iOS/Pod/Classes/Shader/DoricHLayoutNode.m index 29d6a639..de2f0c00 100644 --- a/iOS/Pod/Classes/Shader/DoricHLayoutNode.m +++ b/iOS/Pod/Classes/Shader/DoricHLayoutNode.m @@ -40,14 +40,14 @@ - (void)blendView:(HLayout *)view forPropName:(NSString *)name propValue:(id)pro - (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutConfig { [super blendChild:child layoutConfig:layoutConfig]; - if (![child.layoutConfig isKindOfClass:LinearLayoutConfig.class]) { + if (![child.layoutConfig isKindOfClass:DoricLinearConfig.class]) { DoricLog(@"blend HLayout child error,layout params not match"); return; } - LinearLayoutConfig *params = (LinearLayoutConfig *) child.layoutConfig; + DoricLinearConfig *params = (DoricLinearConfig *) child.layoutConfig; NSDictionary *margin = layoutConfig[@"margin"]; if (margin) { - params.margin = MarginMake( + params.margin = DoricMarginMake( [(NSNumber *) margin[@"left"] floatValue], [(NSNumber *) margin[@"top"] floatValue], [(NSNumber *) margin[@"right"] floatValue], @@ -59,7 +59,7 @@ - (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutCon } } -- (LinearLayoutConfig *)generateDefaultLayoutParams { - return [[LinearLayoutConfig alloc] init]; +- (DoricLinearConfig *)generateDefaultLayoutParams { + return [[DoricLinearConfig alloc] init]; } @end diff --git a/iOS/Pod/Classes/Shader/DoricLinearLayout.h b/iOS/Pod/Classes/Shader/DoricLayouts.h similarity index 65% rename from iOS/Pod/Classes/Shader/DoricLinearLayout.h rename to iOS/Pod/Classes/Shader/DoricLayouts.h index 300cd46d..421b27b3 100644 --- a/iOS/Pod/Classes/Shader/DoricLinearLayout.h +++ b/iOS/Pod/Classes/Shader/DoricLayouts.h @@ -20,20 +20,20 @@ #import -struct Margin { +struct DoricMargin { CGFloat left; CGFloat right; CGFloat top; CGFloat bottom; }; -typedef struct Margin Margin; +typedef struct DoricMargin DoricMargin; -Margin MarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom); +DoricMargin DoricMarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom); -typedef NS_ENUM(NSInteger, LayoutParam) { - LayoutParamExact, - LayoutParamWrapContent, - LayoutParamAtMost, +typedef NS_ENUM(NSInteger, DoricLayoutSpec) { + DoricLayoutExact, + DoricLayoutWrapContent, + DoricLayoutAtMost, }; typedef NS_ENUM(NSInteger, DoricGravity) { @@ -51,32 +51,32 @@ typedef NS_ENUM(NSInteger, DoricGravity) { CENTER = CENTER_X | CENTER_Y, }; -@interface LayoutConfig : NSObject -@property(nonatomic, assign) LayoutParam widthSpec; -@property(nonatomic, assign) LayoutParam heightSpec; +@interface DoricLayoutConfig : NSObject +@property(nonatomic, assign) DoricLayoutSpec widthSpec; +@property(nonatomic, assign) DoricLayoutSpec heightSpec; @property(nonatomic, assign) DoricGravity alignment; - (instancetype)init; -- (instancetype)initWithWidth:(LayoutParam)width height:(LayoutParam)height; +- (instancetype)initWithWidth:(DoricLayoutSpec)width height:(DoricLayoutSpec)height; @end -@interface StackLayoutConfig : LayoutConfig +@interface DoricStackConfig : DoricLayoutConfig @end -@interface MarginLayoutConfig : LayoutConfig -@property(nonatomic) Margin margin; +@interface DoricMarginConfig : DoricLayoutConfig +@property(nonatomic) DoricMargin margin; -- (instancetype)initWithWidth:(LayoutParam)width height:(LayoutParam)height margin:(Margin)margin; +- (instancetype)initWithWidth:(DoricLayoutSpec)width height:(DoricLayoutSpec)height margin:(DoricMargin)margin; @end -@interface LinearLayoutConfig : MarginLayoutConfig +@interface DoricLinearConfig : DoricMarginConfig @property(nonatomic, assign) NSUInteger weight; @end -@interface LayoutContainer : UIView +@interface DoricLayoutContainer : UIView - (T)configForChild:(__kindof UIView *)child; @@ -85,11 +85,11 @@ typedef NS_ENUM(NSInteger, DoricGravity) { - (void)requestLayout; @end -@interface Stack : LayoutContainer +@interface DoricStackView : DoricLayoutContainer @property(nonatomic, assign) DoricGravity gravity; @end -@interface LinearLayout : LayoutContainer +@interface LinearLayout : DoricLayoutContainer @property(nonatomic, assign) DoricGravity gravity; @property(nonatomic, assign) CGFloat space; @end @@ -102,7 +102,7 @@ typedef NS_ENUM(NSInteger, DoricGravity) { @end @interface UIView (LayoutConfig) -@property(nonatomic, strong) LayoutConfig *layoutConfig; +@property(nonatomic, strong) DoricLayoutConfig *layoutConfig; @property(nonatomic, copy) NSString *tagString; - (UIView *)viewWithTagString:(NSString *)tagString; diff --git a/iOS/Pod/Classes/Shader/DoricLinearLayout.m b/iOS/Pod/Classes/Shader/DoricLayouts.m similarity index 70% rename from iOS/Pod/Classes/Shader/DoricLinearLayout.m rename to iOS/Pod/Classes/Shader/DoricLayouts.m index 7ddc1db8..f8d67ce3 100644 --- a/iOS/Pod/Classes/Shader/DoricLinearLayout.m +++ b/iOS/Pod/Classes/Shader/DoricLayouts.m @@ -17,12 +17,12 @@ // Created by pengfei.zhou on 2019/10/23. // -#import "DoricLinearLayout.h" +#import "DoricLayouts.h" #import #import "UIView+Doric.h" -Margin MarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) { - Margin margin; +DoricMargin DoricMarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) { + DoricMargin margin; margin.left = left; margin.top = top; margin.right = right; @@ -30,16 +30,16 @@ Margin MarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) { return margin; } -@implementation LayoutConfig +@implementation DoricLayoutConfig - (instancetype)init { if (self = [super init]) { - _widthSpec = LayoutParamExact; - _heightSpec = LayoutParamExact; + _widthSpec = DoricLayoutExact; + _heightSpec = DoricLayoutExact; } return self; } -- (instancetype)initWithWidth:(LayoutParam)width height:(LayoutParam)height { +- (instancetype)initWithWidth:(DoricLayoutSpec)width height:(DoricLayoutSpec)height { if (self = [super init]) { _widthSpec = width; _heightSpec = height; @@ -48,15 +48,15 @@ - (instancetype)initWithWidth:(LayoutParam)width height:(LayoutParam)height { } @end -@implementation MarginLayoutConfig +@implementation DoricMarginConfig - (instancetype)init { if (self = [super init]) { - _margin = MarginMake(0, 0, 0, 0); + _margin = DoricMarginMake(0, 0, 0, 0); } return self; } -- (instancetype)initWithWidth:(LayoutParam)width height:(LayoutParam)height margin:(Margin)margin { +- (instancetype)initWithWidth:(DoricLayoutSpec)width height:(DoricLayoutSpec)height margin:(DoricMargin)margin { if (self = [super initWithWidth:width height:height]) { _margin = margin; } @@ -64,18 +64,18 @@ - (instancetype)initWithWidth:(LayoutParam)width height:(LayoutParam)height marg } @end -@implementation StackLayoutConfig +@implementation DoricStackConfig @end -@implementation LinearLayoutConfig +@implementation DoricLinearConfig @end -@interface LayoutContainer () +@interface DoricLayoutContainer () @property(nonatomic, assign) BOOL waitingLayout; @end -@implementation LayoutContainer +@implementation DoricLayoutContainer - (instancetype)init { if (self = [super init]) { _waitingLayout = NO; @@ -98,10 +98,10 @@ - (instancetype)initWithCoder:(NSCoder *)coder { } -- (LayoutConfig *)configForChild:(UIView *)child { - LayoutConfig *config = child.layoutConfig; +- (DoricLayoutConfig *)configForChild:(UIView *)child { + DoricLayoutConfig *config = child.layoutConfig; if (!config) { - config = [[LayoutConfig alloc] init]; + config = [[DoricLayoutConfig alloc] init]; } return config; } @@ -129,8 +129,8 @@ - (void)layoutSubviews { - (void)layout { [self.subviews enumerateObjectsUsingBlock:^(__kindof UIView *child, NSUInteger idx, BOOL *stop) { - if ([child isKindOfClass:[LayoutContainer class]]) { - [(LayoutContainer *) child layout]; + if ([child isKindOfClass:[DoricLayoutContainer class]]) { + [(DoricLayoutContainer *) child layout]; } }]; } @@ -138,47 +138,47 @@ - (void)layout { @end -@interface Stack () +@interface DoricStackView () @property(nonatomic, assign) CGFloat contentWidth; @property(nonatomic, assign) CGFloat contentHeight; @end -@implementation Stack -- (StackLayoutConfig *)configForChild:(UIView *)child { - StackLayoutConfig *config = (StackLayoutConfig *) child.layoutConfig; +@implementation DoricStackView +- (DoricStackConfig *)configForChild:(UIView *)child { + DoricStackConfig *config = (DoricStackConfig *) child.layoutConfig; if (!config) { - config = [[StackLayoutConfig alloc] init]; + config = [[DoricStackConfig alloc] init]; } return config; } - (void)sizeToFit { - LayoutConfig *config = self.layoutConfig; + DoricLayoutConfig *config = self.layoutConfig; self.contentWidth = 0; self.contentHeight = 0; for (UIView *child in self.subviews) { if (child.isHidden) { continue; } - StackLayoutConfig *childConfig = [self configForChild:child]; - if ([child isKindOfClass:[LayoutContainer class]] - || childConfig.widthSpec == LayoutParamWrapContent - || childConfig.heightSpec == LayoutParamWrapContent) { + DoricStackConfig *childConfig = [self configForChild:child]; + if ([child isKindOfClass:[DoricLayoutContainer class]] + || childConfig.widthSpec == DoricLayoutWrapContent + || childConfig.heightSpec == DoricLayoutWrapContent) { [child sizeToFit]; } self.contentWidth = MAX(self.contentWidth, child.width); self.contentHeight = MAX(self.contentHeight, child.height); } - if (config.widthSpec == LayoutParamWrapContent) { + if (config.widthSpec == DoricLayoutWrapContent) { self.width = self.contentWidth; - } else if (config.widthSpec == LayoutParamAtMost) { + } else if (config.widthSpec == DoricLayoutAtMost) { self.width = self.superview.width; } - if (config.heightSpec == LayoutParamWrapContent) { + if (config.heightSpec == DoricLayoutWrapContent) { self.height = self.contentHeight; - } else if (config.heightSpec == LayoutParamAtMost) { + } else if (config.heightSpec == DoricLayoutAtMost) { self.height = self.superview.height; } } @@ -188,7 +188,7 @@ - (void)layout { if (child.isHidden) { continue; } - StackLayoutConfig *childConfig = [self configForChild:child]; + DoricStackConfig *childConfig = [self configForChild:child]; DoricGravity gravity = childConfig.alignment | self.gravity; if ((gravity & LEFT) == LEFT) { child.left = 0; @@ -204,15 +204,15 @@ - (void)layout { } else if ((gravity & CENTER_Y) == CENTER_Y) { child.centerY = self.height / 2; } - if (childConfig.widthSpec == LayoutParamAtMost) { + if (childConfig.widthSpec == DoricLayoutAtMost) { child.width = self.width; } - if (childConfig.heightSpec == LayoutParamAtMost) { + if (childConfig.heightSpec == DoricLayoutAtMost) { child.height = self.height; } - if ([child isKindOfClass:[LayoutContainer class]]) { - [(LayoutContainer *) child layout]; + if ([child isKindOfClass:[DoricLayoutContainer class]]) { + [(DoricLayoutContainer *) child layout]; } } } @@ -225,10 +225,10 @@ @interface LinearLayout () @end @implementation LinearLayout -- (LinearLayoutConfig *)configForChild:(UIView *)child { - LinearLayoutConfig *config = (LinearLayoutConfig *) child.layoutConfig; +- (DoricLinearConfig *)configForChild:(UIView *)child { + DoricLinearConfig *config = (DoricLinearConfig *) child.layoutConfig; if (!config) { - config = [[LinearLayoutConfig alloc] init]; + config = [[DoricLinearConfig alloc] init]; } return config; } @@ -237,7 +237,7 @@ - (LinearLayoutConfig *)configForChild:(UIView *)child { @implementation VLayout - (void)sizeToFit { - LayoutConfig *config = self.layoutConfig; + DoricLayoutConfig *config = self.layoutConfig; self.contentWidth = 0; self.contentHeight = 0; self.contentWeight = 0; @@ -245,10 +245,10 @@ - (void)sizeToFit { if (child.isHidden) { continue; } - LinearLayoutConfig *childConfig = [self configForChild:child]; - if ([child isKindOfClass:[LayoutContainer class]] - || childConfig.widthSpec == LayoutParamWrapContent - || childConfig.heightSpec == LayoutParamWrapContent) { + DoricLinearConfig *childConfig = [self configForChild:child]; + if ([child isKindOfClass:[DoricLayoutContainer class]] + || childConfig.widthSpec == DoricLayoutWrapContent + || childConfig.heightSpec == DoricLayoutWrapContent) { [child sizeToFit]; } self.contentWidth = MAX(self.contentWidth, child.width + childConfig.margin.left + childConfig.margin.right); @@ -256,14 +256,14 @@ - (void)sizeToFit { self.contentWeight += childConfig.weight; } self.contentHeight -= self.space; - if (config.widthSpec == LayoutParamWrapContent) { + if (config.widthSpec == DoricLayoutWrapContent) { self.width = self.contentWidth; - } else if (config.widthSpec == LayoutParamAtMost) { + } else if (config.widthSpec == DoricLayoutAtMost) { self.width = self.superview.width; } - if (config.heightSpec == LayoutParamWrapContent) { + if (config.heightSpec == DoricLayoutWrapContent) { self.height = self.contentHeight; - } else if (config.heightSpec == LayoutParamAtMost) { + } else if (config.heightSpec == DoricLayoutAtMost) { self.height = self.superview.height; } if (self.contentWeight) { @@ -272,7 +272,7 @@ - (void)sizeToFit { if (child.isHidden) { continue; } - LinearLayoutConfig *childConfig = [self configForChild:child]; + DoricLinearConfig *childConfig = [self configForChild:child]; if (childConfig.weight) { child.height += remain / self.contentWeight * childConfig.weight; } @@ -294,7 +294,7 @@ - (void)layout { if (child.isHidden) { continue; } - LinearLayoutConfig *childConfig = [self configForChild:child]; + DoricLinearConfig *childConfig = [self configForChild:child]; DoricGravity gravity = childConfig.alignment | self.gravity; if ((gravity & LEFT) == LEFT) { child.left = 0; @@ -309,10 +309,10 @@ - (void)layout { child.right = self.width - childConfig.margin.right; } } - if (childConfig.widthSpec == LayoutParamAtMost) { + if (childConfig.widthSpec == DoricLayoutAtMost) { child.width = self.width; } - if (childConfig.heightSpec == LayoutParamAtMost) { + if (childConfig.heightSpec == DoricLayoutAtMost) { child.height = self.height - yStart - childConfig.margin.top - childConfig.margin.bottom - self.space; } if (childConfig.margin.top) { @@ -323,8 +323,8 @@ - (void)layout { if (childConfig.margin.bottom) { yStart += childConfig.margin.bottom; } - if ([child isKindOfClass:[LayoutContainer class]]) { - [(LayoutContainer *) child layout]; + if ([child isKindOfClass:[DoricLayoutContainer class]]) { + [(DoricLayoutContainer *) child layout]; } } } @@ -332,13 +332,13 @@ - (void)layout { @implementation HLayout - (void)sizeToFit { - LinearLayoutConfig *config; + DoricLinearConfig *config; if ([self.superview isKindOfClass:[LinearLayout class]]) { config = [(LinearLayout *) self.superview configForChild:self]; } else { - config = (LinearLayoutConfig *) self.layoutConfig; + config = (DoricLinearConfig *) self.layoutConfig; if (!config) { - config = [[LinearLayoutConfig alloc] init]; + config = [[DoricLinearConfig alloc] init]; } } self.contentWidth = 0; @@ -348,10 +348,10 @@ - (void)sizeToFit { if (child.isHidden) { continue; } - LinearLayoutConfig *childConfig = [self configForChild:child]; - if ([child isKindOfClass:[LayoutContainer class]] - || childConfig.widthSpec == LayoutParamWrapContent - || childConfig.heightSpec == LayoutParamWrapContent) { + DoricLinearConfig *childConfig = [self configForChild:child]; + if ([child isKindOfClass:[DoricLayoutContainer class]] + || childConfig.widthSpec == DoricLayoutWrapContent + || childConfig.heightSpec == DoricLayoutWrapContent) { [child sizeToFit]; } self.contentHeight = MAX(self.contentHeight, child.height + childConfig.margin.top + childConfig.margin.bottom); @@ -359,14 +359,14 @@ - (void)sizeToFit { self.contentWeight += childConfig.weight; } self.contentWidth -= self.space; - if (config.widthSpec == LayoutParamWrapContent) { + if (config.widthSpec == DoricLayoutWrapContent) { self.width = self.contentWidth; - } else if (config.widthSpec == LayoutParamAtMost) { + } else if (config.widthSpec == DoricLayoutAtMost) { self.width = self.superview.width; } - if (config.heightSpec == LayoutParamWrapContent) { + if (config.heightSpec == DoricLayoutWrapContent) { self.height = self.contentHeight; - } else if (config.heightSpec == LayoutParamAtMost) { + } else if (config.heightSpec == DoricLayoutAtMost) { self.height = self.superview.height; } if (self.contentWeight) { @@ -375,7 +375,7 @@ - (void)sizeToFit { if (child.isHidden) { continue; } - LinearLayoutConfig *childConfig = [self configForChild:child]; + DoricLinearConfig *childConfig = [self configForChild:child]; if (childConfig.weight) { child.width += remain / self.contentWeight * childConfig.weight; } @@ -397,7 +397,7 @@ - (void)layout { if (child.isHidden) { continue; } - LinearLayoutConfig *childConfig = [self configForChild:child]; + DoricLinearConfig *childConfig = [self configForChild:child]; DoricGravity gravity = childConfig.alignment | self.gravity; if ((gravity & TOP) == TOP) { child.top = 0; @@ -413,10 +413,10 @@ - (void)layout { } } - if (childConfig.heightSpec == LayoutParamAtMost) { + if (childConfig.heightSpec == DoricLayoutAtMost) { child.height = self.height; } - if (childConfig.widthSpec == LayoutParamAtMost) { + if (childConfig.widthSpec == DoricLayoutAtMost) { child.width = self.width - xStart - childConfig.margin.right - childConfig.margin.left - self.space; } @@ -428,8 +428,8 @@ - (void)layout { if (childConfig.margin.right) { xStart += childConfig.margin.right; } - if ([child isKindOfClass:[LayoutContainer class]]) { - [(LayoutContainer *) child layout]; + if ([child isKindOfClass:[DoricLayoutContainer class]]) { + [(DoricLayoutContainer *) child layout]; } } } @@ -441,11 +441,11 @@ - (void)layout { @implementation UIView (LayoutConfig) @dynamic layoutConfig; -- (void)setLayoutConfig:(LayoutConfig *)layoutConfig { +- (void)setLayoutConfig:(DoricLayoutConfig *)layoutConfig { objc_setAssociatedObject(self, kLayoutConfig, layoutConfig, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (LayoutConfig *)layoutConfig { +- (DoricLayoutConfig *)layoutConfig { return objc_getAssociatedObject(self, kLayoutConfig); } @@ -471,7 +471,7 @@ - (UIView *)viewWithTagString:(NSString *)tagString { for (__kindof UIView *uiView in views) { [layout addSubview:uiView]; } - layout.layoutConfig = [[LayoutConfig alloc] initWithWidth:LayoutParamWrapContent height:LayoutParamWrapContent]; + layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent]; return layout; } @@ -480,7 +480,7 @@ - (UIView *)viewWithTagString:(NSString *)tagString { for (__kindof UIView *uiView in views) { [layout addSubview:uiView]; } - layout.layoutConfig = [[LayoutConfig alloc] initWithWidth:LayoutParamWrapContent height:LayoutParamWrapContent]; + layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent]; return layout; } @@ -490,7 +490,7 @@ - (UIView *)viewWithTagString:(NSString *)tagString { for (block in blocks) { [layout addSubview:block()]; } - layout.layoutConfig = [[LayoutConfig alloc] initWithWidth:LayoutParamWrapContent height:LayoutParamWrapContent]; + layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent]; return layout; } @@ -500,6 +500,6 @@ - (UIView *)viewWithTagString:(NSString *)tagString { for (block in blocks) { [layout addSubview:block()]; } - layout.layoutConfig = [[LayoutConfig alloc] initWithWidth:LayoutParamWrapContent height:LayoutParamWrapContent]; + layout.layoutConfig = [[DoricLayoutConfig alloc] initWithWidth:DoricLayoutWrapContent height:DoricLayoutWrapContent]; return layout; -} \ No newline at end of file +} diff --git a/iOS/Pod/Classes/Shader/DoricRootNode.h b/iOS/Pod/Classes/Shader/DoricRootNode.h index cc945e8c..58bff00a 100644 --- a/iOS/Pod/Classes/Shader/DoricRootNode.h +++ b/iOS/Pod/Classes/Shader/DoricRootNode.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN @interface DoricRootNode : DoricStackNode -- (void)setupRootView:(Stack *)view; +- (void)setupRootView:(DoricStackView *)view; - (void)render:(NSDictionary *)props; @end diff --git a/iOS/Pod/Classes/Shader/DoricRootNode.m b/iOS/Pod/Classes/Shader/DoricRootNode.m index 69f2ad28..ed0ae8db 100644 --- a/iOS/Pod/Classes/Shader/DoricRootNode.m +++ b/iOS/Pod/Classes/Shader/DoricRootNode.m @@ -23,7 +23,7 @@ #import "DoricRootNode.h" @implementation DoricRootNode -- (void)setupRootView:(Stack *)view { +- (void)setupRootView:(DoricStackView *)view { self.view = view; self.layoutConfig = view.layoutConfig; } diff --git a/iOS/Pod/Classes/Shader/DoricStackNode.h b/iOS/Pod/Classes/Shader/DoricStackNode.h index 9d6cbe98..375cafad 100644 --- a/iOS/Pod/Classes/Shader/DoricStackNode.h +++ b/iOS/Pod/Classes/Shader/DoricStackNode.h @@ -22,5 +22,5 @@ #import "DoricGroupNode.h" -@interface DoricStackNode : DoricGroupNode +@interface DoricStackNode : DoricGroupNode @end diff --git a/iOS/Pod/Classes/Shader/DoricStackNode.m b/iOS/Pod/Classes/Shader/DoricStackNode.m index 4023605a..ec1e37af 100644 --- a/iOS/Pod/Classes/Shader/DoricStackNode.m +++ b/iOS/Pod/Classes/Shader/DoricStackNode.m @@ -25,11 +25,11 @@ @implementation DoricStackNode -- (Stack *)build:(NSDictionary *)props { - return [Stack new]; +- (DoricStackView *)build:(NSDictionary *)props { + return [DoricStackView new]; } -- (void)blendView:(Stack *)view forPropName:(NSString *)name propValue:(id)prop { +- (void)blendView:(DoricStackView *)view forPropName:(NSString *)name propValue:(id)prop { if ([name isEqualToString:@"gravity"]) { view.gravity = (DoricGravity) [(NSNumber *) prop integerValue]; } else { @@ -37,17 +37,17 @@ - (void)blendView:(Stack *)view forPropName:(NSString *)name propValue:(id)prop } } -- (StackLayoutConfig *)generateDefaultLayoutParams { - return [[StackLayoutConfig alloc] init]; +- (DoricStackConfig *)generateDefaultLayoutParams { + return [[DoricStackConfig alloc] init]; } - (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutConfig { [super blendChild:child layoutConfig:layoutConfig]; - if (![child.layoutConfig isKindOfClass:StackLayoutConfig.class]) { + if (![child.layoutConfig isKindOfClass:DoricStackConfig.class]) { DoricLog(@"blend HLayout child error,layout params not match"); return; } - StackLayoutConfig *params = (StackLayoutConfig *) child.layoutConfig; + DoricStackConfig *params = (DoricStackConfig *) child.layoutConfig; NSNumber *alignment = layoutConfig[@"alignment"]; if (alignment) { params.alignment = (DoricGravity) [alignment integerValue]; diff --git a/iOS/Pod/Classes/Shader/DoricVLayoutNode.h b/iOS/Pod/Classes/Shader/DoricVLayoutNode.h index 2ed3bfbd..28cde7d3 100644 --- a/iOS/Pod/Classes/Shader/DoricVLayoutNode.h +++ b/iOS/Pod/Classes/Shader/DoricVLayoutNode.h @@ -22,5 +22,5 @@ #import "DoricGroupNode.h" -@interface DoricVLayoutNode : DoricGroupNode +@interface DoricVLayoutNode : DoricGroupNode @end diff --git a/iOS/Pod/Classes/Shader/DoricVLayoutNode.m b/iOS/Pod/Classes/Shader/DoricVLayoutNode.m index 94b00765..243b04fd 100644 --- a/iOS/Pod/Classes/Shader/DoricVLayoutNode.m +++ b/iOS/Pod/Classes/Shader/DoricVLayoutNode.m @@ -41,14 +41,14 @@ - (void)blendView:(VLayout *)view forPropName:(NSString *)name propValue:(id)pro - (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutconfig { [super blendChild:child layoutConfig:layoutconfig]; - if (![child.layoutConfig isKindOfClass:LinearLayoutConfig.class]) { + if (![child.layoutConfig isKindOfClass:DoricLinearConfig.class]) { DoricLog(@"blend VLayout child error,layout params not match"); return; } - LinearLayoutConfig *params = (LinearLayoutConfig *) child.layoutConfig; + DoricLinearConfig *params = (DoricLinearConfig *) child.layoutConfig; NSDictionary *margin = layoutconfig[@"margin"]; if (margin) { - params.margin = MarginMake( + params.margin = DoricMarginMake( [(NSNumber *) margin[@"left"] floatValue], [(NSNumber *) margin[@"top"] floatValue], [(NSNumber *) margin[@"right"] floatValue], @@ -60,7 +60,7 @@ - (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutcon } } -- (LinearLayoutConfig *)generateDefaultLayoutParams { - return [[LinearLayoutConfig alloc] init]; +- (DoricLinearConfig *)generateDefaultLayoutParams { + return [[DoricLinearConfig alloc] init]; } @end diff --git a/iOS/Pod/Classes/Shader/DoricViewNode.h b/iOS/Pod/Classes/Shader/DoricViewNode.h index 36dcc378..f7333e42 100644 --- a/iOS/Pod/Classes/Shader/DoricViewNode.h +++ b/iOS/Pod/Classes/Shader/DoricViewNode.h @@ -21,7 +21,7 @@ // #import "DoricContextHolder.h" -#import "DoricLinearLayout.h" +#import "DoricLayouts.h" #import "UIView+Doric.h" NS_ASSUME_NONNULL_BEGIN @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong) NSString *viewId; -@property(nonatomic, strong) LayoutConfig *layoutConfig; +@property(nonatomic, strong) DoricLayoutConfig *layoutConfig; @property(nonatomic, strong, readonly) NSArray *idList;