ICRAboutViewController.m 5.35 KB
Newer Older
mei's avatar
mei committed
1 2 3 4 5 6 7 8
//
//  ICRAboutViewController.m
//  XFFruit
//
//  Created by Lili Wang on 15/4/8.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

Sandy's avatar
Sandy committed
9
#define IBT_APP_ICON_WIDTH (80)
mei's avatar
mei committed
10 11 12 13 14 15 16 17 18 19 20 21

#import "ICRAboutViewController.h"

@interface ICRAboutViewController ()

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

@end

@implementation ICRAboutViewController

Sandy's avatar
Sandy committed
22 23
- (void)viewDidLoad
{
mei's avatar
mei committed
24 25 26 27 28
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initTableViewInfo];
}

Sandy's avatar
Sandy committed
29 30
- (void)didReceiveMemoryWarning
{
mei's avatar
mei committed
31 32 33 34 35 36
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Private Method

Sandy's avatar
Sandy committed
37 38 39
- (void)initTableViewInfo
{

mei's avatar
mei committed
40
    self.title = [IBTCommon localizableString:@"About"];
Sandy's avatar
Sandy committed
41

mei's avatar
mei committed
42
    self.m_tableViewInfo = [[IBTTableViewInfo alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
Sandy's avatar
Sandy committed
43

mei's avatar
mei committed
44 45
    IBTTableView *tableV = [_m_tableViewInfo getTableView];
    [self.view addSubview:tableV];
Sandy's avatar
Sandy committed
46

mei's avatar
mei committed
47 48
    IBTUIView *tableHeader = [[IBTUIView alloc] init];
    tableHeader.backgroundColor = [UIColor clearColor];
Sandy's avatar
Sandy committed
49 50
    tableHeader.frame = (CGRect){.origin.x = 0, .origin.y = 0, .size.width = tableV.width, .size.height = 160 };

mei's avatar
mei committed
51 52
    CGFloat fNameH = 40;
    self.m_viewAvatarImage = [[UIImageView alloc] init];
Sandy's avatar
Sandy committed
53
    _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 };
mei's avatar
mei committed
54 55
    _m_viewAvatarImage.layer.cornerRadius = IBT_APP_ICON_WIDTH / 10;
    _m_viewAvatarImage.layer.masksToBounds = YES;
Sandy's avatar
Sandy committed
56

mei's avatar
mei committed
57 58
    CGFloat fMargin = 10;
    UILabel *appNameLabel = [[UILabel alloc] init];
Sandy's avatar
Sandy committed
59 60
    appNameLabel.frame = (CGRect){.origin.x = fMargin, .origin.y = _m_viewAvatarImage.bottom, .size.width = tableHeader.width - 2 * fMargin, .size.height = fNameH };

mei's avatar
mei committed
61 62 63
    appNameLabel.font = [UIFont boldSystemFontOfSize:18];
    appNameLabel.textColor = IBT_TINTCOLOR;
    appNameLabel.textAlignment = NSTextAlignmentCenter;
Sandy's avatar
Sandy committed
64

mei's avatar
mei committed
65 66
    [tableHeader addSubview:_m_viewAvatarImage];
    [tableHeader addSubview:appNameLabel];
Sandy's avatar
Sandy committed
67

mei's avatar
mei committed
68
    tableV.tableHeaderView = tableHeader;
Sandy's avatar
Sandy committed
69

mei's avatar
mei committed
70 71 72
    // Footer
    CGRect frame = self.view.frame;
    frame.size.height = 20;
Sandy's avatar
Sandy committed
73 74
    frame.origin.y = self.view.height - CGRectGetHeight(frame) - 20;

mei's avatar
mei committed
75 76
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.font = [UIFont systemFontOfSize:16];
Sandy's avatar
Sandy committed
77 78 79 80 81 82
#ifdef Demonstrate
    label.text = @"上海海鼎信息工程股份有限公司";
#else
    label.text = @"Copyright © 2014";
#endif
    
mei's avatar
mei committed
83 84 85
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
Sandy's avatar
Sandy committed
86 87

    // tableV.tableFooterView = label;
mei's avatar
mei committed
88
    [self.view addSubview:label];
Sandy's avatar
Sandy committed
89

mei's avatar
mei committed
90 91 92 93 94 95 96 97 98 99 100 101 102
    /*
     CFBundleIcons =     {
     CFBundlePrimaryIcon =         {
     CFBundleIconFiles =             (
     AppIcon29x29,
     AppIcon40x40,
     AppIcon57x57,
     AppIcon60x60,
     AppIcon120x120
     );
     };
     };
     */
Sandy's avatar
Sandy committed
103 104

    NSArray *arrIcons = [[NSBundle mainBundle] infoDictionary][@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconFiles"];
mei's avatar
mei committed
105 106
    UIImage *appIcon = nil;
    NSUInteger uiIconCount = [arrIcons count];
Sandy's avatar
Sandy committed
107 108
    for (NSInteger i = uiIconCount - 1; i >= 0; i--) {
        appIcon = [UIImage imageNamed:arrIcons[i]];
mei's avatar
mei committed
109 110 111 112
        if (appIcon) {
            break;
        }
    }
Sandy's avatar
Sandy committed
113

mei's avatar
mei committed
114 115
    _m_viewAvatarImage.image = appIcon;
    appNameLabel.text = IBT_APP_NAME_STR;
Sandy's avatar
Sandy committed
116

mei's avatar
mei committed
117 118
    // Section 0
    IBTTableViewSectionInfo *sec0Info = [IBTTableViewSectionInfo sectionInfoDefaut];
Sandy's avatar
Sandy committed
119 120

// Version
mei's avatar
mei committed
121 122 123 124 125 126 127
#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
Sandy's avatar
Sandy committed
128

mei's avatar
mei committed
129
    IBTTableViewCellInfo *versionCellInfo =
Sandy's avatar
Sandy committed
130
        [IBTTableViewCellInfo normalCellForSel:nil target:nil title:[IBTCommon localizableString:@"Version"] rightValue:nsV accessoryType:UITableViewCellAccessoryNone];
mei's avatar
mei committed
131
    versionCellInfo.selectionStyle = UITableViewCellSelectionStyleNone;
Sandy's avatar
Sandy committed
132

mei's avatar
mei committed
133
    [sec0Info addCell:versionCellInfo];
Sandy's avatar
Sandy committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148

#ifdef Demonstrate
    IBTTableViewCellInfo *phoneCellInfo = [IBTTableViewCellInfo normalCellForSel:nil
                                                                          target:nil
                                                                           title:[IBTCommon localizableString:@"Phone Number"]
                                                                      rightValue:@"021-54325000"
                                                                   accessoryType:UITableViewCellAccessoryNone];
#else
    IBTTableViewCellInfo *phoneCellInfo = [IBTTableViewCellInfo normalCellForSel:nil
                                                                          target:nil
                                                                           title:[IBTCommon localizableString:@"Phone Number"]
                                                                      rightValue:@"400-400-4000"
                                                                   accessoryType:UITableViewCellAccessoryNone];
#endif

mei's avatar
mei committed
149
    phoneCellInfo.selectionStyle = UITableViewCellSelectionStyleNone;
Sandy's avatar
Sandy committed
150

mei's avatar
mei committed
151
    [sec0Info addCell:phoneCellInfo];
Sandy's avatar
Sandy committed
152

mei's avatar
mei committed
153 154 155 156
    [_m_tableViewInfo addSection:sec0Info];
}

@end