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

152 lines
4.4 KiB
Objective-C

//
// AppVerionDescriptionVC.m
// GIGA
//
// Created by lianxiang on 2018/9/18.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "AppVerionDescriptionVC.h"
#import "AppVersionDescCell.h"
#import "GiGaBaseAPiRequest.h"
#import "VersionModel.h"
#import "AppVersionLogoCell.h"
@interface AppVerionDescriptionVC ()
@property (nonatomic,strong) NSMutableArray *versionsArr;
@property (nonatomic) int currntPage ;
@property (nonatomic) int totalPage ;
@end
@implementation AppVerionDescriptionVC
- (void)viewDidLoad {
[super viewDidLoad];
[self addNavTitile:@"版本说明"];
_currntPage = 1;
_totalPage = 1;
self.versionsArr = [[NSMutableArray alloc] init];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = GIGA_MAIN_BGCOLOR;
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.frame = CGRectMake(0, 1, KMainW, self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self requstListDatas];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1 + self.versionsArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
AppVersionLogoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AppVersionLogoCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"AppVersionLogoCell" owner:self options:nil] lastObject];
}
return cell;
}
AppVersionDescCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AppVersionDescCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"AppVersionDescCell" owner:self options:nil] lastObject];
}
VersionModel *model =self.versionsArr[indexPath.row];
[cell loadCellDataAt:indexPath version:model];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
return 173.f;
}else{
return 92 + 25 * self.versionsArr.count;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 0){
return 0.1;
}else if (section == 1){
return 12;
}
return 4;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 1) {
UIView *view = [[UIView alloc] init];
view.backgroundColor = GIGARGB(222, 222, 222, 1);
return view;
}
UIView *view = [[UIView alloc] init];
view.backgroundColor = GIGARGB(222, 222, 222, 1);
return view;
}
-(void)requstListDatas{
GiGaBaseAPiRequest *reuqest = [GiGaBaseAPiRequest initWithRequestPath:kAPiAPPVersion method:RequestPostMethod parms:@{}];
[reuqest requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
GILog(@"%@",result.dic);
self->_currntPage = [result.dic[@"currPage"] intValue];
self->_totalPage = [result.dic[@"totalPage"] intValue];
NSDictionary *pagedic = result.dic[@"page"];
NSArray *listArr = pagedic[@"list"];
for (NSDictionary *dic in listArr) {
VersionModel *model = [[VersionModel alloc] initWithDictionary:dic error:nil];
[self.versionsArr addObject:model];
}
[self.tableView reloadData];
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end