feat:add SwipeLayout
This commit is contained in:
parent
deada07e8d
commit
2fbf4602e8
@ -48,6 +48,19 @@ - (void)blend:(NSDictionary *)props {
|
|||||||
[super blend:props];
|
[super blend:props];
|
||||||
[self blendHeader];
|
[self blendHeader];
|
||||||
[self blendContent];
|
[self blendContent];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.view also:^(DoricSwipeRefreshLayout *layout) {
|
||||||
|
[layout layoutSelf];
|
||||||
|
[layout.contentView also:^(UIView *it) {
|
||||||
|
it.x = it.y = 0;
|
||||||
|
}];
|
||||||
|
[layout.headerView also:^(UIView *it) {
|
||||||
|
it.bottom = 0;
|
||||||
|
it.centerX = layout.width / 2;
|
||||||
|
}];
|
||||||
|
layout.contentSize = layout.frame.size;
|
||||||
|
}];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)blendContent {
|
- (void)blendContent {
|
||||||
|
@ -17,6 +17,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
|
|||||||
if (self = [super initWithFrame:frame]) {
|
if (self = [super initWithFrame:frame]) {
|
||||||
self.showsHorizontalScrollIndicator = NO;
|
self.showsHorizontalScrollIndicator = NO;
|
||||||
self.showsVerticalScrollIndicator = NO;
|
self.showsVerticalScrollIndicator = NO;
|
||||||
|
self.alwaysBounceVertical = YES;
|
||||||
self.delegate = self;
|
self.delegate = self;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -26,6 +27,7 @@ - (instancetype)init {
|
|||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
self.showsHorizontalScrollIndicator = NO;
|
self.showsHorizontalScrollIndicator = NO;
|
||||||
self.showsVerticalScrollIndicator = NO;
|
self.showsVerticalScrollIndicator = NO;
|
||||||
|
self.alwaysBounceVertical = YES;
|
||||||
self.delegate = self;
|
self.delegate = self;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -58,16 +60,6 @@ - (void)setHeaderView:(UIView *)headerView {
|
|||||||
|
|
||||||
- (void)layoutSubviews {
|
- (void)layoutSubviews {
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
[self layoutSelf];
|
|
||||||
[self.contentView also:^(UIView *it) {
|
|
||||||
[it layoutSubviews];
|
|
||||||
it.x = it.y = 0;
|
|
||||||
}];
|
|
||||||
[self.headerView also:^(UIView *it) {
|
|
||||||
[it layoutSubviews];
|
|
||||||
it.bottom = it.centerX = 0;
|
|
||||||
}];
|
|
||||||
self.contentSize = self.frame.size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
|
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
|
||||||
@ -115,4 +107,8 @@ - (void)setRefreshable:(BOOL)refreshable {
|
|||||||
- (BOOL)refreshable {
|
- (BOOL)refreshable {
|
||||||
return self.scrollEnabled;
|
return self.scrollEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setContentSize:(CGSize)contentSize {
|
||||||
|
[super setContentSize:contentSize];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#import "DoricLayouts.h"
|
#import "DoricLayouts.h"
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
#import "UIView+Doric.h"
|
#import "UIView+Doric.h"
|
||||||
|
#import "Doric.h"
|
||||||
|
|
||||||
DoricMargin DoricMarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) {
|
DoricMargin DoricMarginMake(CGFloat left, CGFloat top, CGFloat right, CGFloat bottom) {
|
||||||
DoricMargin margin;
|
DoricMargin margin;
|
||||||
@ -537,6 +538,13 @@ - (void)layoutSelf {
|
|||||||
} else if (self.layoutConfig.heightSpec == DoricLayoutWrapContent) {
|
} else if (self.layoutConfig.heightSpec == DoricLayoutWrapContent) {
|
||||||
self.height = contentSize.height;
|
self.height = contentSize.height;
|
||||||
}
|
}
|
||||||
|
[self.subviews forEach:^(__kindof UIView *obj) {
|
||||||
|
if ([obj isKindOfClass:[DoricLayoutContainer class]]) {
|
||||||
|
[obj layoutSubviews];
|
||||||
|
} else {
|
||||||
|
[obj layoutSelf];
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -32,12 +32,6 @@ - (void)setContentView:(UIView *)contentView {
|
|||||||
[self addSubview:contentView];
|
[self addSubview:contentView];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)layoutSubviews {
|
|
||||||
[super layoutSubviews];
|
|
||||||
[self layoutSelf];
|
|
||||||
[self.contentView layoutSubviews];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (CGSize)sizeThatFits:(CGSize)size {
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
if (self.contentView) {
|
if (self.contentView) {
|
||||||
CGSize childSize = [self.contentView sizeThatFits:size];
|
CGSize childSize = [self.contentView sizeThatFits:size];
|
||||||
@ -92,15 +86,19 @@ - (void)blend:(NSDictionary *)props {
|
|||||||
self.view.contentView = it.view;
|
self.view.contentView = it.view;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.view also:^(DoricScrollView *it) {
|
[self.view also:^(DoricScrollView *it) {
|
||||||
|
[it layoutSelf];
|
||||||
if (it.contentView) {
|
if (it.contentView) {
|
||||||
CGSize size = [it.contentView sizeThatFits:it.frame.size];
|
CGSize size = [it.contentView sizeThatFits:it.frame.size];
|
||||||
[it setContentSize:size];
|
[it setContentSize:size];
|
||||||
}
|
}
|
||||||
|
[it layoutSelf];
|
||||||
}];
|
}];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)blendView:(UIScrollView *)view forPropName:(NSString *)name propValue:(id)prop {
|
- (void)blendView:(DoricScrollView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||||
if ([@"content" isEqualToString:name]) {
|
if ([@"content" isEqualToString:name]) {
|
||||||
self.childViewId = prop;
|
self.childViewId = prop;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user