// // My_CenterVC.m // smartRhino // // Created by armin on 2019/11/1. // Copyright © 2019 tederen. All rights reserved. // #import "My_CenterVC.h" #import "My_CenterCell.h" #import "MyInfoVC.h" #import "SettingVC.h" #import "FavoritesViewController.h" #import "MyFavoriteVC.h" #import "NoteBookVC.h" @interface My_CenterVC () @property (strong,nonatomic) IBOutlet UITableView *tableView; @end @implementation My_CenterVC - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; self.view.backgroundColor = RGB(240, 239, 244); if (@available(iOS 11.0, *)) { self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } else { self.automaticallyAdjustsScrollViewInsets = NO; } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PushSettingVC:) name:DRAWERPUSHVC object:nil]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0; [UserManager getUserInfoDetail]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.tableView reloadData]; } - (BOOL)hidesBottomBarWhenPushed { return NO; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ switch (section) { case 0:{ return 1; }break; case 1:{ return 3; }break; default:break; } return 0; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ switch (indexPath.section) { case 0:{ return [My_CenterCell configCell0Height]; }break; case 1:{ return [My_CenterCell configCell1Height]; }break; default:break; } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ switch (indexPath.section) { case 0:{ My_CenterCell *cell = [My_CenterCell configCell0:tableView indexPath:indexPath]; [cell.cell0UserImgView sd_setImageWithURL:[NSURL URLWithString:[AppUserModel sharedAppUserModel].AvatarUrl] placeholderImage:[UIImage imageNamed:@"my_conter_TestUserImg"]]; NSLog(@"%@",[AppUserModel sharedAppUserModel].Name); cell.cell0UserName.text = ISEmptyString([AppUserModel sharedAppUserModel].Nick) ? @"昵称":[AppUserModel sharedAppUserModel].Nick; cell.cell0Intrt.text = ISEmptyString([AppUserModel sharedAppUserModel].Description) ? @"自我介绍":[AppUserModel sharedAppUserModel].Description ; return cell; }break; case 1:{ My_CenterCell *cell = [My_CenterCell configCell1:tableView indexPath:indexPath]; switch (indexPath.row) { case 0: { cell.cell1IconImg.image = [UIImage imageNamed:@"my_conter_sc_icon"]; cell.cell1TitleLabel.text = @"收藏"; }break; case 1: { cell.cell1IconImg.image = [UIImage imageNamed:@"my_conter_biji_icon"]; cell.cell1TitleLabel.text = @"笔记"; }break; case 2: { cell.cell1IconImg.image = [UIImage imageNamed:@"my_conter_setting_icon"]; cell.cell1TitleLabel.text = @"设置"; }break; default: break; } return cell; }break; default:break; } return nil; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; switch (indexPath.section) { case 0:{ switch (indexPath.row) { case 0:{ MyInfoVC *vc = [MyInfoVC initMyInfoVC]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; }break; default: break; } }break; case 1:{ switch (indexPath.row) { case 0:{ MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC]; vc.listType = MyFavoriteListLevelTypeA; vc.FolderId = 0; vc.operationStateEnum = OperationStateEnum0; vc.myTitle = @"我的收藏"; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; }break; case 1:{ NoteBookVC *vc = [NoteBookVC initNoteBookVC]; vc.listType = MyNoteBookListLevelTypeA; vc.FolderId = 0; vc.myTitle = @"我的笔记"; vc.VisitUserId = 0; vc.operationStateEnum = OperationStateEnum0; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; }break; case 2:{ SettingVC *vc = [SettingVC initSettingVC]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; }break; default: break; } }break; default: break; } } - (void)PushSettingVC:(NSNotification *)notification { NSInteger index = [[notification.userInfo objectForKey:VCINDEX] integerValue]; switch (index) { case 2: { MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC]; vc.listType = MyFavoriteListLevelTypeA; vc.FolderId = 0; vc.operationStateEnum = OperationStateEnum0; vc.myTitle = @"我的收藏"; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } break; case 3: { NoteBookVC *vc = [NoteBookVC initNoteBookVC]; vc.listType = MyNoteBookListLevelTypeA; vc.FolderId = 0; vc.myTitle = @"我的笔记"; vc.VisitUserId = 0; vc.operationStateEnum = OperationStateEnum0; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } break; case 4: { SettingVC *vc = [SettingVC initSettingVC]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } break; default: break; } } @end