GrossRateViewController.m 4.73 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//
//  GrossRateViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/11/13.
//  Copyright © 2015年 Xummer. All rights reserved.
//

#import "GrossRateViewController.h"
#import "ReportDetailViewController.h"
#import "CustomSegView.h"
#import "SMPageControl.h"
#import "PasengerCell.h"
#import "PassengerHeaderCell.h"
#import "RPassgerView.h"
#define LeftWidth   50

static NSString *grossRateViewHeaderController = @"grossRateViewHeaderController";


21
@interface GrossRateViewController ()<UITableViewDataSource,UITableViewDelegate>
陈俊俊's avatar
陈俊俊 committed
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
@property (nonatomic,strong)SMPageControl *pageControl;

@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)RPassgerView *rpassgerView;


@end

@implementation GrossRateViewController

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


#pragma mark - 布局
- (void)bulidLayout{
    self.view .backgroundColor = [UIColor whiteColor];
    CGRect rect = CGRectMake(0, 0, ScreenSize.width, 145);
    self.bgView = [[UIView alloc]initWithFrame:rect];
    
    rect = CGRectMake(0, 0, ScreenSize.width, 130);
    self.rpassgerView = [[RPassgerView alloc]initWithFrame:rect];
    [self.bgView addSubview:self.rpassgerView];
    
    
    self.pageControl = [[SMPageControl alloc]initWithFrame:CGRectMake(0, self.rpassgerView.bottom, self.view.width, 10)];
    self.pageControl.numberOfPages = 4;

    self.pageControl.currentPage = 3;
53 54 55 56
    self.pageControl.pageIndicatorImage = [UIImage imageNamed:@"white_point"];
    self.pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"yellow_point"];
//    self.pageControl.pageIndicatorTintColor = XXFBgColor;
//    self.pageControl.currentPageIndicatorTintColor = GXF_COMMIT_COLOR;
陈俊俊's avatar
陈俊俊 committed
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
    self.pageControl.indicatorMargin = 15.0f;
    
    self.pageControl.indicatorDiameter = 10.0f;
    [self.bgView addSubview:self.pageControl];
    
    rect = CGRectMake(0, 0, self.view.width, self.view.height - 158);
    self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[PassengerHeaderCell class] forHeaderFooterViewReuseIdentifier:grossRateViewHeaderController];
    self.tableView.tableHeaderView = self.bgView;
    
    [self.view addSubview:self.tableView];
    
}
- (void)setValueInGrossRate:(Compass *)compass{
    [self.rpassgerView setGrossprofitWithCompass:compass];
}

#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *passgerPriceCellIdentify = @"grossRateViewHeaderController";
    
    PasengerCell *cell = [tableView dequeueReusableCellWithIdentifier:passgerPriceCellIdentify];
    
    if(cell == nil) {
        cell = [[PasengerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:passgerPriceCellIdentify];
    }
    //没有选中风格
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //取消分割线
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
96 97
    Compass *test = _dataArr[indexPath.row];
    [cell setColorAndFont:test.level];
陈俊俊's avatar
陈俊俊 committed
98 99 100 101 102 103 104 105
    if(test != nil) {
        [cell updateCellWithGross:test index:indexPath];
    }
    cell.detailBtn.tag = indexPath.row;
    [cell.detailBtn addTarget:self action:@selector(detailClick:) forControlEvents:UIControlEventTouchUpInside];
    return cell;
}
- (void)detailClick:(UIButton *)btn{
106
    [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_GoReportDetail object:nil];
陈俊俊's avatar
陈俊俊 committed
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
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [PasengerCell cellHeight];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [[NSNotificationCenter defaultCenter]postNotificationName:KNOTIFICATION_GetNextDetailData object:nil userInfo:@{@"indexPath":indexPath}];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    PassengerHeaderCell *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:grossRateViewHeaderController];
    
    if (headerView == nil) {
        headerView = [[PassengerHeaderCell alloc] initWithReuseIdentifier:grossRateViewHeaderController];
    }
    
    [headerView buildLayout:@"毛利率"];
    [headerView setTotalValue:[NSString stringWithFormat:@"共%ld家",(long)self.count]];
    return headerView;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return [PassengerHeaderCell viewHeight];
}

@end