CYSpecialCareViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. //
  2. // JXSpecialCareViewController.m
  3. // shiku_im
  4. //
  5. // Created by Ron on 2019/10/29.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "CYSpecialCareViewController.h"
  9. #import "CYMusciTypeViewController.h"
  10. #define HEIGHT 50
  11. //#define IMGSIZE 150
  12. #define TopHeight 7
  13. #define CellHeight 45
  14. @interface CYSpecialCareViewController ()
  15. @property (nonatomic,strong) UIImageView * memberView;
  16. @property (nonatomic,strong) UILabel * musicTypeLabel;
  17. @end
  18. @implementation CYSpecialCareViewController{
  19. UISwitch *_topSwitch;
  20. UISwitch *_tipSwitch;
  21. }
  22. -(void)viewWillAppear:(BOOL)animated{
  23. NSString *musicTypeName = @"默认";
  24. int a =[self.user.veryCareTones intValue];
  25. if ( a == 0) {
  26. musicTypeName = @"默认";
  27. }else if (a == 1){
  28. musicTypeName = @"常用的一个提示音";
  29. }else if (a == 2){
  30. musicTypeName = @"电车报站提示音";
  31. }else if (a == 3){
  32. musicTypeName = @"电脑YY提示音";
  33. }else if (a == 4){
  34. musicTypeName = @"可爱消息音效";
  35. }else if (a == 5){
  36. musicTypeName = @"女生短信提示音";
  37. }else if (a == 6){
  38. musicTypeName = @"苹果line提示音铃声";
  39. }else if (a == 7){
  40. musicTypeName = @"千牛上线提示";
  41. }else if (a == 8){
  42. musicTypeName = @"日本短信提示音";
  43. }else if (a == 9){
  44. musicTypeName = @"问题答错提示音";
  45. }else if (a == 10){
  46. musicTypeName = @"系统提示完成回答正确";
  47. }else if (a == 11){
  48. musicTypeName = @"小新嘿嘿提示音";
  49. }else if (a == 12){
  50. musicTypeName = @"新浪微博刷新的声音";
  51. }else if (a == 13){
  52. musicTypeName = @"选择正确提示音";
  53. }else if (a == 14){
  54. musicTypeName = @"游戏常用的轻快系统提示";
  55. }else if (a == 15){
  56. musicTypeName = @"游戏选择英雄";
  57. }else if (a == 16){
  58. musicTypeName = @"游戏UI提示音";
  59. }else if (a == 17){
  60. musicTypeName = @"Facebook提示音";
  61. }
  62. _musicTypeLabel.text = musicTypeName;
  63. }
  64. - (void)viewDidLoad {
  65. [super viewDidLoad];
  66. // Do any additional setup after loading the view.
  67. self.tableBody.backgroundColor = HEXCOLOR(0xf0eff4);
  68. self.tableBody.backgroundColor = [UIColor colorWithRed:233/255.0 green:233/255.0 blue:233/255.0 alpha:1];
  69. self.isGotoBack = YES;
  70. self.title = @"特别关心好友设置";
  71. self.heightFooter = 0;
  72. self.heightHeader = JX_SCREEN_TOP;
  73. [self createHeadAndFoot];
  74. self.tableBody.scrollEnabled = YES;
  75. self.tableBody.contentSize = CGSizeMake(self_width, JX_SCREEN_HEIGHT - JX_SCREEN_TOP);
  76. self.tableBody.showsVerticalScrollIndicator = YES;
  77. int h = 0;
  78. [_memberView removeFromSuperview];
  79. _memberView = [[UIImageView alloc] initWithFrame:CGRectMake(0, h, JX_SCREEN_WIDTH, self.tableBody.frame.size.height)];
  80. _memberView.userInteractionEnabled = YES;
  81. _memberView.backgroundColor = HEXCOLOR(0xf0eff4);;
  82. [self.tableBody addSubview:_memberView];
  83. UIImageView *iv =[[UIImageView alloc] init];
  84. iv.backgroundColor = HEXCOLOR(0xf0eff4);
  85. BOOL isFlag = YES;
  86. if ([self.user.veryCare intValue] == 0) {
  87. isFlag = NO;
  88. }
  89. iv = [self createButton:@"特别关心" drawTop:YES drawBottom:YES must:NO click:nil superView:_memberView];
  90. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  91. _topSwitch = [[UISwitch alloc] init];
  92. _topSwitch.onTintColor = THEMECOLOR;
  93. _topSwitch.frame = CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 0, 0);
  94. _topSwitch.center = CGPointMake(_topSwitch.center.x, iv.frame.size.height/2);
  95. _topSwitch.on = isFlag;
  96. [_topSwitch addTarget:self action:@selector(topSwitchAction:) forControlEvents:UIControlEventTouchUpInside];
  97. // [_topSwitch setOn:self.user.topTime];
  98. [iv addSubview:_topSwitch];
  99. h+=iv.frame.size.height;
  100. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, h, JX_SCREEN_WIDTH -40, 100)];
  101. label.backgroundColor = [UIColor clearColor];
  102. label.numberOfLines = 0;
  103. label.textColor = UIColor.blackColor;
  104. label.textAlignment = NSTextAlignmentLeft;
  105. label.text = @"开启后,好友将收藏至【特别关心】列表中,好友消息/生活圈将有声音提醒和特别提醒。特别关心的好友消息置顶";
  106. [_memberView addSubview:label];
  107. h+=label.frame.size.height;
  108. // iv = [self createButton:@"好友消息特别提醒" drawTop:YES drawBottom:YES must:NO click:nil superView:_memberView];
  109. // iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  110. // _tipSwitch = [[UISwitch alloc] init];
  111. // _tipSwitch.onTintColor = THEMECOLOR;
  112. // _tipSwitch.frame = CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 0, 0);
  113. // _tipSwitch.center = CGPointMake(_tipSwitch.center.x, iv.frame.size.height/2);
  114. // [_tipSwitch addTarget:self action:@selector(tipSwitchAction:) forControlEvents:UIControlEventTouchUpInside];
  115. // // [_topSwitch setOn:self.user.topTime];
  116. // [iv addSubview:_tipSwitch];
  117. // h+=iv.frame.size.height;
  118. iv = [self createButton:@"特别提示音" drawTop:YES drawBottom:YES must:NO click:@selector(musicTypeClick) superView:_memberView];
  119. iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
  120. NSString *musicTypeName = @"默认";
  121. int a =[self.user.veryCareTones intValue];
  122. if ( a == 0) {
  123. musicTypeName = @"默认";
  124. }else if (a == 1){
  125. musicTypeName = @"常用的一个提示音";
  126. }else if (a == 2){
  127. musicTypeName = @"电车报站提示音";
  128. }else if (a == 3){
  129. musicTypeName = @"电脑YY提示音";
  130. }else if (a == 4){
  131. musicTypeName = @"可爱消息音效";
  132. }else if (a == 5){
  133. musicTypeName = @"女生短信提示音";
  134. }else if (a == 6){
  135. musicTypeName = @"苹果line提示音铃声";
  136. }else if (a == 7){
  137. musicTypeName = @"千牛上线提示";
  138. }else if (a == 8){
  139. musicTypeName = @"日本短信提示音";
  140. }else if (a == 9){
  141. musicTypeName = @"问题答错提示音";
  142. }else if (a == 10){
  143. musicTypeName = @"系统提示完成回答正确";
  144. }else if (a == 11){
  145. musicTypeName = @"小新嘿嘿提示音";
  146. }else if (a == 12){
  147. musicTypeName = @"新浪微博刷新的声音";
  148. }else if (a == 13){
  149. musicTypeName = @"选择正确提示音";
  150. }else if (a == 14){
  151. musicTypeName = @"游戏常用的轻快系统提示";
  152. }else if (a == 15){
  153. musicTypeName = @"游戏选择英雄";
  154. }else if (a == 16){
  155. musicTypeName = @"游戏UI提示音";
  156. }else if (a == 17){
  157. musicTypeName = @"Facebook提示音";
  158. }
  159. _musicTypeLabel = [self createLabel:iv default:musicTypeName];
  160. [iv addSubview:_musicTypeLabel];
  161. h+=iv.frame.size.height;
  162. // CGRect memFrame = _memberView.frame;
  163. // memFrame.size.height = h;
  164. // _memberView.frame = memFrame;
  165. [_memberView addSubview:iv];
  166. // return membHeight;
  167. }
  168. -(void)topSwitchAction:(UISwitch *)send{
  169. // int a = 0;
  170. NSString *a = @"0";
  171. if (_topSwitch.isOn == YES) {
  172. a = @"1";
  173. }
  174. // [g_server getUser:g_server.myself.userId veryCare: veryCareTones:[self.user.veryCareTones intValue] toView:self];
  175. [g_server getUser:self.user.userId veryCare:a veryCareTones:[NSString stringWithFormat:@"%d",[self.user.veryCareTones intValue]] toView:self];
  176. }
  177. -(void)tipSwitchAction:(UISwitch *)send{
  178. }
  179. -(void)musicTypeClick{
  180. CYMusciTypeViewController *vc = [[CYMusciTypeViewController alloc] init];
  181. vc.user = self.user;
  182. vc.userId = self.userId;
  183. [g_navigation pushViewController:vc animated:true];
  184. }
  185. -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click superView:(UIView *)superView{
  186. JXImageView* btn = [[JXImageView alloc] init];
  187. btn.backgroundColor = [UIColor whiteColor];
  188. btn.userInteractionEnabled = YES;
  189. btn.didTouch = click;
  190. btn.delegate = self;
  191. [superView addSubview:btn];
  192. // [btn release];
  193. if(must){
  194. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)];
  195. p.text = @"*";
  196. p.font = g_factory.font18;
  197. p.backgroundColor = [UIColor clearColor];
  198. p.textColor = [UIColor redColor];
  199. p.textAlignment = NSTextAlignmentCenter;
  200. [btn addSubview:p];
  201. // [p release];
  202. }
  203. JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(20, 0, 200, HEIGHT)];
  204. p.text = title;
  205. p.font = g_factory.font15;
  206. p.backgroundColor = [UIColor clearColor];
  207. p.textColor = [UIColor blackColor];
  208. [btn addSubview:p];
  209. // if (@selector(onRemark) == click) {
  210. // _labelLab = p;
  211. // }
  212. if(drawTop){
  213. UIView* line = [[UIView alloc] initWithFrame:CGRectMake(0,0,JX_SCREEN_WIDTH,0.3)];
  214. line.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1];
  215. [btn addSubview:line];
  216. }
  217. if(drawBottom){
  218. UIView* line = [[UIView alloc]initWithFrame:CGRectMake(0,HEIGHT-0.5,JX_SCREEN_WIDTH,0.3)];
  219. line.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1];
  220. [btn addSubview:line];
  221. }
  222. //这个选择器仅用于判断,之后会修改为不可点击
  223. SEL check = @selector(switchAction:);
  224. //创建switch
  225. if(click == check){
  226. UISwitch * switchView = [[UISwitch alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-51, 6, 20, 20)];
  227. if ([title isEqualToString:Localized(@"JX_MessageFree")]) {
  228. // _messageFreeSwitch = switchView;
  229. // if ([user.offlineNoPushMsg intValue] == 1) {
  230. // [_messageFreeSwitch setOn:YES];
  231. // }else {
  232. // [_messageFreeSwitch setOn:NO];
  233. // }
  234. }
  235. switchView.onTintColor = THEMECOLOR;
  236. [switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
  237. [btn addSubview:switchView];
  238. //取消调用switchAction
  239. btn.didTouch = @selector(hideKeyboard);
  240. }else if(click){
  241. btn.frame = CGRectMake(btn.frame.origin.x -20, btn.frame.origin.y, btn.frame.size.width, btn.frame.size.height);
  242. UIImageView* iv;
  243. iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-INSETS-20-3, 15, 20, 20)];
  244. iv.image = [UIImage imageNamed:@"set_list_next"];
  245. [btn addSubview:iv];
  246. // [iv release];
  247. }
  248. return btn;
  249. }
  250. -(UILabel*)createLabel:(UIView*)parent default:(NSString*)s{
  251. UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2,INSETS,JX_SCREEN_WIDTH/2 - INSETS - 20 - 5,HEIGHT-INSETS*2)];
  252. p.userInteractionEnabled = NO;
  253. p.text = s;
  254. p.font = g_factory.font15;
  255. p.textAlignment = NSTextAlignmentRight;
  256. [parent addSubview:p];
  257. // [p release];
  258. return p;
  259. }
  260. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  261. if([aDownload.action isEqualToString:act_FriendsAttention]){
  262. [_wait stop];
  263. int a = 0;
  264. if (_topSwitch.isOn == YES) {
  265. a = 1;
  266. }
  267. self.user.veryCare = [NSNumber numberWithInt:a];
  268. // // 修改备注后实时刷新
  269. [self.user update];
  270. [g_App showAlert:Localized(@"JXAlert_SetOK")];
  271. }
  272. }
  273. /*
  274. #pragma mark - Navigation
  275. // In a storyboard-based application, you will often want to do a little preparation before navigation
  276. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  277. // Get the new view controller using [segue destinationViewController].
  278. // Pass the selected object to the new view controller.
  279. }
  280. */
  281. @end