feat:List and slider support wrap content in iOS
This commit is contained in:
parent
06f2a0b106
commit
f2d2c96619
@ -29,6 +29,23 @@ @interface DoricTableViewCell : UITableViewCell
|
|||||||
@implementation DoricTableViewCell
|
@implementation DoricTableViewCell
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface DoricTableView : UITableView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DoricTableView
|
||||||
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
|
if (self.subviews.count > 0) {
|
||||||
|
CGFloat width = size.width;
|
||||||
|
for (UIView *child in self.subviews) {
|
||||||
|
width = MAX(child.width, width);
|
||||||
|
}
|
||||||
|
return CGSizeMake(width, size.width);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
|
@interface DoricListNode () <UITableViewDataSource, UITableViewDelegate>
|
||||||
@property(nonatomic, strong) NSMutableDictionary <NSNumber *, NSString *> *itemViewIds;
|
@property(nonatomic, strong) NSMutableDictionary <NSNumber *, NSString *> *itemViewIds;
|
||||||
@property(nonatomic, strong) NSMutableDictionary <NSNumber *, NSNumber *> *itemHeights;
|
@property(nonatomic, strong) NSMutableDictionary <NSNumber *, NSNumber *> *itemHeights;
|
||||||
@ -47,7 +64,7 @@ - (instancetype)initWithContext:(DoricContext *)doricContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (UITableView *)build {
|
- (UITableView *)build {
|
||||||
return [[UITableView new] also:^(UITableView *it) {
|
return [[DoricTableView new] also:^(UITableView *it) {
|
||||||
it.dataSource = self;
|
it.dataSource = self;
|
||||||
it.delegate = self;
|
it.delegate = self;
|
||||||
it.separatorStyle = UITableViewCellSeparatorStyleNone;
|
it.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||||
|
@ -37,6 +37,22 @@ @interface DoricSliderNode () <UICollectionViewDataSource, UICollectionViewDeleg
|
|||||||
@property(nonatomic, assign) NSUInteger batchCount;
|
@property(nonatomic, assign) NSUInteger batchCount;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface DoricCollectionView : UICollectionView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation DoricCollectionView
|
||||||
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
|
if (self.subviews.count > 0) {
|
||||||
|
CGFloat height = size.height;
|
||||||
|
for (UIView *child in self.subviews) {
|
||||||
|
height = MAX(child.height, height);
|
||||||
|
}
|
||||||
|
return CGSizeMake(height, size.height);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation DoricSliderNode
|
@implementation DoricSliderNode
|
||||||
- (instancetype)initWithContext:(DoricContext *)doricContext {
|
- (instancetype)initWithContext:(DoricContext *)doricContext {
|
||||||
if (self = [super initWithContext:doricContext]) {
|
if (self = [super initWithContext:doricContext]) {
|
||||||
@ -50,8 +66,8 @@ - (UICollectionView *)build {
|
|||||||
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||||||
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
|
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
|
||||||
|
|
||||||
return [[[UICollectionView alloc] initWithFrame:CGRectZero
|
return [[[DoricCollectionView alloc] initWithFrame:CGRectZero
|
||||||
collectionViewLayout:flowLayout]
|
collectionViewLayout:flowLayout]
|
||||||
also:^(UICollectionView *it) {
|
also:^(UICollectionView *it) {
|
||||||
it.backgroundColor = [UIColor whiteColor];
|
it.backgroundColor = [UIColor whiteColor];
|
||||||
it.delegate = self;
|
it.delegate = self;
|
||||||
@ -165,4 +181,4 @@ - (void)blendSubNode:(NSDictionary *)subModel {
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
Reference in New Issue
Block a user