ICRAboutViewController.m 4.85 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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
//
//  ICRAboutViewController.m
//  XFFruit
//
//  Created by Lili Wang on 15/4/8.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#define IBT_APP_ICON_WIDTH     (80)

#import "ICRAboutViewController.h"

@interface ICRAboutViewController ()

@property (strong, nonatomic) IBTTableViewInfo *m_tableViewInfo;
@property (strong, nonatomic) UIImageView *m_viewAvatarImage;

@end

@implementation ICRAboutViewController

- (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.title = [IBTCommon localizableString:@"About"];
    
    self.m_tableViewInfo = [[IBTTableViewInfo alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    
    IBTTableView *tableV = [_m_tableViewInfo getTableView];
    [self.view addSubview:tableV];
    
    
    IBTUIView *tableHeader = [[IBTUIView alloc] init];
    tableHeader.backgroundColor = [UIColor clearColor];
    tableHeader.frame = (CGRect){
        .origin.x = 0,
        .origin.y = 0,
        .size.width = tableV.width,
        .size.height = 160
    };
    
    CGFloat fNameH = 40;
    self.m_viewAvatarImage = [[UIImageView alloc] init];
    _m_viewAvatarImage.frame = (CGRect){
        .origin.x = (tableHeader.width - IBT_APP_ICON_WIDTH) * .5f,
        .origin.y = (tableHeader.height - IBT_APP_ICON_WIDTH - fNameH) * IBT_GOLDEN_RATIO,
        .size.width = IBT_APP_ICON_WIDTH,
        .size.height = IBT_APP_ICON_WIDTH
    };
    _m_viewAvatarImage.layer.cornerRadius = IBT_APP_ICON_WIDTH / 10;
    _m_viewAvatarImage.layer.masksToBounds = YES;
    
    CGFloat fMargin = 10;
    UILabel *appNameLabel = [[UILabel alloc] init];
    appNameLabel.frame = (CGRect){
        .origin.x = fMargin,
        .origin.y = _m_viewAvatarImage.bottom,
        .size.width = tableHeader.width - 2 * fMargin,
        .size.height = fNameH
    };
    
    appNameLabel.font = [UIFont boldSystemFontOfSize:18];
    appNameLabel.textColor = IBT_TINTCOLOR;
    appNameLabel.textAlignment = NSTextAlignmentCenter;
    
    [tableHeader addSubview:_m_viewAvatarImage];
    [tableHeader addSubview:appNameLabel];
    
    tableV.tableHeaderView = tableHeader;
    
    
    // Footer
    CGRect frame = self.view.frame;
    frame.size.height = 20;
    frame.origin.y = self.view.height - CGRectGetHeight(frame) -20;
    
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.font = [UIFont systemFontOfSize:16];
    label.text = @"Copyright@2014";
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    
    //tableV.tableFooterView = label;
    [self.view addSubview:label];
    
    /*
     CFBundleIcons =     {
     CFBundlePrimaryIcon =         {
     CFBundleIconFiles =             (
     AppIcon29x29,
     AppIcon40x40,
     AppIcon57x57,
     AppIcon60x60,
     AppIcon120x120
     );
     };
     };
     */
    
    NSArray *arrIcons = [[NSBundle mainBundle] infoDictionary][ @"CFBundleIcons" ][ @"CFBundlePrimaryIcon" ][ @"CFBundleIconFiles" ];
    UIImage *appIcon = nil;
    NSUInteger uiIconCount = [arrIcons count];
    for (NSInteger i = uiIconCount - 1; i >= 0; i -- ) {
        appIcon = [UIImage imageNamed:arrIcons[ i ]];
        if (appIcon) {
            break;
        }
    }
    
    _m_viewAvatarImage.image = appIcon;
    appNameLabel.text = IBT_APP_NAME_STR;
    
    // Section 0
    IBTTableViewSectionInfo *sec0Info = [IBTTableViewSectionInfo sectionInfoDefaut];
    
    // Version
#if DEBUG
    NSString *nsBuild = IBT_APP_BUILD_STR;
    NSString *nsVersion = IBT_APP_VERSION_STR;
    NSString *nsV = (nsBuild.length > 0) ? [NSString stringWithFormat:@"%@(%@)", nsVersion, nsBuild] : nsVersion;
#else
    NSString *nsV = IBT_APP_VERSION_STR;
#endif
    
    IBTTableViewCellInfo *versionCellInfo =
    [IBTTableViewCellInfo normalCellForSel:nil target:nil
                                    title:[IBTCommon localizableString:@"Version"]
                               rightValue:nsV
                            accessoryType:UITableViewCellAccessoryNone];
    versionCellInfo.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [sec0Info addCell:versionCellInfo];
    
    IBTTableViewCellInfo *phoneCellInfo =
    [IBTTableViewCellInfo normalCellForSel:nil target:nil
                                     title:[IBTCommon localizableString:@"Phone Number"]
                                rightValue:@"400-400-4000"
                             accessoryType:UITableViewCellAccessoryNone];
    phoneCellInfo.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [sec0Info addCell:phoneCellInfo];
    
    [_m_tableViewInfo addSection:sec0Info];
}

@end