JXCirclePermissionsVC.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // JXCirclePermissionsVC.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/8/27.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXCirclePermissionsVC.h"
  9. #define HEIGHT 56
  10. @interface JXCirclePermissionsVC ()
  11. @end
  12. @implementation JXCirclePermissionsVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.isGotoBack = YES;
  16. self.title = @"设置社交圈权限";
  17. self.heightFooter = 0;
  18. self.heightHeader = JX_SCREEN_TOP;
  19. [self createHeadAndFoot];
  20. self.tableBody.backgroundColor = HEXCOLOR(0xF2F2F2);
  21. [self setupViews];
  22. }
  23. - (void)setupViews {
  24. JXImageView* iv;
  25. CGFloat h = 0;
  26. // 不让他看
  27. iv = [self createButton:[self.user.sex boolValue] ? @"不让他看" : @"不让她看" drawTop:NO drawBottom:NO must:NO click:nil superView:self.tableBody];
  28. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  29. UISwitch *notSee = [[UISwitch alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH -70, 10, 0, 0)];
  30. [notSee addTarget:self action:@selector(notLookHisCircleAndVideo:) forControlEvents:UIControlEventValueChanged];
  31. notSee.tag = 1000;
  32. notSee.onTintColor = THEMECOLOR;
  33. [iv addSubview:notSee];
  34. notSee.on = [self.user.notLetSeeHim boolValue];
  35. h += iv.frame.size.height;
  36. // 不看他
  37. iv = [self createButton:[self.user.sex boolValue] ? @"不看他" : @"不看她" drawTop:YES drawBottom:NO must:NO click:nil superView:self.tableBody];
  38. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  39. UISwitch *see = [[UISwitch alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH -70, 10, 0, 0)];
  40. see.tag = 1001;
  41. see.onTintColor = THEMECOLOR;
  42. [see addTarget:self action:@selector(notLookHisCircleAndVideo:) forControlEvents:UIControlEventValueChanged];
  43. [iv addSubview:see];
  44. see.on = [self.user.notSeeHim boolValue];
  45. }
  46. - (void)notLookHisCircleAndVideo:(UISwitch *)switchButton {
  47. NSNumber *shieldType;
  48. if (switchButton.tag == 1000) {
  49. // 不让他看
  50. shieldType = @1;
  51. self.user.notLetSeeHim = [NSNumber numberWithBool:switchButton.isOn];
  52. }else if (switchButton.tag == 1001) {
  53. // 不看他
  54. shieldType = @-1;
  55. self.user.notSeeHim = [NSNumber numberWithBool:switchButton.isOn];
  56. }
  57. // NSMutableArray *mutArr = g_server.myself.filterCircleUserIds.mutableCopy;
  58. // BOOL haveTheUserId = [g_server.myself.filterCircleUserIds containsObject:[NSNumber numberWithInt:[self.userId intValue]]];
  59. // if (haveTheUserId && !switchButton.isOn) {
  60. // [mutArr removeObject:[NSNumber numberWithInt:[self.userId intValue]]];
  61. // }else if (!haveTheUserId && switchButton.isOn){
  62. // [mutArr addObject:[NSNumber numberWithInt:[self.userId intValue]]];
  63. // }
  64. // g_server.myself.filterCircleUserIds = mutArr;
  65. // 不看他(她)生活圈和视频
  66. [g_server filterUserCircle:self.user.userId shieldType:shieldType type:switchButton.isOn ? @1 : @-1 toView:self];
  67. }
  68. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  69. if([aDownload.action isEqualToString:act_filterUserCircle]){
  70. [_wait stop];
  71. }
  72. }
  73. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  74. [_wait stop];
  75. return show_error;
  76. }
  77. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  78. [_wait stop];
  79. return show_error;
  80. }
  81. -(void) didServerConnectStart:(JXConnection*)aDownload{
  82. [_wait start];
  83. }
  84. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click superView:(UIView *)superView{
  85. JXImageView* btn = [[JXImageView alloc] init];
  86. btn.backgroundColor = [UIColor whiteColor];
  87. btn.userInteractionEnabled = YES;
  88. btn.didTouch = click;
  89. btn.delegate = self;
  90. [superView addSubview:btn];
  91. if(must){
  92. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)];
  93. p.text = @"*";
  94. p.font = g_factory.font18;
  95. p.backgroundColor = [UIColor clearColor];
  96. p.textColor = [UIColor redColor];
  97. p.textAlignment = NSTextAlignmentCenter;
  98. [btn addSubview:p];
  99. }
  100. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(15, 0, 200, HEIGHT)];
  101. p.text = title;
  102. p.font = g_factory.font16;
  103. p.backgroundColor = [UIColor clearColor];
  104. p.textColor = [UIColor blackColor];
  105. [btn addSubview:p];
  106. if(drawTop){
  107. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,0,JX_SCREEN_WIDTH-15,LINE_WH)];
  108. line.backgroundColor = THE_LINE_COLOR;
  109. [btn addSubview:line];
  110. }
  111. if(drawBottom){
  112. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(15,HEIGHT-LINE_WH,JX_SCREEN_WIDTH-15,LINE_WH)];
  113. line.backgroundColor = THE_LINE_COLOR;
  114. [btn addSubview:line];
  115. }
  116. if(click){
  117. btn.frame = CGRectMake(btn.frame.origin.x -20, btn.frame.origin.y, btn.frame.size.width, btn.frame.size.height);
  118. UIImageView* iv;
  119. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
  120. iv.image = [UIImage imageNamed:@"new_icon_>"];
  121. [btn addSubview:iv];
  122. }
  123. return btn;
  124. }
  125. @end