You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
5.6 KiB
171 lines
5.6 KiB
// |
|
// HomeMenuTableViewCell.m |
|
// tongxin |
|
// |
|
// Created by ecell on 2023/6/20. |
|
// Copyright © 2023 xTT. All rights reserved. |
|
// |
|
|
|
#import "HomeMenuTableViewCell.h" |
|
#import "WSLWaterFlowLayout.h" |
|
#import "MenuCollectionViewCell.h" |
|
#import "HAndTViewController.h" |
|
#import "BloodAndOxygenViewController.h" |
|
|
|
@interface HomeMenuTableViewCell ()<WSLWaterFlowLayoutDelegate,UICollectionViewDelegate,UICollectionViewDataSource> |
|
|
|
@property (nonatomic, assign) WSLWaterFlowLayoutStyle flowLayoutStyle; |
|
@property (nonatomic ,strong) UICollectionView *menuCollectionView; |
|
|
|
@end |
|
|
|
@implementation HomeMenuTableViewCell |
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier |
|
{ |
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
|
if (self) |
|
{ |
|
self.selectionStyle = UITableViewCellSelectionStyleNone; |
|
self.backgroundColor = KKClearColor; |
|
[self subCellView]; |
|
} |
|
|
|
return self; |
|
} |
|
|
|
|
|
- (void)setDataModel:(lastDataModel *)dataModel |
|
{ |
|
_dataModel = dataModel; |
|
[self.menuCollectionView reloadData]; |
|
} |
|
|
|
- (void)subCellView |
|
{ |
|
|
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(14) textColor:KKTextColor text:@"健康数据" Radius:0]; |
|
[self.contentView addSubview:titleLabel]; |
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(self.contentView).offset(20); |
|
make.top.equalTo(self.contentView).offset(15); |
|
}]; |
|
|
|
WEAKSELF |
|
WSLWaterFlowLayout *FlowLayout = [[WSLWaterFlowLayout alloc] init]; |
|
FlowLayout.delegate = self; |
|
FlowLayout.flowLayoutStyle = self.flowLayoutStyle; |
|
|
|
_menuCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 5, ScreenWidth-30, 300) collectionViewLayout:FlowLayout]; |
|
_menuCollectionView.backgroundColor = KKClearColor; |
|
_menuCollectionView.dataSource = self; |
|
_menuCollectionView.delegate = self; |
|
// _menuCollectionView.showsVerticalScrollIndicator = NO; |
|
// _menuCollectionView.alwaysBounceVertical = NO; |
|
// _menuCollectionView.scrollEnabled = NO; |
|
if (@available(iOS 11.0, *)) |
|
_menuCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; |
|
[_menuCollectionView registerClass:MenuCollectionViewCell.class forCellWithReuseIdentifier:NSStringFromClass(MenuCollectionViewCell.class)]; |
|
[self.contentView addSubview:_menuCollectionView]; |
|
[_menuCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.contentView).inset(15); |
|
make.top.equalTo(titleLabel.mas_bottom).offset(5); |
|
make.bottom.equalTo(self.contentView.mas_bottom); |
|
}]; |
|
} |
|
|
|
#pragma mark - WSLWaterFlowLayoutDelegate |
|
//返回每个item大小 |
|
- (CGSize)waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
return CGSizeMake((ScreenWidth-45)/2, (ScreenWidth-45)/2); |
|
} |
|
|
|
/** 头视图Size */ |
|
-(CGSize )waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForHeaderViewInSection:(NSInteger)section |
|
{ |
|
return CGSizeMake(ScreenWidth, 0); |
|
} |
|
/** 列数*/ |
|
-(CGFloat)columnCountInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout |
|
{ |
|
return 2; |
|
} |
|
|
|
/** 列间距*/ |
|
-(CGFloat)columnMarginInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout |
|
{ |
|
return 15; |
|
} |
|
/** 行间距*/ |
|
-(CGFloat)rowMarginInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout |
|
{ |
|
return 15; |
|
} |
|
/** 边缘之间的间距*/ |
|
-(UIEdgeInsets)edgeInsetInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout |
|
{ |
|
return UIEdgeInsetsMake(0, 0, 0, 0); |
|
} |
|
|
|
#pragma mark - UICollectionView数据源 |
|
//组个数 |
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView |
|
{ |
|
|
|
return 1; |
|
} |
|
|
|
//组内成员个数 |
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section |
|
{ |
|
return self.modelTitleArr.count; |
|
} |
|
|
|
//设置元素内容 |
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
MenuCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(MenuCollectionViewCell.class) forIndexPath:indexPath]; |
|
cell.titleStr = self.modelTitleArr[indexPath.row]; |
|
cell.imageStr = self.modelImageArr[indexPath.row]; |
|
cell.dataModel = self.dataModel; |
|
return cell; |
|
} |
|
|
|
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
NSString *titleStr = self.modelTitleArr[indexPath.row]; |
|
if ([titleStr isEqualToString:@"心率"] || [titleStr isEqualToString:@"体温"]) |
|
{ |
|
HAndTViewController *vc = [HAndTViewController new]; |
|
vc.type = [titleStr isEqualToString:@"心率"] ? 0 : 1; |
|
vc.hidesBottomBarWhenPushed = YES; |
|
[[UICommon currentVC].navigationController pushViewController:vc animated:YES]; |
|
} |
|
else if ([titleStr isEqualToString:@"睡眠"]) |
|
{ |
|
|
|
} |
|
else if ([titleStr isEqualToString:@"血压"] || [titleStr isEqualToString:@"血氧"]) |
|
{ |
|
BloodAndOxygenViewController *vc = [[BloodAndOxygenViewController alloc] init]; |
|
vc.types = [titleStr isEqualToString:@"血压"] ? 888 : 999; |
|
vc.zx_navTitle = titleStr; |
|
vc.hidesBottomBarWhenPushed = YES; |
|
[[UICommon currentVC].navigationController pushViewController:vc animated:YES]; |
|
} |
|
} |
|
|
|
- (void)awakeFromNib { |
|
[super awakeFromNib]; |
|
// Initialization code |
|
} |
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
|
[super setSelected:selected animated:animated]; |
|
|
|
// Configure the view for the selected state |
|
} |
|
|
|
@end
|
|
|