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.

386 lines
14 KiB

2 years ago
//
// DeviceMenuTableViewCell.m
// tongxin
//
// Created by ecell on 2023/7/11.
// Copyright © 2023 xTT. All rights reserved.
//
#import "DeviceMenuTableViewCell.h"
#import "DeviceTabCollectionViewCell.h"
#import "WSLWaterFlowLayout.h"
#import "TimingSwitchVC.h"
#import "CourseViewController.h"
#import "FamilyViewController.h"
#import "PPFriendViewController.h"
#import "NewStepVC.h"
#import "DeviceLoseViewController.h"
#import "WatchDialViewController.h"
#import "ChatViewController.h"
#import "BloodAndOxygenViewController.h"
#import "ContactsViewController.h"
#import "HAndTViewController.h"
#import "jjcdViewController.h"
#import "VIPViewController.h"
#import "StudentInfoViewController.h"
#import "WiFiViewController.h"
#import "ShortMessageListViewController.h"
#import "ApplicationManageViewController.h"
#import "ChatListViewController.h"
#import "WhiteContactViewController.h"
@interface DeviceMenuTableViewCell ()<WSLWaterFlowLayoutDelegate,UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic, assign) WSLWaterFlowLayoutStyle flowLayoutStyle;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic ,weak) UILabel *titleLabel;
@property (nonatomic ,weak) UIView *bgView;
@end
@implementation DeviceMenuTableViewCell
- (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)setChatMsgNum:(NSInteger)chatMsgNum
{
_chatMsgNum = chatMsgNum;
[self.collectionView reloadData];
}
- (void)setImageArr:(NSArray *)ImageArr
{
_ImageArr = ImageArr;
}
- (void)setTitleArr:(NSArray *)TitleArr
{
_TitleArr = TitleArr;
[self.collectionView reloadData];
}
- (void)setTitleStr:(NSString *)titleStr
{
_titleStr = titleStr;
self.titleLabel.text = titleStr;
// [self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
// make.left.right.equalTo(self.bgView);
// if (titleStr.length > 0)
// make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
// else
// make.top.equalTo(self.bgView).offset(5);
// make.bottom.equalTo(self.bgView.mas_bottom);
// }];
}
- (void)subCellView
{
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(14) textColor:KKTextColor text:@"" Radius:0];
self.titleLabel = titleLabel;
[self.contentView addSubview:titleLabel];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self);
make.top.equalTo(self.mas_top).offset(15);
}];
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor];
self.bgView = bgView;
[self.contentView addSubview:bgView];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.mas_left).offset(0);
make.top.equalTo(titleLabel.mas_bottom).offset(10);
make.right.equalTo(self.mas_right).inset(0);
make.bottom.equalTo(self.mas_bottom);
}];
[bgView addSubview:self.collectionView];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(bgView);
make.top.equalTo(bgView).offset(5);
make.bottom.equalTo(bgView.mas_bottom);
}];
}
#pragma mark - Lazy
- (UICollectionView *)collectionView
{
if (!_collectionView) {
WSLWaterFlowLayout *flowLayout = [[WSLWaterFlowLayout alloc] init];
flowLayout.delegate = self;
flowLayout.flowLayoutStyle = self.flowLayoutStyle;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 10, 0, 0) collectionViewLayout:flowLayout];
_collectionView.backgroundColor = KKClearColor;
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.alwaysBounceVertical = YES;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.scrollEnabled = NO;
[_collectionView registerClass:DeviceTabCollectionViewCell.class forCellWithReuseIdentifier:NSStringFromClass(DeviceTabCollectionViewCell.class)];
}
return _collectionView;
}
#pragma mark - WSLWaterFlowLayoutDelegate
//返回每个item大小
- (CGSize)waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake((ScreenWidth-40)/4, (ScreenWidth-40)/4.5);
}
/** 头视图Size */
-(CGSize )waterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout sizeForHeaderViewInSection:(NSInteger)section
{
return CGSizeMake(ScreenWidth, 0.1);
}
/** 列数*/
-(CGFloat)columnCountInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout
{
return 4;
}
/** 列间距*/
-(CGFloat)columnMarginInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout
{
return 0;
}
/** 行间距*/
-(CGFloat)rowMarginInWaterFlowLayout:(WSLWaterFlowLayout *)waterFlowLayout
{
return 0;
}
/** 边缘之间的间距*/
-(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.ImageArr count];
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
DeviceTabCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(DeviceTabCollectionViewCell.class) forIndexPath:indexPath];
cell.imageName = self.ImageArr[indexPath.row];
cell.titleName = self.TitleArr[indexPath.row];
cell.chatMsgNum = self.chatMsgNum;
return cell;
}
//选择了某个cell
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%ld组第%ld个",indexPath.section, indexPath.row);
NSString *title = self.TitleArr[indexPath.row];
if([title isEqualToString:@"家庭成员"] || [title isEqualToString:@"电话本"] || [title isEqualToString:@"管理员"])
{
ContactsViewController *vc = (ContactsViewController *)[UICommon pusXibViewController:@"ContactsViewController"];
vc.viewType = [title isEqualToString:@"电话本"] ? 999 : 888;
}
else if ([title isEqualToString:@"微聊"])
{
ChatListViewController *vc = [[ChatListViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if([title isEqualToString:@"视频通话"])
{
[UICommon pusXibViewController:@"VideoCallViewController"];
}
else if([title isEqualToString:@"设备闹钟"])
{
[UICommon pusXibViewController:@"VoiceAlarmViewController"];
}
else if([title isEqualToString:@"上课禁用"])
{
[UICommon pusXibViewController:@"DisturbBanViewController"];
}
else if([title isEqualToString:@"SOS号码"])
{
[UICommon pusXibViewController:@"SOSViewController"];
}
else if([title isEqualToString:@"定时开关机"])
{
TimingSwitchVC *vc = [TimingSwitchVC new];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"查找设备"])
{
LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"查找设备" message:@"点击查找设备,设备接收到指令,会响铃60秒,按任意键可以取消。若设备处于关机或未联网状态,则无法向设备端发送相关指令" style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) {
[cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opFind":@(1)}
success:^(id responseObject) {
[SVProgressHUD showSuccessWithStatus:@"查找设备成功,等待响铃"];
} failure:^(id faiObject) {
xLog(@"查找设备失败");
[SVProgressHUD showSuccessWithStatus:faiObject[@"msg"]];
}];
} cancelHandler:nil destructiveHandler:nil];
[alertView setMessageFont:[UIFont systemFontOfSize:14]];
[alertView setMessageTextColor:[UIColor systemGrayColor]];
[alertView showAnimated:YES completionHandler:nil];
}
else if([title isEqualToString:@"课程表"])
{
CourseViewController *vc = [[CourseViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"亲情号"])
{
FamilyViewController *vc = [[FamilyViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"好友列表"])
{
PPFriendViewController *vc = [[PPFriendViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if([title isEqualToString:@"计步"])
{
NewStepVC * vc = [NewStepVC new];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"学生资料"])
{
StudentInfoViewController *vc = [[StudentInfoViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[vc setValue:@(NO) forKey:@"isAdd"];
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"设备资料"])
{
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"EditDeviceViewController"];
[vc setValue:@(NO) forKey:@"isAdd"];
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"VIP客服"])
{
VIPViewController *vc = [VIPViewController new];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"设备WIFI"])
{
WiFiViewController * vc = [WiFiViewController new];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"设备监听"])
{
[UICommon pusXibViewController:@"MonitorViewController"];
}
else if ([title isEqualToString:@"应用管理"])
{
ApplicationManageViewController *vc = [[ApplicationManageViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"血压检测"] || [title isEqualToString:@"血氧检测"])
{
BloodAndOxygenViewController *vc = [[BloodAndOxygenViewController alloc] init];
vc.types = [title isEqualToString:@"血压"] ? 888 : 999;
vc.zx_navTitle = title;
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"心率检测"] || [title isEqualToString:@"体温检测"])
{
HAndTViewController *vc = [HAndTViewController new];
vc.type = [title isEqualToString:@"心率检测"] ? 0 : 1;
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"远程拍照"])
{
[UICommon pusXibViewController:@"RemoteCameraViewController"];
}
else if ([title isEqualToString:@"健康码"] || [title isEqualToString:@"核酸码"])
{
jjcdViewController *vc = [jjcdViewController new];
vc.viewType = [title isEqualToString:@"健康码"] ? 888 : 999;
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"手表短信"])
{
ShortMessageListViewController *vc = [[ShortMessageListViewController alloc] init];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"蓝牙防丢"])
{
DeviceLoseViewController *vc = [DeviceLoseViewController new];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"表盘中心"])
{
WatchDialViewController *vc = [WatchDialViewController new];
vc.hidesBottomBarWhenPushed = YES;
[[UICommon currentVC].navigationController pushViewController:vc animated:YES];
}
else if ([title isEqualToString:@"钱包"])
{
}
else if ([title isEqualToString:@"通讯录"])
{
WhiteContactViewController *vc = [[WhiteContactViewController alloc] init];
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