WFCPrivacyTableViewController.m 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // WFCPrivacyTableViewController.h
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/10/6.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCPrivacyTableViewController.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import <WFChatUIKit/WFChatUIKit.h>
  11. @interface WFCPrivacyTableViewController () <UITableViewDataSource, UITableViewDelegate>
  12. @property (nonatomic, strong)UITableView *tableView;
  13. @end
  14. @implementation WFCPrivacyTableViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.view.backgroundColor = [UIColor whiteColor];
  18. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
  19. self.tableView.delegate = self;
  20. self.tableView.dataSource = self;
  21. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  22. [self.tableView reloadData];
  23. [self.view addSubview:self.tableView];
  24. }
  25. - (void)didReceiveMemoryWarning {
  26. [super didReceiveMemoryWarning];
  27. // Dispose of any resources that can be recreated.
  28. }
  29. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  30. return 48;
  31. }
  32. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  33. if (indexPath.section == 0) {
  34. WFCUBlackListViewController *vc = [[WFCUBlackListViewController alloc] init];
  35. [self.navigationController pushViewController:vc animated:YES];
  36. } else if(indexPath.section == 2) {
  37. UIViewController *vc = [[NSClassFromString(@"MomentSettingsTableViewController") alloc] init];
  38. [self.navigationController pushViewController:vc animated:YES];
  39. }
  40. }
  41. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  42. return [[UIView alloc] initWithFrame:CGRectZero];
  43. }
  44. //#pragma mark - Table view data source
  45. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  46. if (NSClassFromString(@"MomentSettingsTableViewController")) {
  47. return 3;
  48. }
  49. return 2;
  50. }
  51. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  52. if (section == 0) {
  53. return 1;
  54. } else if(section == 1) {
  55. return 1;
  56. } else if(section == 2) {
  57. return 1;
  58. }
  59. return 0;
  60. }
  61. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  62. if (indexPath.section == 0 || indexPath.section == 2) {
  63. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"style1Cell"];
  64. if (cell == nil) {
  65. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"style1Cell"];
  66. }
  67. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  68. cell.accessoryView = nil;
  69. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  70. if(indexPath.section == 2) {
  71. cell.textLabel.text = LocalizedString(@"Moments");
  72. } else {
  73. cell.textLabel.text = LocalizedString(@"Blacklist");
  74. }
  75. return cell;;
  76. } else if(indexPath.section == 1) {
  77. WFCUGeneralSwitchTableViewCell *switchCell = [[WFCUGeneralSwitchTableViewCell alloc] init];
  78. switchCell.textLabel.text = LocalizedString(@"MsgReceipt");
  79. if ([[WFCCIMService sharedWFCIMService] isUserEnableReceipt]) {
  80. switchCell.on = YES;
  81. } else {
  82. switchCell.on = NO;
  83. }
  84. __weak typeof(self)ws = self;
  85. [switchCell setOnSwitch:^(BOOL value, void (^result)(BOOL success)) {
  86. [[WFCCIMService sharedWFCIMService] setUserEnableReceipt:value success:^{
  87. result(YES);
  88. } error:^(int error_code) {
  89. [ws.view makeToast:@"网络错误"];
  90. result(NO);
  91. }];
  92. }];
  93. return switchCell;
  94. }
  95. return nil;
  96. }
  97. @end