// // CYGroupNameRankViewController.m // shiku_im // // Created by Ron on 2019/11/14. // Copyright © 2019 Reese. All rights reserved. // #import "CYGroupNameRankViewController.h" #import "CYActiveTitleViewController.h" #import "JXRoomRemind.h" #define HEIGHT 50 //#define IMGSIZE 150 #define TopHeight 7 #define CellHeight 45 @interface CYGroupNameRankViewController () @property (nonatomic,strong) UIImageView * memberView; @property (nonatomic,strong) UILabel * musicTypeLabel; @end @implementation CYGroupNameRankViewController{ UISwitch *_topSwitch; UISwitch *_tipSwitch; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view.self.isGotoBack = YES; 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); 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.on = _isOpenIntegral; _topSwitch.center = CGPointMake(_topSwitch.center.x, iv.frame.size.height/2); [_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(activeRankClick) superView:_memberView]; iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT); // _musicTypeLabel = [self createLabel:iv default:@"叮咚"]; // [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{ // printf(); // NSLog(@"%lu",(unsigned long)_topSwitch.state); self.room.isOpenIntegral = send.on; [g_server updateRoomShowRead:self.room key:@"isOpenIntegral" value:self.room.isOpenIntegral toView:self] ; } //-(void)tipSwitchAction:(UISwitch *)send{ // // // printf(); // NSLog(@"%lu",(unsigned long)_tipSwitch.state); //} -(void)activeRankClick{ CYActiveTitleViewController *VC =[[CYActiveTitleViewController alloc] init]; VC.room = self.room; [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{ [_wait stop]; if( [aDownload.action isEqualToString:act_roomSet] ){ JXUserObject * user = [[JXUserObject alloc]init]; user = [user getUserById:self.room.roomJid]; user.showRead = [NSNumber numberWithBool:self.room.showRead]; user.showMember = [NSNumber numberWithBool:self.room.showMember]; user.allowSendCard = [NSNumber numberWithBool:self.room.allowSendCard]; user.chatRecordTimeOut = self.room.chatRecordTimeOut; user.talkTime = [NSNumber numberWithLong:self.room.talkTime]; user.allowInviteFriend = [NSNumber numberWithBool:self.room.allowInviteFriend]; user.allowUploadFile = [NSNumber numberWithBool:self.room.allowUploadFile]; user.allowConference = [NSNumber numberWithBool:self.room.allowConference]; user.allowSpeakCourse = [NSNumber numberWithBool:self.room.allowSpeakCourse]; user.isNeedVerify = [NSNumber numberWithBool:self.room.isNeedVerify]; [user update]; JXRoomRemind* p = [[JXRoomRemind alloc] init]; p.objectId = self.room.roomJid; p.type = [NSNumber numberWithInt:kRoomRemind_RoomIsOpenIntegral]; p.content = [NSString stringWithFormat:@"%d",self.room.isOpenIntegral]; [p notify]; [g_App showAlert:Localized(@"JXAlert_UpdateOK")]; } } /* #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