WFCUProfileMoreTableViewController.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //
  2. // WFCUProfileMoreTableViewController.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/10/22.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUProfileMoreTableViewController.h"
  9. #import <SDWebImage/SDWebImage.h>
  10. #import <WFChatClient/WFCChatClient.h>
  11. #import "WFCUMessageListViewController.h"
  12. #import "MBProgressHUD.h"
  13. #import "WFCUMyPortraitViewController.h"
  14. #import "WFCUVerifyRequestViewController.h"
  15. #import "WFCUGeneralModifyViewController.h"
  16. #import "WFCUVideoViewController.h"
  17. #if WFCU_SUPPORT_VOIP
  18. #import <WFAVEngineKit/WFAVEngineKit.h>
  19. #endif
  20. #import "UIFont+YH.h"
  21. #import "UIColor+YH.h"
  22. #import "WFCUConfigManager.h"
  23. #import "WFCUUserMessageListViewController.h"
  24. #import "WFCUImage.h"
  25. #import "WFCUGroupTableViewController.h"
  26. @interface WFCUProfileMoreTableViewController () <UITableViewDelegate, UITableViewDataSource>
  27. @property (strong, nonatomic)UITableViewCell *commonGroupCell;
  28. @property (nonatomic, strong)UITableView *tableView;
  29. @property (nonatomic, strong)NSMutableArray<UITableViewCell *> *cells;
  30. @property (nonatomic, strong)WFCCUserInfo *userInfo;
  31. @end
  32. @implementation WFCUProfileMoreTableViewController
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. self.title = WFCString(@"More");
  36. self.userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:self.userId refresh:YES];
  37. self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
  38. [self.view addSubview:self.tableView];
  39. self.tableView.backgroundColor = [WFCUConfigManager globalManager].backgroudColor;
  40. self.tableView.delegate = self;
  41. self.tableView.dataSource = self;
  42. if (@available(iOS 15, *)) {
  43. self.tableView.sectionHeaderTopPadding = 0;
  44. }
  45. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0.1)];
  46. [self loadData];
  47. }
  48. - (void)viewWillAppear:(BOOL)animated {
  49. [super viewWillAppear:animated];
  50. UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
  51. keyWindow.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
  52. [keyWindow tintColorDidChange];
  53. }
  54. - (void)viewWillDisappear:(BOOL)animated {
  55. [super viewWillDisappear:animated];
  56. }
  57. - (void)loadData {
  58. self.cells = [[NSMutableArray alloc] init];
  59. if (self.userInfo.mobile.length > 0) {
  60. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
  61. cell.textLabel.text = @"电话";
  62. cell.detailTextLabel.text = self.userInfo.mobile;
  63. [self.cells addObject:cell];
  64. }
  65. if (self.userInfo.email.length > 0) {
  66. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
  67. cell.textLabel.text = @"邮箱";
  68. cell.detailTextLabel.text = self.userInfo.email;
  69. [self.cells addObject:cell];
  70. }
  71. if (self.userInfo.address.length) {
  72. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
  73. cell.textLabel.text = @"地址";
  74. cell.detailTextLabel.text = self.userInfo.address;
  75. [self.cells addObject:cell];
  76. }
  77. if (self.userInfo.company.length) {
  78. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
  79. cell.textLabel.text = @"公司";
  80. cell.detailTextLabel.text = self.userInfo.company;
  81. [self.cells addObject:cell];
  82. }
  83. if (self.userInfo.social.length) {
  84. UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
  85. cell.textLabel.text = @"社交账号";
  86. cell.detailTextLabel.text = self.userInfo.social;
  87. [self.cells addObject:cell];
  88. }
  89. [self.tableView reloadData];
  90. }
  91. - (UITableViewCell *)commonGroupCell {
  92. if(!_commonGroupCell) {
  93. _commonGroupCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"common_group"];
  94. _commonGroupCell.textLabel.text = @"我和他的共同群组";
  95. _commonGroupCell.detailTextLabel.text = [NSString stringWithFormat:@"%ld个", self.commonGroupIds.count];
  96. _commonGroupCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  97. }
  98. return _commonGroupCell;
  99. }
  100. - (void)setCommonGroupIds:(NSArray<NSString *> *)commonGroupIds {
  101. _commonGroupIds = commonGroupIds;
  102. self.commonGroupCell.detailTextLabel.text = [NSString stringWithFormat:@"%ld个", commonGroupIds.count];
  103. }
  104. - (void)didReceiveMemoryWarning {
  105. [super didReceiveMemoryWarning];
  106. // Dispose of any resources that can be recreated.
  107. }
  108. #pragma mark - UITableViewDataSource<NSObject>
  109. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  110. if(section == 0) {
  111. return 1;
  112. }
  113. return self.cells.count;
  114. }
  115. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  116. NSLog(@"section:%ld",(long)indexPath.section);
  117. if (indexPath.section == 0) {
  118. return self.commonGroupCell;
  119. } else {
  120. return self.cells[indexPath.row];
  121. }
  122. }
  123. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  124. if (self.cells.count) {
  125. return 2;
  126. } else {
  127. return 1;
  128. }
  129. }
  130. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  131. if (section != 0) {
  132. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 10)];
  133. view.backgroundColor = [WFCUConfigManager globalManager].backgroudColor;
  134. return view;
  135. } else {
  136. return nil;
  137. }
  138. }
  139. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  140. if (section == 0) {
  141. return 0;
  142. } else {
  143. return 10;
  144. }
  145. }
  146. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  147. return @" ";
  148. }
  149. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  150. if([tableView cellForRowAtIndexPath:indexPath] == self.commonGroupCell) {
  151. WFCUGroupTableViewController *groupsVC = [[WFCUGroupTableViewController alloc] init];
  152. groupsVC.groupIds = self.commonGroupIds;
  153. groupsVC.titleString = @"我和他的共同群组";
  154. [self.navigationController pushViewController:groupsVC animated:YES];
  155. }
  156. }
  157. #pragma mark - UITableViewDelegate
  158. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  159. return 50;
  160. }
  161. @end