123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #import "WFCMeTableViewController.h"
- #import <WFChatClient/WFCChatClient.h>
- #import <SDWebImage/SDWebImage.h>
- #import <WFChatUIKit/WFChatUIKit.h>
- #import "WFCSettingTableViewController.h"
- #import "WFCSecurityTableViewController.h"
- #import "WFCMeTableViewHeaderViewCell.h"
- #import "UIColor+YH.h"
- @interface WFCMeTableViewController () <UITableViewDataSource, UITableViewDelegate>
- @property (nonatomic, strong)UITableView *tableView;
- @property (nonatomic, strong)UIImageView *portraitView;
- @property (nonatomic, strong)NSArray *itemDataSource;
- @end
- @implementation WFCMeTableViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
- self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
- self.tableView.backgroundColor = [WFCUConfigManager globalManager].backgroudColor;
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
- self.tableView.tableHeaderView = nil;
- [self.tableView reloadData];
- self.tableView.estimatedRowHeight = 0;
- self.tableView.estimatedSectionHeaderHeight = 0;
- self.tableView.estimatedSectionFooterHeight = 0;
- if ([self.tableView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
-
- }
- }
- [self.view addSubview:self.tableView];
-
- __weak typeof(self)ws = self;
- [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
- if ([[WFCCNetworkService sharedInstance].userId isEqualToString:note.object]) {
- [ws.tableView reloadData];
- }
- }];
-
- self.itemDataSource = @[
- @{@"title":LocalizedString(@"MessageNotification"),
- @"image":@"notification_setting"},
- @{@"title":LocalizedString(@"AccountSafety"),
- @"image":@"safe_setting"},
- @{@"title":LocalizedString(@"Settings"),
- @"image":@"MoreSetting"}
- ];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self.tableView reloadData];
- self.navigationController.navigationBar.hidden = YES;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 4;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- if (section == 0) {
- return 0.01;
- } else {
- return 9;
- }
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- if (section == 0) {
- return nil;
- } else {
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 9)];
- view.backgroundColor = [WFCUConfigManager globalManager].backgroudColor;
- return view;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if(indexPath.section == 0) {
- WFCMeTableViewHeaderViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"profileCell"];
- if (cell == nil) {
- cell = [[WFCMeTableViewHeaderViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"profileCell"];
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- }
-
- WFCCUserInfo *me = [[WFCCIMService sharedWFCIMService] getUserInfo:[WFCCNetworkService sharedInstance].userId refresh:YES];
- cell.userInfo = me;
- cell.backgroundColor = [WFCUConfigManager globalManager].naviBackgroudColor;
- return cell;
- } else {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"styleDefault"];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"styleDefault"];
- }
-
- cell.accessoryType = UITableViewCellAccessoryNone;
- cell.accessoryView = nil;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
-
- cell.textLabel.text = self.itemDataSource[indexPath.section - 1][@"title"];
- cell.imageView.image = [UIImage imageNamed:self.itemDataSource[indexPath.section - 1][@"image"]];
- return cell;
- }
- return nil;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 0) {
- return 154;
- } else {
- return 50;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section == 0) {
- WFCUMyProfileTableViewController *vc = [[WFCUMyProfileTableViewController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- } else if (indexPath.section == 1) {
-
- WFCUMessageNotificationViewController *mnvc = [[WFCUMessageNotificationViewController alloc] init];
- mnvc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:mnvc animated:YES];
- } else if(indexPath.section == 2) {
- WFCSecurityTableViewController * stvc = [[WFCSecurityTableViewController alloc] init];
- stvc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:stvc animated:YES];
- } else {
- WFCSettingTableViewController *vc = [[WFCSettingTableViewController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
-
-
- }
- - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
- view.backgroundColor = [WFCUConfigManager globalManager].backgroudColor;
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- self.navigationController.navigationBar.hidden = NO;
-
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- @end
|