ICRSystemViewController.m 6.13 KB
Newer Older
mei's avatar
mei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
//
//  ICRSystemViewController.m
//  XFFruit
//
//  Created by Xummer on 3/24/15.
//  Copyright (c) 2015 Xummer. All rights reserved.
//

#import "ICRSystemViewController.h"
#import "ICRSystemHeaderView.h"
#import "ICRModifyPwdViewController.h"
#import "ICRConfigurationViewController.h"
#import "ICRHelpAndFeedBackViewController.h"
#import "ICRAboutViewController.h"

#if DEBUG
#import "ICRHTTPApiTestViewController.h"
#endif

@interface ICRSystemViewController ()

@property (strong, nonatomic) IBTTableViewInfo *m_tableViewInfo;
@property (weak, nonatomic) ICRSystemHeaderView *m_tableHeader;
@end

@implementation ICRSystemViewController

#pragma mark - Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initTableViewInfo];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Private Method
- (void)initTableViewInfo {
    self.m_tableViewInfo = [[IBTTableViewInfo alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    
    IBTTableView *tableV = [_m_tableViewInfo getTableView];
    tableV.backgroundColor = [UIColor colorWithW:246 a:1];
    [self.view addSubview:tableV];
    
    // Header
    ICRSystemHeaderView *tableHeader = [[ICRSystemHeaderView alloc] initWithFrame:(CGRect){
        .origin.x = 0,
        .origin.y = 0,
        .size.width = tableV.width,
        .size.height = 150
    }];
    tableV.tableHeaderView = tableHeader;
    self.m_tableHeader = tableHeader;
    
    [tableHeader updateWithUserUtil];
    
    // Footer
    UIButton *btn = nil;
    UIView *tableFooter =
    [tableV buttonViewWithTitle:[IBTCommon localizableString:@"Logout"]
                          color:ICR_ORANGE_BTN_COLOR
                         topGap:25
                        pointer:&btn
                         target:self
                         action:@selector(onLogout:)];
    tableV.tableFooterView = tableFooter;
    
    IBTTableViewSectionInfo *secInfo;
    IBTTableViewCellInfo *cellInfo;
    
    UIColor *titleColor = [UIColor colorWithW:109 a:1];
    CGFloat fCellHeight = IBT_DEFAULT_CELL_HEIGHT;
    
    secInfo = [IBTTableViewSectionInfo sectionInfoDefaut];
    // Change Password
    cellInfo =
    [IBTTableViewCellInfo normalCellForSel:@selector(onChangePassword:) target:self
                                     title:[IBTCommon localizableString:@"Change Password"]
                                rightValue:nil
                             accessoryType:UITableViewCellAccessoryDisclosureIndicator];
    [cellInfo addUserInfoValue:titleColor forKey:CInfoTitleColorKey];
    cellInfo.fCellHeight = fCellHeight;
    [secInfo addCell:cellInfo];
    
    // Setting
    cellInfo =
    [IBTTableViewCellInfo normalCellForSel:@selector(onShowSettingView:) target:self
                                     title:[IBTCommon localizableString:@"Setting"]
                                rightValue:nil
                             accessoryType:UITableViewCellAccessoryDisclosureIndicator];
    [cellInfo addUserInfoValue:titleColor forKey:CInfoTitleColorKey];
    cellInfo.fCellHeight = fCellHeight;
    [secInfo addCell:cellInfo];
    
    // Help & Feedback
    cellInfo =
    [IBTTableViewCellInfo normalCellForSel:@selector(onShowHelpAndFeedBackView:) target:self
                                     title:[IBTCommon localizableString:@"Help & Feedback"]
                                rightValue:nil
                             accessoryType:UITableViewCellAccessoryDisclosureIndicator];
    [cellInfo addUserInfoValue:titleColor forKey:CInfoTitleColorKey];
    cellInfo.fCellHeight = fCellHeight;
    [secInfo addCell:cellInfo];
    
    // About
    cellInfo =
    [IBTTableViewCellInfo normalCellForSel:@selector(onShowAboutView:) target:self
                                     title:[IBTCommon localizableString:@"About"]
                                rightValue:nil
                             accessoryType:UITableViewCellAccessoryDisclosureIndicator];
    [cellInfo addUserInfoValue:titleColor forKey:CInfoTitleColorKey];
    cellInfo.fCellHeight = fCellHeight;
    [secInfo addCell:cellInfo];
    
    [self.m_tableViewInfo addSection:secInfo];
    
freecui's avatar
freecui committed
120 121 122 123 124 125 126 127 128 129 130 131 132
//#if DEBUG
//    // HTTP API
//    secInfo = [IBTTableViewSectionInfo sectionInfoHeader:@"Test"];
//    cellInfo =
//    [IBTTableViewCellInfo normalCellForSel:@selector(onShowHTTPTestView:) target:self
//                                     title:[IBTCommon localizableString:@"HTTP Restful API"]
//                                rightValue:nil
//                             accessoryType:UITableViewCellAccessoryDisclosureIndicator];
//    [cellInfo addUserInfoValue:titleColor forKey:CInfoTitleColorKey];
//    cellInfo.fCellHeight = fCellHeight;
//    [secInfo addCell:cellInfo];
//    [self.m_tableViewInfo addSection:secInfo];
//#endif
mei's avatar
mei committed
133 134 135 136 137 138 139 140 141
    

}

#pragma mark - Actions
- (void)onLogout:(__unused id)sender {
    ICRAppViewControllerManager *mgr =
    [ICRAppViewControllerManager getAppViewControllerManager];
    [mgr doLogout];
管鹏飞's avatar
管鹏飞 committed
142 143 144 145
    
    ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
    userUtil.isLogout = YES;
    [userUtil saveArchive];
mei's avatar
mei committed
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
}

- (void)onChangePassword:(__unused id)sender {
    ICRModifyPwdViewController *modifyPWDVC = [[ICRModifyPwdViewController alloc] init];
    [self PushViewController:modifyPWDVC animated:YES];
}

- (void)onShowSettingView:(__unused id)sender {
    ICRConfigurationViewController *configurationVC = [[ICRConfigurationViewController alloc] init];
    [self PushViewController:configurationVC animated:YES];
}


- (void)onShowHelpAndFeedBackView:(__unused id)sender {
    ICRHelpAndFeedBackViewController *helpAndFeedVC = [[ICRHelpAndFeedBackViewController alloc] init];
    [self PushViewController:helpAndFeedVC animated:YES];
}

- (void)onShowAboutView:(__unused id)sender {
    ICRAboutViewController *aboutVC = [[ICRAboutViewController alloc] init];
    [self PushViewController:aboutVC animated:YES];
}

#if DEBUG
- (void)onShowHTTPTestView:(__unused id)sender {
    ICRHTTPApiTestViewController *apiTestCtrl = [[ICRHTTPApiTestViewController alloc] init];
    [self PushViewController:apiTestCtrl animated:YES];
}
#endif

@end