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.
81 lines
2.7 KiB
81 lines
2.7 KiB
// |
|
// RailListCell.m |
|
// tongxin |
|
// |
|
// Created by WeiChaoZheng on 2018/8/17. |
|
// Copyright © 2018年 xTT. All rights reserved. |
|
// |
|
|
|
#import "RailListCell.h" |
|
|
|
@implementation RailListCell |
|
|
|
- (void)awakeFromNib { |
|
[super awakeFromNib]; |
|
// Initialization code |
|
self.selectionStyle = UITableViewCellSelectionStyleNone; |
|
self.railRangeLabel.textColor = mainColor; |
|
self.railNameLabel.font = [UIFont systemFontOfSize:13]; |
|
[self.editingBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside]; |
|
[self.delectBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside]; |
|
[self.switchBtn addTarget:self action:@selector(switchBtnAction:) forControlEvents:UIControlEventTouchUpInside]; |
|
self.contentView.backgroundColor = [UIColor clearColor]; |
|
self.backgroundColor = [UIColor clearColor]; |
|
} |
|
-(void)setModel:(Rail *)model{ |
|
_model = model; |
|
self.switchBtn.selected = model.status.boolValue; |
|
[self.switchBtn setTitleColor:mainColor forState:UIControlStateSelected]; |
|
self.railNameLabel.text = model.name; |
|
self.addressLabel.text = model.address; |
|
self.ruleLabel.text = [NSString stringWithFormat:@"%@-%@,%@",model.starttime,model.endedtime,[myHelper getWeekDayStr:model.week]]; |
|
self.railRangeLabel.text = [NSString stringWithFormat:@"安全范围:%@米",model.radius]; |
|
self.railRangeLabel.textColor = mainColor; |
|
|
|
} |
|
|
|
-(void)btnAction:(UIButton*)sender{ |
|
if([sender.titleLabel.text isEqualToString:@"编辑"]){ |
|
if (self.editingBlock) { |
|
self.editingBlock(); |
|
} |
|
}else{ |
|
|
|
WEAKSELF |
|
LGAlertView *alertView = [[LGAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"确定删除【%@】?",self.model.name] style:LGAlertViewStyleAlert buttonTitles:@[@"确定"] cancelButtonTitle:@"取消" destructiveButtonTitle:nil actionHandler:^(LGAlertView *alertView, NSString *title, NSUInteger index) { |
|
//删除 |
|
[weakSelf.model deleteSuccess:^{ |
|
if (weakSelf.deleteBlock) { |
|
weakSelf.deleteBlock(); |
|
} |
|
} failure:^{ |
|
|
|
}]; |
|
} cancelHandler:nil destructiveHandler:nil]; |
|
[alertView showAnimated:YES completionHandler:nil]; |
|
|
|
|
|
} |
|
|
|
} |
|
-(void)switchBtnAction:(UIButton*)sender{ |
|
|
|
self.model.status = @(!sender.selected); |
|
[self.model saveSuccess:^{ |
|
sender.selected = !sender.selected; |
|
if(self.switchBlock){ |
|
self.switchBlock(); |
|
} |
|
} failure:^{ |
|
|
|
}]; |
|
} |
|
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
|
[super setSelected:selected animated:animated]; |
|
|
|
// Configure the view for the selected state |
|
} |
|
|
|
@end
|
|
|