PassengerViewController.m 4.63 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9
//
//  PassengerViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/11/8.
//  Copyright © 2015年 Xummer. All rights reserved.
//

#import "PassengerViewController.h"
陈俊俊's avatar
陈俊俊 committed
10
#import "RPassgerView.h"
陈俊俊's avatar
陈俊俊 committed
11 12
#import "PasengerCell.h"
#import "PassengerHeaderCell.h"
陈俊俊's avatar
陈俊俊 committed
13
#import "ReportDetailViewController.h"
陈俊俊's avatar
陈俊俊 committed
14 15 16 17 18
#define LeftWidth   50

static NSString *passengerHeaderIdentify = @"PassengerHeaderIdentify";


陈俊俊's avatar
陈俊俊 committed
19 20 21
@interface PassengerViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)RPassgerView *rpassgerView;

陈俊俊's avatar
陈俊俊 committed
22 23 24 25 26 27 28 29 30 31 32 33 34
@end

@implementation PassengerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self bulidLayout];
}


#pragma mark - 布局
- (void)bulidLayout{
    self.view .backgroundColor = [UIColor whiteColor];
陈俊俊's avatar
陈俊俊 committed
35
    CGRect rect = CGRectMake(0, 0, ScreenSize.width, 145);
36 37 38 39 40
    self.rpassgerView = [[RPassgerView alloc]initWithFrame:rect withPage:1];
    self.rpassgerView.bgImage.image = [UIImage imageNamed:@"salebg_2"];
    self.rpassgerView.cenImage.image = [UIImage imageNamed:@"sale_2"];

    [self.view addSubview:self.rpassgerView];
陈俊俊's avatar
陈俊俊 committed
41 42
    
    
陈俊俊's avatar
陈俊俊 committed
43
    rect = CGRectMake(0, 0, self.view.width, self.view.height- 158);
陈俊俊's avatar
陈俊俊 committed
44 45 46 47
    self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[PassengerHeaderCell class] forHeaderFooterViewReuseIdentifier:passengerHeaderIdentify];
48
    self.tableView.tableHeaderView = self.rpassgerView;
陈俊俊's avatar
陈俊俊 committed
49 50 51 52
    
    [self.view addSubview:self.tableView];
    
}
陈俊俊's avatar
陈俊俊 committed
53 54
- (void)setValueInPassenger:(Compass *)compass  withType:(NSString *)type{
    self.rpassgerView.weekLabelStr = type;
陈俊俊's avatar
陈俊俊 committed
55 56
    [self.rpassgerView setPassengerWithCompass:compass];
}
陈俊俊's avatar
陈俊俊 committed
57 58 59 60 61 62 63


#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
陈俊俊's avatar
陈俊俊 committed
64
    return self.dataArr.count;
陈俊俊's avatar
陈俊俊 committed
65 66
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
陈俊俊's avatar
陈俊俊 committed
67 68 69 70
    
    static NSString *passengerCellIdentify = @"PassengerCellIdentify";

    PasengerCell *cell = [tableView dequeueReusableCellWithIdentifier:passengerCellIdentify];
陈俊俊's avatar
陈俊俊 committed
71 72 73 74 75 76 77 78 79
    
    if(cell == nil) {
        cell = [[PasengerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:passengerCellIdentify];
    }
    //没有选中风格
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //取消分割线
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
80
    Compass *test = _dataArr[indexPath.row];
陈俊俊's avatar
陈俊俊 committed
81 82 83 84 85
    if(test != nil) {
        [cell updateCellWithFlow:test index:indexPath];
    }
    cell.detailBtn.tag = indexPath.row;
    [cell.detailBtn addTarget:self action:@selector(detailClick:) forControlEvents:UIControlEventTouchUpInside];
陈俊俊's avatar
陈俊俊 committed
86 87 88 89 90 91 92
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [PasengerCell cellHeight];
}
陈俊俊's avatar
陈俊俊 committed
93 94 95
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [[NSNotificationCenter defaultCenter]postNotificationName:KNOTIFICATION_GetNextDetailData object:nil userInfo:@{@"indexPath":indexPath}];
}
陈俊俊's avatar
陈俊俊 committed
96 97 98 99 100 101 102 103 104

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    PassengerHeaderCell *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:passengerHeaderIdentify];
    
    if (headerView == nil) {
        headerView = [[PassengerHeaderCell alloc] initWithReuseIdentifier:passengerHeaderIdentify];
    }
    
陈俊俊's avatar
陈俊俊 committed
105 106
    [headerView buildLayout:@"客流"];
    [headerView setTotalValue:[NSString stringWithFormat:@"共%ld家",(long)self.count]];
陈俊俊's avatar
陈俊俊 committed
107
    [headerView changeTypeName:self.typeStr];
陈俊俊's avatar
陈俊俊 committed
108 109
    return headerView;
}
陈俊俊's avatar
陈俊俊 committed
110
- (void)detailClick:(UIButton *)btn{
111 112 113 114 115 116
    Compass *com = self.dataArr[btn.tag];
    NSObject *comObj = [NSNull null];
    if (com) {
        comObj = com;
    }
    [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_GoReportDetail object:nil userInfo:@{@"compass":comObj}];
陈俊俊's avatar
陈俊俊 committed
117
}
陈俊俊's avatar
陈俊俊 committed
118 119


120

陈俊俊's avatar
陈俊俊 committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return [PassengerHeaderCell viewHeight];
}



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

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end