//
//  RDSSystemSetVC.m
//  Temperature
//
//  Created by RD on 2023/1/16.
//

#import "RDSSystemSetVC.h"
#import "RDSSystemSetCell.h"
#import "RDSUserProtocolViewController.h"
#import "RDCheckAppVersion.h"

static NSString * const RDSSystemSetCellID = @"RDSSystemSetCell";
@interface RDSSystemSetVC ()<UITableViewDelegate , UITableViewDataSource>
@property (nonatomic, weak) UITableView *tableView;

@end

@implementation RDSSystemSetVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"系统设置";
    self.view.backgroundColor = UIColor.whiteColor;
    [self p_setupTableView];
}

- (void)p_setupTableView {
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, SCREEN_HEIGHT-20-60)];
    [self.view addSubview:tableView];
    tableView.dataSource = self;
    tableView.delegate = self;
    
    tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.tableView = tableView;
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.tableView registerNib:[UINib nibWithNibName:@"RDSSystemSetCell" bundle:nil] forCellReuseIdentifier:RDSSystemSetCellID];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    
    tableView.rowHeight = 60*kSCALE_WIDTH_X;
    

}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    RDSSystemSetCell *cell = [tableView dequeueReusableCellWithIdentifier:RDSSystemSetCellID];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if(indexPath.row == 0){
        cell.titleLab.text = @"检查更新";
    }
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    int row = (int)indexPath.row;
    
    [TheCheckAppVersion checkUpdateAlert];
    
//    RDSUserProtocolViewController *userProtocolVC = [[RDSUserProtocolViewController alloc] init];
//    userProtocolVC.url = row == 0 ? kUserAgreement:kPrivacyPolicy;
//    userProtocolVC.vcTitle = row == 0 ? @"用户协议":@"隐私政策";
//    [self pushViewController:userProtocolVC animated:YES];
    
}

@end
