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.
234 lines
11 KiB
234 lines
11 KiB
// |
|
// MoreCollectionTableViewCell.m |
|
// tongxin |
|
// |
|
// Created by WeiChaoZheng on 2018/10/11. |
|
// Copyright © 2018年 xTT. All rights reserved. |
|
// |
|
|
|
#import "MoreCollectionTableViewCell.h" |
|
#import "WatchFunctionCell.h" |
|
#import "WatchHomeViewController.h" |
|
#import "WiFiViewController.h" |
|
#import "RedFlowerSetVC.h" |
|
#import "TimingSwitchVC.h" |
|
#import "NewStepVC.h" |
|
#import "FamilyViewController.h" |
|
#import "WhiteContactViewController.h" |
|
#import "StudentInfoViewController.h" |
|
#import "CourseViewController.h" |
|
#import "jjcdViewController.h" |
|
#import "DeviceLoseViewController.h" |
|
#import "VIPViewController.h" |
|
#import "WatchDialViewController.h" |
|
|
|
@interface MoreCollectionTableViewCell () <UICollectionViewDelegateFlowLayout,UICollectionViewDataSource> |
|
@property (nonatomic, strong) NSArray * myDataTitleImageArr; |
|
@property (nonatomic, strong) NSArray * myDataSource; |
|
@end |
|
|
|
@implementation MoreCollectionTableViewCell |
|
- (NSArray *)myDataSource{ |
|
if (!_myDataSource) { |
|
_myDataSource = @[ |
|
@"电话本", |
|
@"监听设备", |
|
@"设备闹钟", |
|
@"上课禁用", |
|
@"远程拍照", |
|
@"SOS号码", |
|
@"计步", |
|
@"设备资料" |
|
]; |
|
} |
|
return _myDataSource; |
|
} |
|
- (NSArray *)myDataTitleImageArr{ |
|
if (!_myDataTitleImageArr) { |
|
_myDataTitleImageArr = @[ |
|
@"icon_phonebook", |
|
@"icon_monitor", |
|
@"icon_alarm", |
|
@"icon_disabled", |
|
@"icon_photography", |
|
@"icon_sosnumber", |
|
@"icon_Pedometer", |
|
@"icon_more_watch_data" |
|
]; |
|
} |
|
return _myDataTitleImageArr; |
|
} |
|
|
|
- (void)awakeFromNib { |
|
[super awakeFromNib]; |
|
self.contentView.backgroundColor = [UIColor clearColor]; |
|
self.backgroundColor = [UIColor clearColor]; |
|
[self setSelectionStyle:UITableViewCellSelectionStyleNone]; |
|
self.funcCollectionView.delaysContentTouches = false; |
|
self.funcCollectionView.contentSize = CGSizeMake(ScreenWidth, 0); |
|
self.funcCollectionView.delegate = self; |
|
self.funcCollectionView.dataSource = self; |
|
[self.funcCollectionView registerNib:[UINib nibWithNibName:@"WatchFunctionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"WatchFunctionCell"]; |
|
self.funcCollectionView.layer.cornerRadius = 5; |
|
self.funcCollectionView.layer.masksToBounds = YES; |
|
} |
|
|
|
-(void)setFuncArrTitles:(NSArray*)funcArrTitles TitleImage:(NSArray*)array{ |
|
self.myDataSource = funcArrTitles; |
|
self.myDataTitleImageArr = array; |
|
|
|
} |
|
|
|
#pragma collectionView |
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section |
|
{ |
|
// 功能列表 |
|
return self.myDataSource.count; |
|
} |
|
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
|
|
// 功能的 collection |
|
WatchFunctionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WatchFunctionCell" |
|
forIndexPath:indexPath]; |
|
NSString *BtnImageUrl = self.myDataTitleImageArr[indexPath.item]; |
|
[cell.watchFunctionImgView setImage:[UIImage imageNamed:BtnImageUrl]]; |
|
cell.watchFunctionLabel.text = self.myDataSource[indexPath.item]; |
|
cell.watchFunctionCornerMark.font = [UIFont systemFontOfSize:15]; |
|
[cell.watchFunctionCornerMark setBackgroundColor:[UIColor redColor]]; |
|
[cell.watchFunctionCornerMark setHidden: YES]; |
|
return cell; |
|
|
|
|
|
} |
|
|
|
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
return (CGSize){((SWIDTH-12*2)/ 4.0), (SWIDTH-3)/ 4}; |
|
} |
|
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{ |
|
return UIEdgeInsetsMake(0, 0, 0, 0); |
|
} |
|
//设置水平间距 (同一行的cell的左右间距) |
|
|
|
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { |
|
|
|
return 0; |
|
|
|
} |
|
//垂直间距 (同一列cell上下间距) |
|
|
|
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ |
|
|
|
NSString *title = self.myDataSource[indexPath.item]; |
|
if([title isEqualToString:@"电话本"] || [title isEqualToString:@"管理员"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goContactsVC" sender:nil]; |
|
}else if([title isEqualToString:@"监听设备"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goMonitorVC" sender:nil]; |
|
}else if([title isEqualToString:@"设备闹钟"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goVoiceAlarmVC" sender:nil]; |
|
}else if([title isEqualToString:@"上课禁用"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goDisturbBanVC" sender:nil]; |
|
}else if([title isEqualToString:@"SOS号码"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goSOSVC" sender:nil]; |
|
}else if([title isEqualToString:@"设备资料"]){ |
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; |
|
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"EditDeviceViewController"]; |
|
[vc setValue:@(NO) forKey:@"isAdd"]; |
|
[[self getViewController].navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"远程拍照"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goRemoteCameraVC" sender:nil]; |
|
}else if([title isEqualToString:@"计步"]){ |
|
// [[self getViewController] performSegueWithIdentifier:@"goStepVC" sender:nil]; |
|
NewStepVC * vc = [NewStepVC new]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"视频通话"]){ |
|
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]]; |
|
UIViewController *vc =[sb instantiateViewControllerWithIdentifier:@"VideoCallViewController"]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"设备WIFI"]){ |
|
WiFiViewController * vc = [WiFiViewController new]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if ([title isEqualToString:@"爱心奖励"]){ |
|
RedFlowerSetVC *vc = [RedFlowerSetVC new]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if ([title isEqualToString:@"话费流量"]){ |
|
[[self getViewController] performSegueWithIdentifier:@"goQueryCall" sender:nil]; |
|
}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) { |
|
[UICommon MessageSuccessText:@"查找设备成功,等待响铃" isImg:YES]; |
|
} failure:^(id faiObject) { |
|
xLog(@"查找设备失败"); |
|
}]; |
|
|
|
} cancelHandler:nil destructiveHandler:nil]; |
|
[alertView setMessageFont:[UIFont systemFontOfSize:14]]; |
|
[alertView setMessageTextColor:[UIColor systemGrayColor]]; |
|
[alertView showAnimated:YES completionHandler:nil]; |
|
|
|
}else if([title isEqualToString:@"定时开关机"]){ |
|
TimingSwitchVC *vc = [TimingSwitchVC new]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"亲情号"]) { |
|
FamilyViewController *vc = [[FamilyViewController alloc] init]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"通讯录"]){ |
|
WhiteContactViewController *vc = [[WhiteContactViewController alloc] init]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"学生资料"]){ |
|
StudentInfoViewController *vc = [[StudentInfoViewController alloc] init]; |
|
[vc setValue:@(NO) forKey:@"isAdd"]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
}else if([title isEqualToString:@"课程表"]){ |
|
CourseViewController *vc = [[CourseViewController alloc] init]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
} |
|
else if([title isEqualToString:@"亲情号"]) |
|
{ |
|
FamilyViewController *vc = [[FamilyViewController alloc] init]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
} |
|
else if([title isEqualToString:@"分享图片"]) |
|
{ |
|
jjcdViewController *vc = [jjcdViewController new]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
} |
|
else if([title isEqualToString:@"设备防丢"]) |
|
{ |
|
DeviceLoseViewController *vc = [[DeviceLoseViewController alloc] init]; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
} |
|
else if ([title isEqualToString:@"VIP客服"]) |
|
{ |
|
VIPViewController *vc = [[VIPViewController alloc] init]; |
|
//vc.view.backgroundColor = UIColor.whiteColor; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
} |
|
else if ([title isEqualToString:@"表盘中心"]) |
|
{ |
|
WatchDialViewController *vc = [[WatchDialViewController alloc] init]; |
|
//vc.view.backgroundColor = UIColor.whiteColor; |
|
[self.getViewController.navigationController pushViewController:vc animated:YES]; |
|
} |
|
} |
|
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
|
[super setSelected:selected animated:animated]; |
|
|
|
// Configure the view for the selected state |
|
} |
|
|
|
@end
|
|
|