feat:rename vlayout and hlayout

This commit is contained in:
pengfei.zhou 2019-10-23 20:11:24 +08:00
parent 4b1a982e85
commit c9f1f099ae
7 changed files with 32 additions and 40 deletions

View File

@ -22,5 +22,5 @@
#import "DoricGroupNode.h"
@interface DoricHLayoutNode : DoricGroupNode<HLayout *, DoricLinearConfig *>
@interface DoricHLayoutNode : DoricGroupNode<DoricHLayoutView *, DoricLinearConfig *>
@end

View File

@ -24,11 +24,11 @@
#import "DoricUtil.h"
@implementation DoricHLayoutNode
- (HLayout *)build:(NSDictionary *)props {
return [HLayout new];
- (DoricHLayoutView *)build:(NSDictionary *)props {
return [DoricHLayoutView new];
}
- (void)blendView:(HLayout *)view forPropName:(NSString *)name propValue:(id)prop {
- (void)blendView:(DoricHLayoutView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([name isEqualToString:@"gravity"]) {
view.gravity = (DoricGravity) [(NSNumber *) prop integerValue];
} else if ([name isEqualToString:@"space"]) {
@ -41,7 +41,7 @@ - (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:DoricLinearConfig.class]) {
DoricLog(@"blend HLayout child error,layout params not match");
DoricLog(@"blend DoricHLayoutView child error,layout params not match");
return;
}
DoricLinearConfig *params = (DoricLinearConfig *) child.layoutConfig;

View File

@ -89,29 +89,21 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
@property(nonatomic, assign) DoricGravity gravity;
@end
@interface LinearLayout : DoricLayoutContainer<DoricLinearConfig *>
@interface DoricLinearView : DoricLayoutContainer<DoricLinearConfig *>
@property(nonatomic, assign) DoricGravity gravity;
@property(nonatomic, assign) CGFloat space;
@end
@interface VLayout : LinearLayout
@interface DoricVLayoutView : DoricLinearView
@end
@interface HLayout : LinearLayout
@interface DoricHLayoutView : DoricLinearView
@end
@interface UIView (LayoutConfig)
@interface UIView (DoricLayoutConfig)
@property(nonatomic, strong) DoricLayoutConfig *layoutConfig;
@property(nonatomic, copy) NSString *tagString;
- (UIView *)viewWithTagString:(NSString *)tagString;
@end
VLayout *vLayout(NSArray <__kindof UIView *> *views);
HLayout *hLayout(NSArray <__kindof UIView *> *views);
VLayout *vLayoutWithBlock(NSArray <UIView *(^)()> *blocks);
HLayout *hLayoutWithBlock(NSArray <UIView *(^)()> *blocks);

View File

@ -107,8 +107,8 @@ - (DoricLayoutConfig *)configForChild:(UIView *)child {
}
- (void)requestLayout {
if ([self.superview isKindOfClass:[LinearLayout class]]) {
[(LinearLayout *) self.superview requestLayout];
if ([self.superview isKindOfClass:[DoricLinearView class]]) {
[(DoricLinearView *) self.superview requestLayout];
return;
}
if (self.waitingLayout) {
@ -218,13 +218,13 @@ - (void)layout {
}
@end
@interface LinearLayout ()
@interface DoricLinearView ()
@property(nonatomic, assign) CGFloat contentWidth;
@property(nonatomic, assign) CGFloat contentHeight;
@property(nonatomic, assign) NSUInteger contentWeight;
@end
@implementation LinearLayout
@implementation DoricLinearView
- (DoricLinearConfig *)configForChild:(UIView *)child {
DoricLinearConfig *config = (DoricLinearConfig *) child.layoutConfig;
if (!config) {
@ -234,7 +234,7 @@ - (DoricLinearConfig *)configForChild:(UIView *)child {
}
@end
@implementation VLayout
@implementation DoricVLayoutView
- (void)sizeToFit {
DoricLayoutConfig *config = self.layoutConfig;
@ -330,11 +330,11 @@ - (void)layout {
}
@end
@implementation HLayout
@implementation DoricHLayoutView
- (void)sizeToFit {
DoricLinearConfig *config;
if ([self.superview isKindOfClass:[LinearLayout class]]) {
config = [(LinearLayout *) self.superview configForChild:self];
if ([self.superview isKindOfClass:[DoricLinearView class]]) {
config = [(DoricLinearView *) self.superview configForChild:self];
} else {
config = (DoricLinearConfig *) self.layoutConfig;
if (!config) {
@ -438,7 +438,7 @@ - (void)layout {
static const void *kLayoutConfig = &kLayoutConfig;
static const void *kTagString = &kTagString;
@implementation UIView (LayoutConfig)
@implementation UIView (DoricLayoutConfig)
@dynamic layoutConfig;
- (void)setLayoutConfig:(DoricLayoutConfig *)layoutConfig {
@ -466,8 +466,8 @@ - (UIView *)viewWithTagString:(NSString *)tagString {
@end
VLayout *vLayout(NSArray <__kindof UIView *> *views) {
VLayout *layout = [[VLayout alloc] initWithFrame:CGRectZero];
DoricVLayoutView *vLayout(NSArray <__kindof UIView *> *views) {
DoricVLayoutView *layout = [[DoricVLayoutView alloc] initWithFrame:CGRectZero];
for (__kindof UIView *uiView in views) {
[layout addSubview:uiView];
}
@ -475,8 +475,8 @@ - (UIView *)viewWithTagString:(NSString *)tagString {
return layout;
}
HLayout *hLayout(NSArray <__kindof UIView *> *views) {
HLayout *layout = [[HLayout alloc] initWithFrame:CGRectZero];
DoricHLayoutView *hLayout(NSArray <__kindof UIView *> *views) {
DoricHLayoutView *layout = [[DoricHLayoutView alloc] initWithFrame:CGRectZero];
for (__kindof UIView *uiView in views) {
[layout addSubview:uiView];
}
@ -484,8 +484,8 @@ - (UIView *)viewWithTagString:(NSString *)tagString {
return layout;
}
VLayout *vLayoutWithBlock(NSArray <UIView *(^)()> *blocks) {
VLayout *layout = [[VLayout alloc] initWithFrame:CGRectZero];
DoricVLayoutView *vLayoutWithBlock(NSArray <UIView *(^)()> *blocks) {
DoricVLayoutView *layout = [[DoricVLayoutView alloc] initWithFrame:CGRectZero];
UIView *(^block)();
for (block in blocks) {
[layout addSubview:block()];
@ -494,8 +494,8 @@ - (UIView *)viewWithTagString:(NSString *)tagString {
return layout;
}
HLayout *hLayoutWithBlock(NSArray <UIView *(^)()> *blocks) {
HLayout *layout = [[HLayout alloc] initWithFrame:CGRectZero];
DoricHLayoutView *hLayoutWithBlock(NSArray <UIView *(^)()> *blocks) {
DoricHLayoutView *layout = [[DoricHLayoutView alloc] initWithFrame:CGRectZero];
UIView *(^block)();
for (block in blocks) {
[layout addSubview:block()];

View File

@ -44,7 +44,7 @@ - (DoricStackConfig *)generateDefaultLayoutParams {
- (void)blendChild:(DoricViewNode *)child layoutConfig:(NSDictionary *)layoutConfig {
[super blendChild:child layoutConfig:layoutConfig];
if (![child.layoutConfig isKindOfClass:DoricStackConfig.class]) {
DoricLog(@"blend HLayout child error,layout params not match");
DoricLog(@"blend DoricHLayoutView child error,layout params not match");
return;
}
DoricStackConfig *params = (DoricStackConfig *) child.layoutConfig;

View File

@ -22,5 +22,5 @@
#import "DoricGroupNode.h"
@interface DoricVLayoutNode : DoricGroupNode<VLayout *, DoricLinearConfig *>
@interface DoricVLayoutNode : DoricGroupNode<DoricVLayoutView *, DoricLinearConfig *>
@end

View File

@ -25,11 +25,11 @@
@implementation DoricVLayoutNode
- (VLayout *)build:(NSDictionary *)props {
return [VLayout new];
- (DoricVLayoutView *)build:(NSDictionary *)props {
return [DoricVLayoutView new];
}
- (void)blendView:(VLayout *)view forPropName:(NSString *)name propValue:(id)prop {
- (void)blendView:(DoricVLayoutView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([name isEqualToString:@"gravity"]) {
view.gravity = (DoricGravity) [(NSNumber *) prop integerValue];
} else if ([name isEqualToString:@"space"]) {
@ -42,7 +42,7 @@ - (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:DoricLinearConfig.class]) {
DoricLog(@"blend VLayout child error,layout params not match");
DoricLog(@"blend DoricVLayoutView child error,layout params not match");
return;
}
DoricLinearConfig *params = (DoricLinearConfig *) child.layoutConfig;