// // JXSpecialCareViewController.m // shiku_im // // Created by Ron on 2019/10/29. // Copyright © 2019 Reese. All rights reserved. // #import "CYSpecialCareViewController.h" #import "CYMusciTypeViewController.h" #define HEIGHT 50 //#define IMGSIZE 150 #define TopHeight 7 #define CellHeight 45 @interface CYSpecialCareViewController () @property (nonatomic,strong) UIImageView * memberView; @property (nonatomic,strong) UILabel * musicTypeLabel; @end @implementation CYSpecialCareViewController{ UISwitch *_topSwitch; UISwitch *_tipSwitch; } -(void)viewWillAppear:(BOOL)animated{ NSString *musicTypeName = @"默认"; int a =[self.user.veryCareTones intValue]; if ( a == 0) { musicTypeName = @"默认"; }else if (a == 1){ musicTypeName = @"常用的一个提示音"; }else if (a == 2){ musicTypeName = @"电车报站提示音"; }else if (a == 3){ musicTypeName = @"电脑YY提示音"; }else if (a == 4){ musicTypeName = @"可爱消息音效"; }else if (a == 5){ musicTypeName = @"女生短信提示音"; }else if (a == 6){ musicTypeName = @"苹果line提示音铃声"; }else if (a == 7){ musicTypeName = @"千牛上线提示"; }else if (a == 8){ musicTypeName = @"日本短信提示音"; }else if (a == 9){ musicTypeName = @"问题答错提示音"; }else if (a == 10){ musicTypeName = @"系统提示完成回答正确"; }else if (a == 11){ musicTypeName = @"小新嘿嘿提示音"; }else if (a == 12){ musicTypeName = @"新浪微博刷新的声音"; }else if (a == 13){ musicTypeName = @"选择正确提示音"; }else if (a == 14){ musicTypeName = @"游戏常用的轻快系统提示"; }else if (a == 15){ musicTypeName = @"游戏选择英雄"; }else if (a == 16){ musicTypeName = @"游戏UI提示音"; }else if (a == 17){ musicTypeName = @"Facebook提示音"; } _musicTypeLabel.text = musicTypeName; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.tableBody.backgroundColor = HEXCOLOR(0xf0eff4); self.tableBody.backgroundColor = [UIColor colorWithRed:233/255.0 green:233/255.0 blue:233/255.0 alpha:1]; self.isGotoBack = YES; self.title = @"特别关心好友设置"; self.heightFooter = 0; self.heightHeader = JX_SCREEN_TOP; [self createHeadAndFoot]; self.tableBody.scrollEnabled = YES; self.tableBody.contentSize = CGSizeMake(self_width, JX_SCREEN_HEIGHT - JX_SCREEN_TOP); self.tableBody.showsVerticalScrollIndicator = YES; int h = 0; [_memberView removeFromSuperview]; _memberView = [[UIImageView alloc] initWithFrame:CGRectMake(0, h, JX_SCREEN_WIDTH, self.tableBody.frame.size.height)]; _memberView.userInteractionEnabled = YES; _memberView.backgroundColor = HEXCOLOR(0xf0eff4);; [self.tableBody addSubview:_memberView]; UIImageView *iv =[[UIImageView alloc] init]; iv.backgroundColor = HEXCOLOR(0xf0eff4); BOOL isFlag = YES; if ([self.user.veryCare intValue] == 0) { isFlag = NO; } iv = [self createButton:@"特别关心" drawTop:YES drawBottom:YES must:NO click:nil superView:_memberView]; iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT); _topSwitch = [[UISwitch alloc] init]; _topSwitch.onTintColor = THEMECOLOR; _topSwitch.frame = CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 0, 0); _topSwitch.center = CGPointMake(_topSwitch.center.x, iv.frame.size.height/2); _topSwitch.on = isFlag; [_topSwitch addTarget:self action:@selector(topSwitchAction:) forControlEvents:UIControlEventTouchUpInside]; // [_topSwitch setOn:self.user.topTime]; [iv addSubview:_topSwitch]; h+=iv.frame.size.height; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, h, JX_SCREEN_WIDTH -40, 100)]; label.backgroundColor = [UIColor clearColor]; label.numberOfLines = 0; label.textColor = UIColor.blackColor; label.textAlignment = NSTextAlignmentLeft; label.text = @"开启后,好友将收藏至【特别关心】列表中,好友消息/生活圈将有声音提醒和特别提醒。特别关心的好友消息置顶"; [_memberView addSubview:label]; h+=label.frame.size.height; // iv = [self createButton:@"好友消息特别提醒" drawTop:YES drawBottom:YES must:NO click:nil superView:_memberView]; // iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT); // _tipSwitch = [[UISwitch alloc] init]; // _tipSwitch.onTintColor = THEMECOLOR; // _tipSwitch.frame = CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 0, 0); // _tipSwitch.center = CGPointMake(_tipSwitch.center.x, iv.frame.size.height/2); // [_tipSwitch addTarget:self action:@selector(tipSwitchAction:) forControlEvents:UIControlEventTouchUpInside]; // // [_topSwitch setOn:self.user.topTime]; // [iv addSubview:_tipSwitch]; // h+=iv.frame.size.height; iv = [self createButton:@"特别提示音" drawTop:YES drawBottom:YES must:NO click:@selector(musicTypeClick) superView:_memberView]; iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT); NSString *musicTypeName = @"默认"; int a =[self.user.veryCareTones intValue]; if ( a == 0) { musicTypeName = @"默认"; }else if (a == 1){ musicTypeName = @"常用的一个提示音"; }else if (a == 2){ musicTypeName = @"电车报站提示音"; }else if (a == 3){ musicTypeName = @"电脑YY提示音"; }else if (a == 4){ musicTypeName = @"可爱消息音效"; }else if (a == 5){ musicTypeName = @"女生短信提示音"; }else if (a == 6){ musicTypeName = @"苹果line提示音铃声"; }else if (a == 7){ musicTypeName = @"千牛上线提示"; }else if (a == 8){ musicTypeName = @"日本短信提示音"; }else if (a == 9){ musicTypeName = @"问题答错提示音"; }else if (a == 10){ musicTypeName = @"系统提示完成回答正确"; }else if (a == 11){ musicTypeName = @"小新嘿嘿提示音"; }else if (a == 12){ musicTypeName = @"新浪微博刷新的声音"; }else if (a == 13){ musicTypeName = @"选择正确提示音"; }else if (a == 14){ musicTypeName = @"游戏常用的轻快系统提示"; }else if (a == 15){ musicTypeName = @"游戏选择英雄"; }else if (a == 16){ musicTypeName = @"游戏UI提示音"; }else if (a == 17){ musicTypeName = @"Facebook提示音"; } _musicTypeLabel = [self createLabel:iv default:musicTypeName]; [iv addSubview:_musicTypeLabel]; h+=iv.frame.size.height; // CGRect memFrame = _memberView.frame; // memFrame.size.height = h; // _memberView.frame = memFrame; [_memberView addSubview:iv]; // return membHeight; } -(void)topSwitchAction:(UISwitch *)send{ // int a = 0; NSString *a = @"0"; if (_topSwitch.isOn == YES) { a = @"1"; } // [g_server getUser:g_server.myself.userId veryCare: veryCareTones:[self.user.veryCareTones intValue] toView:self]; [g_server getUser:self.user.userId veryCare:a veryCareTones:[NSString stringWithFormat:@"%d",[self.user.veryCareTones intValue]] toView:self]; } -(void)tipSwitchAction:(UISwitch *)send{ } -(void)musicTypeClick{ CYMusciTypeViewController *vc = [[CYMusciTypeViewController alloc] init]; vc.user = self.user; vc.userId = self.userId; [g_navigation pushViewController:vc animated:true]; } -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click superView:(UIView *)superView{ JXImageView* btn = [[JXImageView alloc] init]; btn.backgroundColor = [UIColor whiteColor]; btn.userInteractionEnabled = YES; btn.didTouch = click; btn.delegate = self; [superView addSubview:btn]; // [btn release]; if(must){ UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)]; p.text = @"*"; p.font = g_factory.font18; p.backgroundColor = [UIColor clearColor]; p.textColor = [UIColor redColor]; p.textAlignment = NSTextAlignmentCenter; [btn addSubview:p]; // [p release]; } JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(20, 0, 200, HEIGHT)]; p.text = title; p.font = g_factory.font15; p.backgroundColor = [UIColor clearColor]; p.textColor = [UIColor blackColor]; [btn addSubview:p]; // if (@selector(onRemark) == click) { // _labelLab = p; // } if(drawTop){ UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH,0.3)]; line.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1]; [btn addSubview:line]; } if(drawBottom){ UIView* line = [[UIView alloc]initWithFrame:CGRectMake(0,HEIGHT-0.5,JX_SCREEN_WIDTH,0.3)]; line.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1]; [btn addSubview:line]; } //这个选择器仅用于判断,之后会修改为不可点击 SEL check = @selector(switchAction:); //创建switch if(click == check){ UISwitch * switchView = [[UISwitch alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 20, 20)]; if ([title isEqualToString:Localized(@"JX_MessageFree")]) { // _messageFreeSwitch = switchView; // if ([user.offlineNoPushMsg intValue] == 1) { // [_messageFreeSwitch setOn:YES]; // }else { // [_messageFreeSwitch setOn:NO]; // } } switchView.onTintColor = THEMECOLOR; [switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside]; [btn addSubview:switchView]; //取消调用switchAction btn.didTouch = @selector(hideKeyboard); }else if(click){ btn.frame = CGRectMake(btn.frame.origin.x -20, btn.frame.origin.y, btn.frame.size.width, btn.frame.size.height); UIImageView* iv; iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-20-3, 15, 20, 20)]; iv.image = [UIImage imageNamed:@"set_list_next"]; [btn addSubview:iv]; // [iv release]; } return btn; } -(UILabel*)createLabel:(UIView*)parent default:(NSString*)s{ UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/2 - INSETS - 20 - 5,HEIGHT-INSETS*2)]; p.userInteractionEnabled = NO; p.text = s; p.font = g_factory.font15; p.textAlignment = NSTextAlignmentRight; [parent addSubview:p]; // [p release]; return p; } -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{ if([aDownload.action isEqualToString:act_FriendsAttention]){ [_wait stop]; int a = 0; if (_topSwitch.isOn == YES) { a = 1; } self.user.veryCare = [NSNumber numberWithInt:a]; // // 修改备注后实时刷新 [self.user update]; [g_App showAlert:Localized(@"JXAlert_SetOK")]; } } /* #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