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

165 lines
5.3 KiB
Objective-C

//
// GiSysSettingsVC.m
// GIGA
//
// Created by lianxiang on 2018/9/3.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "GiSysSettingsVC.h"
#import "GiGaSettingsViewCell.h"
#import "JXTAlertController.h"
#import "GiGaUserDefault.h"
#import "GiGaUserManager.h"
#import "AppVerionDescriptionVC.h"
#import "GIGaAboutUsVC.h"
#import "GiGaFeedBackViewController.h"
#import "GiGaWebViewController.h"
#import "GiGaServerConfig.h"
@interface GiSysSettingsVC ()
@end
@implementation GiSysSettingsVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self addNavTitile:@"系统设置"];
[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;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
GiGaSettingsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaSettingsViewCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaSettingsViewCell" owner:self options:nil] lastObject];
}
[cell loadCellDataAt:indexPath];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0) {
[self jxt_showAlertWithTitle:@"提示" message:@"确定清楚缓存?" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"确定");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
GiGaSettingsViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.cachLabe.text = @"0M";
}
}];
}else if (indexPath.row == 1){
GiGaFeedBackViewController *feedVC = [[GiGaFeedBackViewController alloc] init];
[self.navigationController pushViewController:feedVC animated:YES];
}else if (indexPath.row == 2){
GIGaAboutUsVC *usVC= [[GIGaAboutUsVC alloc] init];
[self.navigationController pushViewController:usVC animated:YES];
}else if (indexPath.row == 3){
// AppVerionDescriptionVC *verVC =[[AppVerionDescriptionVC alloc] init];
// [self.navigationController pushViewController:verVC animated:YES];
//版本说明
GiGaWebViewController *webVC = [[GiGaWebViewController alloc] init];
webVC.url = kIMPRITNT;
webVC.souceType = WebSourceTypeUrlLink;
[self.navigationController pushViewController:webVC animated:YES];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 100;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *view = [[UIView alloc] init];
view.frame = CGRectMake(0, 0, KMainW, 100);
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(30, 50, KMainW - 30*2, 50);
[btn setTitle:@"退出登录" forState:UIControlStateNormal];
btn.layer.masksToBounds = YES;
btn.layer.cornerRadius = btn.frame.size.height / 2;
btn.backgroundColor = GIGARGB(181, 14, 14, 1);
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(userLogOutAction) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:btn];
return view;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - 退出登录
-(void)userLogOutAction{
[self jxt_showAlertWithTitle:@"温馨提示" message:@"确定退出?" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDestructiveTitle(@"退出");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
switch (buttonIndex) {
case 1:
{
GILog(@"退出登录");
[self userlogOut];
}
break;
default:
GILog(@"取消");
break;
}
}];
}
//http://yts.s1.natapp.cc/mask/clearZear.html
-(void)userlogOut{
[[GiGaUserManager shareUser] loginOut];
NC_POST_NAME_OBJECT(kUserLogOutNotify, nil);
[self.navigationController popToRootViewControllerAnimated:YES];
}
@end