feature:CoordinateLayout support multi set
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DoricScrollableProtocol.h"
|
||||
|
||||
typedef void (^DoricDidScrollBlock)(UIScrollView *__nonnull scrollView);
|
||||
|
||||
@protocol DoricScrollableProtocol <NSObject>
|
||||
@property(nonatomic, strong, nullable) void (^didScrollListener)(UIScrollView *__nonnull scrollView);
|
||||
|
||||
- (void)addDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener;
|
||||
|
||||
- (void)removeDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener;
|
||||
@end
|
||||
|
@@ -22,5 +22,4 @@
|
||||
#import "DoricScrollableProtocol.h"
|
||||
|
||||
@interface DoricFlowLayoutNode : DoricSuperNode<UICollectionView *> <DoricScrollableProtocol>
|
||||
@property(nonatomic, strong, nullable) void (^didScrollListener)(UIScrollView *__nonnull scrollView);
|
||||
@end
|
@@ -171,6 +171,7 @@ @interface DoricFlowLayoutNode () <UICollectionViewDataSource, UICollectionViewD
|
||||
@property(nonatomic, copy) NSString *onLoadMoreFuncId;
|
||||
@property(nonatomic, copy) NSString *loadMoreViewId;
|
||||
@property(nonatomic, assign) BOOL loadMore;
|
||||
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
|
||||
@end
|
||||
|
||||
@implementation DoricFlowLayoutNode
|
||||
@@ -370,8 +371,23 @@ - (NSInteger)doricFlowLayoutColumnCount {
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
if (self.didScrollListener) {
|
||||
self.didScrollListener(scrollView);
|
||||
for (DoricDidScrollBlock block in self.didScrollBlocks) {
|
||||
block(scrollView);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableSet<DoricDidScrollBlock> *)didScrollBlocks {
|
||||
if (!_didScrollBlocks) {
|
||||
_didScrollBlocks = [NSMutableSet new];
|
||||
}
|
||||
return _didScrollBlocks;
|
||||
}
|
||||
|
||||
- (void)addDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener {
|
||||
[self.didScrollBlocks addObject:didScrollListener];
|
||||
}
|
||||
|
||||
- (void)removeDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener {
|
||||
[self.didScrollBlocks removeObject:didScrollListener];
|
||||
}
|
||||
@end
|
||||
|
@@ -22,5 +22,4 @@
|
||||
#import "DoricScrollableProtocol.h"
|
||||
|
||||
@interface DoricListNode : DoricSuperNode<UITableView *> <DoricScrollableProtocol>
|
||||
@property(nonatomic, strong, nullable) void (^didScrollListener)(UIScrollView *__nonnull scrollView);
|
||||
@end
|
@@ -66,6 +66,7 @@ @interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
|
||||
@property(nonatomic, copy) NSString *renderItemFuncId;
|
||||
@property(nonatomic, copy) NSString *loadMoreViewId;
|
||||
@property(nonatomic, assign) BOOL loadMore;
|
||||
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
|
||||
@end
|
||||
|
||||
@implementation DoricListNode
|
||||
@@ -250,8 +251,24 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
if (self.didScrollListener) {
|
||||
self.didScrollListener(scrollView);
|
||||
for (DoricDidScrollBlock block in self.didScrollBlocks) {
|
||||
block(scrollView);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableSet<DoricDidScrollBlock> *)didScrollBlocks {
|
||||
if (!_didScrollBlocks) {
|
||||
_didScrollBlocks = [NSMutableSet new];
|
||||
}
|
||||
return _didScrollBlocks;
|
||||
}
|
||||
|
||||
- (void)addDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener {
|
||||
[self.didScrollBlocks addObject:didScrollListener];
|
||||
}
|
||||
|
||||
- (void)removeDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener {
|
||||
[self.didScrollBlocks removeObject:didScrollListener];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -28,5 +28,4 @@
|
||||
@end
|
||||
|
||||
@interface DoricScrollerNode : DoricSuperNode<DoricScrollView *> <DoricScrollableProtocol>
|
||||
@property(nonatomic, strong, nullable) void (^didScrollListener)(UIScrollView *__nonnull scrollView);
|
||||
@end
|
@@ -53,6 +53,7 @@ @interface DoricScrollerNode () <UIScrollViewDelegate>
|
||||
@property(nonatomic, copy) NSString *childViewId;
|
||||
@property(nonatomic, copy) NSString *onScrollFuncId;
|
||||
@property(nonatomic, copy) NSString *onScrollEndFuncId;
|
||||
@property(nonatomic, strong) NSMutableSet <DoricDidScrollBlock> *didScrollBlocks;
|
||||
@end
|
||||
|
||||
@implementation DoricScrollerNode
|
||||
@@ -139,8 +140,8 @@ - (DoricViewNode *)subNodeWithViewId:(NSString *)viewId {
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
if (self.didScrollListener) {
|
||||
self.didScrollListener(scrollView);
|
||||
for (DoricDidScrollBlock block in self.didScrollBlocks) {
|
||||
block(scrollView);
|
||||
}
|
||||
if (self.onScrollFuncId) {
|
||||
[self callJSResponse:self.onScrollFuncId,
|
||||
@@ -192,4 +193,20 @@ - (void)scrollBy:(NSDictionary *)params {
|
||||
MIN(self.view.contentSize.height - self.view.height, MAX(0, offset.y + self.view.contentOffset.y)))
|
||||
animated:animated];
|
||||
}
|
||||
|
||||
- (NSMutableSet<DoricDidScrollBlock> *)didScrollBlocks {
|
||||
if (!_didScrollBlocks) {
|
||||
_didScrollBlocks = [NSMutableSet new];
|
||||
}
|
||||
return _didScrollBlocks;
|
||||
}
|
||||
|
||||
- (void)addDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener {
|
||||
[self.didScrollBlocks addObject:didScrollListener];
|
||||
}
|
||||
|
||||
- (void)removeDidScrollBlock:(__nonnull DoricDidScrollBlock)didScrollListener {
|
||||
[self.didScrollBlocks removeObject:didScrollListener];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user