|
|
|
//
|
|
|
|
// AddVAViewController.m
|
|
|
|
// watch
|
|
|
|
//
|
|
|
|
// Created by xTT on 2017/7/15.
|
|
|
|
// Copyright © 2017年 xTT. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "AddVAViewController.h"
|
|
|
|
#import "AddWeekTableViewCell.h"
|
|
|
|
#import "RecordingBtn.h"
|
|
|
|
#import "XHAudioPlayerHelper.h"
|
|
|
|
|
|
|
|
#import "SelectWeekViewController.h"
|
|
|
|
|
|
|
|
@interface AddVAViewController ()
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AddVAViewController
|
|
|
|
|
|
|
|
@synthesize myDataSource = _myDataSource;
|
|
|
|
|
|
|
|
- (NSMutableArray *)myDataSource{
|
|
|
|
if (!_myDataSource) {
|
|
|
|
_myDataSource = [[NSMutableArray alloc] initWithArray:@[@[@"标签"],@[@"时间",@"星期"]]];
|
|
|
|
}
|
|
|
|
return _myDataSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (VoiceAlarm *)infoVoiceAlarm{
|
|
|
|
if (!_infoVoiceAlarm) {
|
|
|
|
_infoVoiceAlarm = [[VoiceAlarm alloc] init];
|
|
|
|
[_infoVoiceAlarm setDefaultValue];
|
|
|
|
}
|
|
|
|
return _infoVoiceAlarm;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
if (!self.isAdd) {
|
|
|
|
self.title = @"添加闹钟";
|
|
|
|
}else{
|
|
|
|
self.title = @"编辑闹钟";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
|
|
|
[self zx_setRightBtnWithText:@"保存" clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
|
|
|
|
[self rightBarItemClick];
|
|
|
|
}];
|
|
|
|
[self.zx_navRightBtn setTitleColor:mainColor forState:0];
|
|
|
|
self.myTableView.frame = CGRectMake(16, iPhoneX_NavHeight, ScreenWidth-32, ScreenHeight-iPhoneX_NavHeight);
|
|
|
|
self.myTableView.separatorStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
|
|
|
|
//注册cell
|
|
|
|
[self.myTableView registerNib:[UINib nibWithNibName:@"AddWeekTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AddWeekTableViewCellID"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated{
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
[[XHAudioPlayerHelper shareInstance] pausePlayingAudio];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)rightBarItemClick
|
|
|
|
{
|
|
|
|
if (self.infoVoiceAlarm.text.length > 8)
|
|
|
|
{
|
|
|
|
[UICommon MessageErrorText:@"标签为8位字符内"];
|
|
|
|
}else{
|
|
|
|
// if (!self.infoVoiceAlarm.id && !self.infoVoiceAlarm.voicePath) {
|
|
|
|
// [UICommon MessageErrorText:@"未录音,请按下录音按钮说话"];
|
|
|
|
// }else{
|
|
|
|
[self.view endEditing:YES];
|
|
|
|
[self.infoVoiceAlarm saveSuccess:^{
|
|
|
|
[self goBack:nil];
|
|
|
|
} failure:^{}];
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
|
|
{
|
|
|
|
return self.myDataSource.count;
|
|
|
|
}
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
return [self.myDataSource[section] count];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
|
|
{
|
|
|
|
return 12;
|
|
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
|
|
|
|
return indexPath.section == 1 && indexPath.row == 1 ? 112 : 55;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
NSString *title = self.myDataSource[indexPath.section][indexPath.row];
|
|
|
|
if ([title isEqualToString:@"星期"])
|
|
|
|
{
|
|
|
|
|
|
|
|
AddWeekTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AddWeekTableViewCellID" forIndexPath:indexPath];
|
|
|
|
UIImageView *line = [UIImageView new];
|
|
|
|
line.backgroundColor = RGB(240, 240, 240);
|
|
|
|
[cell addSubview:line];
|
|
|
|
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.equalTo(cell).inset(15);
|
|
|
|
make.top.equalTo(cell);
|
|
|
|
make.height.mas_equalTo(0.5);
|
|
|
|
}];
|
|
|
|
cell.aTitleLabel.text = title;
|
|
|
|
//cell.textLabel.text = title;
|
|
|
|
// cell.textLabel.font = DefineFontSize;
|
|
|
|
[cell setWeek:self.infoVoiceAlarm.week];
|
|
|
|
WEAKSELF
|
|
|
|
cell.weekSelectBlack = ^(NSString *selectWeek)
|
|
|
|
{
|
|
|
|
weakSelf.infoVoiceAlarm.week = selectWeek;
|
|
|
|
};
|
|
|
|
cell.accessoryType = UITableViewCellAccessoryNone;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"时间"] || [title isEqualToString:@"标签"])
|
|
|
|
{
|
|
|
|
TextFieldCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TextFieldCell"];
|
|
|
|
if (!cell) {
|
|
|
|
cell = [[TextFieldCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"TextFieldCell"];
|
|
|
|
|
|
|
|
}
|
|
|
|
cell.textLabel.text = title;
|
|
|
|
if ([title isEqualToString:@"时间"])
|
|
|
|
{
|
|
|
|
[UICommon ui_uiViewFillet:CGRectMake(0, 0, ScreenWidth-30, 55) Viewdirection:PYUIdirectionTop toView:cell sizeMake:10];
|
|
|
|
NSDateFormatter * df = [[NSDateFormatter alloc]init];
|
|
|
|
[df setDateFormat:@"HH:mm"];
|
|
|
|
[cell timeInputViewWithModel:UIDatePickerModeTime WithData:[df dateFromString:self.infoVoiceAlarm.time]];
|
|
|
|
cell.textField.text = self.infoVoiceAlarm.time;
|
|
|
|
cell.textField.textColor = KKBlack20;
|
|
|
|
cell.textField.tintColor = [UIColor clearColor]; //使光标不可见
|
|
|
|
cell.textField.font = FontBold_(32);
|
|
|
|
cell.accessoryType = UITableViewCellAccessoryNone;
|
|
|
|
[cell.textField mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.right.equalTo(cell.mas_right).inset(20);
|
|
|
|
make.centerY.equalTo(cell);
|
|
|
|
make.size.mas_equalTo(CGSizeMake(150, 40));
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
else if([title isEqualToString:@"标签"])
|
|
|
|
{
|
|
|
|
cell.accessoryType = UITableViewCellAccessoryNone;
|
|
|
|
[UICommon ui_uiViewFillet:CGRectMake(0, 0, ScreenWidth-30, 55) Viewdirection:PYUIdirectionNo toView:cell sizeMake:10];
|
|
|
|
cell.maxLimitLength = 8;
|
|
|
|
cell.textField.textColor = KKBlack20;
|
|
|
|
cell.textField.font = FontBold_(14);
|
|
|
|
cell.textField.textAlignment = NSTextAlignmentRight;
|
|
|
|
cell.textField.text = self.infoVoiceAlarm.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
WEAKSELF
|
|
|
|
cell.block = ^(NSString *text, TextFieldCell *blockCell){
|
|
|
|
if ([title isEqualToString:@"时间"]) {
|
|
|
|
weakSelf.infoVoiceAlarm.time = text;
|
|
|
|
}else if([title isEqualToString:@"标签"]){
|
|
|
|
self.infoVoiceAlarm.text = text;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
// NSString *text = self.myDataSource[indexPath.section][indexPath.row];
|
|
|
|
// if ([text isEqualToString:@"星期"]) {
|
|
|
|
// SelectWeekViewController *vc = [[SelectWeekViewController alloc] init];
|
|
|
|
// vc.model = self.infoVoiceAlarm;
|
|
|
|
// [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.
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
@end
|