ICRHomeViewController.m 6.57 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
//
//  ICRHomeViewController.m
//  XFFruit
//
//  Created by Xummer on 3/24/15.
//  Copyright (c) 2015 Xummer. All rights reserved.
//

#define M_HEAD_IMG_VIEW_HEIGHT               (190)
#define M_HEAD_VIEW_TITLE_LABEL_HEIGHT       (30)
#define M_HEAD_IMG_HEIGHT_WIDTH_PROPORTION   190.0f/320.0f

#import "ICRHomeViewController.h"

#import "ICRTaskListViewController.h"
#import "ICRPatrolPlanViewController.h"
#import "ICRStoreListViewController.h"
#import "ICRStoreDetailViewController.h"
#import "ICRAnnouncementViewController.h"

#import "ICRFunctionBaseView.h"
#import "ICRFunctionEntity.h"
#import "ICRFunctionBaseView.h"

陈俊俊's avatar
陈俊俊 committed
25 26
#import "NewSurveyViewController.h"
#import "SurveyViewController.h"
陈俊俊's avatar
陈俊俊 committed
27
#import "AddWorkSheetViewController.h"
陈俊俊's avatar
陈俊俊 committed
28

mei's avatar
mei committed
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
@interface ICRHomeViewController ()
<
    ICRFunctionBaseViewDelegate,
    ICRStoreListViewDelegate
>

@property (strong, nonatomic) UIImageView *m_headImageView;
@property (strong, nonatomic) UILabel     *m_headViewTextLabel;

@end

@implementation ICRHomeViewController

#pragma mark - Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupSubviews];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Private Method
- (void)setupSubviews {
    
    self.m_headImageView = [[UIImageView alloc] initWithFrame:(CGRect){
        .origin.x = 0,
        .origin.y = 0,
        .size.width = self.view.width,
        .size.height = self.view.width * M_HEAD_IMG_HEIGHT_WIDTH_PROPORTION
    }];
    _m_headImageView.image = [UIImage imageNamed:@"HomeDisplayImage"];
    
    self.m_headViewTextLabel = [[UILabel alloc] initWithFrame:(CGRect){
        .origin.x = 0,
        .origin.y = CGRectGetHeight(self.m_headImageView.frame) - M_HEAD_VIEW_TITLE_LABEL_HEIGHT,
        .size.width = CGRectGetWidth(self.m_headImageView.frame),
        .size.height = M_HEAD_VIEW_TITLE_LABEL_HEIGHT
    }];
    _m_headViewTextLabel.backgroundColor = [UIColor colorWithRed:0.310f green:0.345f blue:0.392f alpha:0.5f];
    _m_headViewTextLabel.textColor = [UIColor whiteColor];
    _m_headViewTextLabel.font = [UIFont systemFontOfSize:13];
    _m_headViewTextLabel.textAlignment = NSTextAlignmentCenter;
//    _m_headViewTextLabel.text = @"我是文字我是文字我是文字我是文字";
    
    [_m_headImageView addSubview:_m_headViewTextLabel];
    [self.view addSubview:_m_headImageView];
    
    NSMutableArray *arrFunctionEntities = [NSMutableArray array];
    
陈俊俊's avatar
陈俊俊 committed
81
    NSArray *functionImageNames = @[ @"AnnouncementIcon",@"TaskManageIcon",@"PatrolPlanIcon",@"MyStoreIcon",@"MyStoreIcon",@"MyStoreIcon"];
mei's avatar
mei committed
82 83 84
    NSArray *fuctionNames = @[ [IBTCommon localizableString:@"Announcement"],
                              [IBTCommon localizableString:@"TaskManage"],
                              [IBTCommon localizableString:@"PatrolPlan"],
陈俊俊's avatar
陈俊俊 committed
85 86
                              [IBTCommon localizableString:@"MyStore"],
                               [IBTCommon localizableString:@"Survey"],[IBTCommon localizableString:@"AddSurvey"]];
mei's avatar
mei committed
87 88 89
    NSArray *functionTags = @[ @(kFunctionAnnouncement),
                               @(kFunctionTaskManagement),
                               @(kFunctionPatrolPlan),
陈俊俊's avatar
陈俊俊 committed
90 91 92
                               @(kFunctionMyShop),
                               @(kFunctionNavigation),
                               @(kFunctionComeShopReg)];
mei's avatar
mei committed
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

    int i = 0;
    for (NSString *functionName in fuctionNames) {
        ICRFunctionEntity *funtionEntity = [[ICRFunctionEntity alloc] init];
        funtionEntity.functionName = functionName;
        funtionEntity.iconName = [functionImageNames objectAtIndex:i];
        funtionEntity.functionItemTag = [[functionTags objectAtIndex:i] integerValue];
        [arrFunctionEntities addObject:funtionEntity];
        i ++;
    }
    
    ICRFunctionBaseView *baseView = [ICRFunctionBaseView initWithFunctionData:arrFunctionEntities];
    
    baseView.frame = (CGRect){
        .origin.x = 0,
        .origin.y = CGRectGetMaxY(_m_headImageView.frame),
        .size.width = CGRectGetWidth(self.view.frame),
        .size.height = CGRectGetHeight(self.view.frame) - CGRectGetHeight(_m_headImageView.frame)
    };
    baseView.backgroundColor = [UIColor clearColor];
    baseView.m_delegate = self;
    [self.view addSubview:baseView];
}

