GiGaMaskTime/GIGA/Modules/Me/Controller/GiGaMeViewController.m

165 lines
4.7 KiB
Objective-C

//
// GiGaMeViewController.m
// GIGA
//
// Created by lianxiang on 2018/8/22.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "GiGaMeViewController.h"
#import "GiGaUserViewController.h"
#import "GiGaMineUserViewCell.h"
#import "GiGaMineInfoViewCell.h"
#import "GiSysSettingsVC.h"
#import "GiMaskTimeHistoryVC.h"
#import "UINavigationBar+Custom.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaUserManager.h"
@interface GiGaMeViewController ()
@property (nonatomic,strong) GiGaUser *user;
@end
@implementation GiGaMeViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self addNavTitile:@"我的"];
// Do any additional setup after loading the view.
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.bounces = NO;
self.tableView.frame = CGRectMake(0, 1, KMainW, self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self loadUserInfo];
}
-(void)loadUserInfo{
GiGaUser *currentuser = [[GiGaUserManager shareUser] getCurrentUser];
if (!currentuser) {
[self.view makeToastActivity:CSToastPositionCenter];
[[GiGaUserManager shareUser] synsisUserInfo:^(GiGaUser *user) {
[self.view hideToastActivity];
self.user = user;
} userErrorMsgBlock:^(NSDictionary *errorCodemsg) {
[self.view hideToastActivity];
GIGA_ShowToast(errorCodemsg[@"msg"]);
}];
}else{
self.user = currentuser;
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0){
return 1;
}
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section ==0){
GiGaMineUserViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaMineUserViewCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaMineUserViewCell" owner:self options:nil] lastObject];
}
if (self.user) {
[cell loadUserinfoWith:self.user];
}
return cell;
}
GiGaMineInfoViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaMineInfoViewCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaMineInfoViewCell" owner:self options:nil] lastObject];
}
[cell loadCellData:indexPath];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section == 1){
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if(indexPath.section == 0){
GiGaUserViewController *userVC= [[GiGaUserViewController alloc] init];
[self.navigationController pushViewController:userVC animated:YES];
}else{
if (indexPath.section == 1 && indexPath.row == 0 ){
//历史记录
GiMaskTimeHistoryVC *historyVC= [[GiMaskTimeHistoryVC alloc] init];
[self.navigationController pushViewController:historyVC animated:YES];
}else if (indexPath.section == 1 && indexPath.row == 1){
}else{
//系统设置
GiSysSettingsVC*settingsVC= [[GiSysSettingsVC alloc] init];
[self.navigationController pushViewController:settingsVC animated:YES];
}
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section==0){
return 139;
}else {
return 54;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 1){
return 6;
}
return 0.1;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 1) {
UIView *view = [[UIView alloc] init];
view.backgroundColor = GIGARGB(222, 222, 222, 1);
return view;
}
return nil;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end