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.9 KiB

//
// DisturbBanViewController.m
// watch
//
// Created by xTT on 2017/7/12.
// Copyright © 2017年 xTT. All rights reserved.
//
#import "DisturbBanViewController.h"
#import "AddDBViewController.h"
#import "DisturbBan.h"
#import "MyUILabel.h"
#import "VoiceAlarmTableViewCell.h"
@interface DisturbBanViewController ()
@end
@implementation DisturbBanViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.zx_navTitle = @"上课禁用";
// Do any additional setup after loading the view.
self.myTableView.frame = CGRectMake(16, iPhoneX_NavHeight, ScreenWidth-32, ScreenHeight-iPhoneX_NavHeight);
// [self.myTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
// make.top.equalTo(self.view).offset(iPhoneX_NavHeight);
// make.bottom.equalTo(self.view.mas_bottom);
// make.left.right.equalTo(self.view).inset(15);
// }];
self.myTableView.separatorStyle = UITableViewCellSelectionStyleNone;
[self.myTableView registerClass:VoiceAlarmTableViewCell.class forCellReuseIdentifier:NSStringFromClass(VoiceAlarmTableViewCell.class)];
[self zx_setRightBtnWithText:@"添加" clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
[self rightBarItemClick];
}];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
WEAKSELF
[DisturbBan getObjsSuccess:^(NSMutableArray *arr)
{
[weakSelf.myDataSource removeAllObjects];
[weakSelf.myDataSource addObjectsFromArray:arr];
[weakSelf.myTableView reloadData];
// add by lsz
MyUILabel *header = [[MyUILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 60)];
header.font = Font_(12);
header.adjustsFontSizeToFitWidth = YES;
header.numberOfLines = 0;
header.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
[header setTextColor:KKGrey163];
[header setAttributedText:[UICommon labelLinesHeight:@"温馨提示:禁用时设备除可以呼出SOS号码外,设备仅可查看时间,同时拒接所有电话和消息." height:3 align:NSTextAlignmentLeft]];
weakSelf.myTableView.tableHeaderView = header;
} failure:^(NSError *error){
if (!error) {
}
}];
}
- (void)emptyDataSetView
{
[self rightBarItemClick];
}
- (void)rightBarItemClick
{
[UICommon PusXibViewController:[AddDBViewController new] :@"AddDBViewController"];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.myDataSource.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return section == 0 ? 0.1 : 12;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 146;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
DisturbBan *disturbBan = self.myDataSource[indexPath.section];
VoiceAlarmTableViewCell *cell = [VoiceAlarmTableViewCell cellWithTableView:tableView indexPath:indexPath];
cell.disturbBanModel = disturbBan;
cell.BlockBtnClick = ^(UISwitch * _Nonnull sender, id _Nonnull blockCell) {
disturbBan.status = @(sender.on);
[disturbBan saveSuccess:^{
disturbBan.status = @(sender.on);
[self.myTableView reloadData];
} failure:^{
[self.myTableView reloadData];
}];
};
// baseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"baseCell"];
// DisturbBan *disturbBan = self.myDataSource[indexPath.section];
//
// if (!cell) {
// cell = [[baseCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"baseCell"];
// cell.textLabel.font = [myHelper fixFoneSize:20 font:cell.textLabel.font];
// cell.detailTextLabel.font = [myHelper fixFoneSize:15 font:cell.detailTextLabel.font];
//
// UISwitch *uiSwitch = [[UISwitch alloc] init];
// cell.accessoryView = uiSwitch;
// [uiSwitch addTarget:cell
// action:@selector(cellClick:)
// forControlEvents:UIControlEventValueChanged];
//
//
// }
//
// UISwitch *uiSwitch = (UISwitch *)cell.accessoryView;
// uiSwitch.on = [disturbBan.status boolValue];
// cell.textLabel.text = [NSString stringWithFormat:@"%@-%@",disturbBan.starttime,disturbBan.endedtime];
// cell.detailTextLabel.text = [myHelper getWeekDayStr:[disturbBan week]];
// cell.block = ^(UISwitch *uiSwitch, baseCell *blockCell){
// disturbBan.status = @(uiSwitch.on);
// [disturbBan saveSuccess:^{}
// failure:^{
// uiSwitch.on = !uiSwitch.on;
// disturbBan.status = @(uiSwitch.on);
// }];
//
// };
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
DisturbBan *disturbBan = self.myDataSource[indexPath.section];
// [self performSegueWithIdentifier:@"goAddDisturbBanVC" sender:disturbBan];
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
AddDBViewController *vc = [sb instantiateViewControllerWithIdentifier:@"AddDBViewController"];
vc.isAdd = YES;
vc.infoDisturBan = disturbBan;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if (sender) {
[segue.destinationViewController setValue:sender forKey:@"infoDisturBan"];
}
}
@end