#pragma mark - ICRFunctionBaseViewDelegate
- (void)ICRFunctionBaseView:(ICRFunctionItemControl *)imageView {
    /*
     kFunctionAnnouncement = 0,
     kFunctionTaskManagement,
     kFunctionPatrolPlan,
     kFunctionMyShop,
     */
    switch (imageView.tag) {
        case kFunctionAnnouncement:
        {
            ICRAnnouncementViewController *aVC = [[ICRAnnouncementViewController alloc] init];
            [self PushViewController:aVC animated:YES];
        }
            break;
        case kFunctionTaskManagement:
        {
            ICRTaskListViewController *tVC = [[ICRTaskListViewController alloc] init];
            [self PushViewController:tVC animated:YES];
        }
            break;
        case kFunctionPatrolPlan:
        {
            ICRPatrolPlanViewController *pVC = [[ICRPatrolPlanViewController alloc] initWithStore:nil isHomeShow:YES];
            [self PushViewController:pVC animated:YES];
        }
            break;
        case kFunctionMyShop:
        {
陈俊俊's avatar
陈俊俊 committed
146 147 148 149 150
//            ICRStoreListViewController *sVC = [[ICRStoreListViewController alloc] initWithBHaveToChooseOne:NO];
//            sVC.title = [IBTCommon localizableString:@"MyStore"];
//            sVC.m_delegate = self;
//            [self PushViewController:sVC animated:YES];
            AddWorkSheetViewController *sVC = [[AddWorkSheetViewController alloc] init];
mei's avatar
mei committed
151 152 153
            [self PushViewController:sVC animated:YES];
        }
            break;
陈俊俊's avatar
陈俊俊 committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167
        case kFunctionNavigation:
        {
            SurveyViewController *svc = [[SurveyViewController alloc] init];
            svc.title = [IBTCommon localizableString:@"Survey"];
            [self PushViewController:svc animated:YES];
        }
            break;
        case kFunctionComeShopReg:
        {
            NewSurveyViewController *svc = [[NewSurveyViewController alloc] init];
            svc.title = [IBTCommon localizableString:@"AddSurvey"];
            [self PushViewController:svc animated:YES];
        }
            break;
mei's avatar
mei committed
168 169 170 171 172 173 174 175 176 177 178 179
        default:
            break;
    }
}

#pragma mark - ICRStoreListViewDelegate
- (void)storeListViewCtrl:(ICRStoreListViewController *)vCtrl didSelectedStore:(ICRStore *)store {
    ICRStoreDetailViewController *dVC = [[ICRStoreDetailViewController alloc] initWithStoreData:store];
    [vCtrl PushViewController:dVC animated:YES];
}

@end