219 lines
6.5 KiB
Objective-C
219 lines
6.5 KiB
Objective-C
//
|
|
// SonNuo128NameViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 2017/6/14.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "SonNuo128NameViewController.h"
|
|
#import "RuSunChangeNameTextViewCell.h"
|
|
#import "SongNuo128Name.h"
|
|
#import "UserExtendataArchaver.h"
|
|
#define SONG128CELL_LIANGHT1 12000
|
|
#define SONG128CELL_LIANGHT2 12001
|
|
#define SONG128CELL_WP 12002
|
|
#define SONG128CELL_AP 12003
|
|
#define SONG128CELL_UV 12004
|
|
#define SONG128CELL_ZL 12005
|
|
#define SONG128CELL_BY 12006
|
|
#define SONG128CELL_JR 12007
|
|
|
|
@interface SonNuo128NameViewController ()
|
|
|
|
@end
|
|
|
|
@implementation SonNuo128NameViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
self.tableView.dataSource = self;
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
if (section==0) {
|
|
|
|
return 1;
|
|
|
|
}else{
|
|
|
|
return 8;
|
|
}
|
|
}
|
|
|
|
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
|
|
return 2;
|
|
}
|
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
if (indexPath.section==0) {
|
|
|
|
return [super baseViewLoadDeviceNameCell:indexPath intable:tableView];
|
|
}
|
|
|
|
RuSunChangeNameTextViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"RuSunChangeNameTextViewCell"];
|
|
if (cell==nil) {
|
|
cell= [[[NSBundle mainBundle]loadNibNamed:@"RuSunChangeNameTextViewCell" owner:self options:nil]lastObject];
|
|
|
|
}
|
|
|
|
//控制原名
|
|
if (indexPath.row==7&&indexPath.section==1) {
|
|
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
|
|
|
|
}
|
|
NSArray *titles= @[@"灯1",@"灯2",@"水泵",@"氧泵",@"UV",@"造浪",@"备用",@"加热棒"];
|
|
if (indexPath.section==1) {
|
|
cell.chTitle.text = titles[indexPath.row];
|
|
}
|
|
|
|
//自定义名字
|
|
SongNuo128Name *name = [UserExtendataArchaver currentSongNuo128:self.device.macAddress];
|
|
if (indexPath.section==1&&indexPath.row==0) {
|
|
cell.chName.text = name.light1;
|
|
|
|
}else if (indexPath.section==1&&indexPath.row==1){
|
|
cell.chName.text = name.light2;
|
|
}else if (indexPath.section==1&&indexPath.row==2){
|
|
cell.chName.text = name.waterPump;
|
|
}else if (indexPath.section==1&&indexPath.row==3){
|
|
cell.chName.text = name.airPump;
|
|
}
|
|
else if (indexPath.section==1&&indexPath.row==4){
|
|
cell.chName.text = name.uVPump;
|
|
}
|
|
else if (indexPath.section==1&&indexPath.row==5){
|
|
cell.chName.text = name.wave;
|
|
}
|
|
else if (indexPath.section==1&&indexPath.row==6){
|
|
cell.chName.text = name.beiYong;
|
|
}
|
|
else if (indexPath.section==1&&indexPath.row==7){
|
|
cell.chName.text = name.jiaRe;
|
|
}
|
|
cell.chName.delegate = self;
|
|
cell.tag = 12000 + indexPath.row;
|
|
return cell;
|
|
}
|
|
|
|
-(void)sureAction
|
|
{
|
|
|
|
|
|
//RunSunCHNameCustom 本地处理 保存按钮名称 不与服务器交互
|
|
SongNuo128Name *songN = [[SongNuo128Name alloc] init];
|
|
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:SONG128CELL_LIANGHT1];
|
|
if (cell1.chName.text.length>3) {
|
|
[self.view makeToast:@"灯1不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell1.chName.text.length==0) {
|
|
[self.view makeToast:@"灯1不能为空"];
|
|
return;
|
|
}
|
|
songN.light1 = cell1.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:SONG128CELL_LIANGHT2];
|
|
if (cell2.chName.text.length>3) {
|
|
[self.view makeToast:@"灯2不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell2.chName.text.length==0) {
|
|
[self.view makeToast:@"灯2不能为空"];
|
|
return;
|
|
}
|
|
songN.light2 = cell2.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:SONG128CELL_WP];
|
|
if (cell3.chName.text.length>3) {
|
|
[self.view makeToast:@"水泵名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell3.chName.text.length==0) {
|
|
[self.view makeToast:@"水泵名不能为空"];
|
|
return;
|
|
}
|
|
songN.waterPump = cell3.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:SONG128CELL_AP];
|
|
if (cell4.chName.text.length>3) {
|
|
[self.view makeToast:@"氧泵名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell4.chName.text.length==0) {
|
|
[self.view makeToast:@"氧泵名不能为空"];
|
|
return;
|
|
}
|
|
songN.airPump = cell4.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:SONG128CELL_UV];
|
|
if (cell5.chName.text.length>3) {
|
|
[self.view makeToast:@"UV灯名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell5.chName.text.length==0) {
|
|
[self.view makeToast:@"UV灯名不能为空"];
|
|
return;
|
|
}
|
|
songN.uVPump = cell5.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell6 = [self.view viewWithTag:SONG128CELL_ZL];
|
|
if (cell6.chName.text.length>3) {
|
|
[self.view makeToast:@"造浪名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell6.chName.text.length==0) {
|
|
[self.view makeToast:@"造浪名不能为空"];
|
|
return;
|
|
}
|
|
songN.wave = cell6.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell7 = [self.view viewWithTag:SONG128CELL_BY];
|
|
if (cell7.chName.text.length>3) {
|
|
[self.view makeToast:@"备用名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell7.chName.text.length==0) {
|
|
[self.view makeToast:@"备用名不能为空"];
|
|
return;
|
|
}
|
|
songN.beiYong = cell7.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell8 = [self.view viewWithTag:SONG128CELL_JR];
|
|
if (cell8.chName.text.length>3) {
|
|
[self.view makeToast:@"加热棒名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell8.chName.text.length==0) {
|
|
[self.view makeToast:@"加热棒名不能为空"];
|
|
return;
|
|
}
|
|
songN.jiaRe = cell8.chName.text;
|
|
|
|
songN.macAddress = self.device.macAddress;
|
|
[UserExtendataArchaver saveSongNuo128Name:songN];
|
|
[self upLoadDeviceName];
|
|
|
|
}
|
|
|
|
/*
|
|
#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.
|
|
}
|
|
*/
|
|
|
|
@end
|