PassgerPriceViewController.m 8.31 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 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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
//
//  PassgerPriceViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/11/8.
//  Copyright © 2015年 Xummer. All rights reserved.
//

#import "PassgerPriceViewController.h"
#import "CustomSegView.h"
#import "SMPageControl.h"
#import "PassgerPriceCell.h"
#import "PassgerPriceHeaderCell.h"
#define LeftWidth   50

static NSString *passgerPriceCellIdentify = @"PassgerPriceCellIdentify";
static NSString *passgerPriceHeaderIdentify = @"PassgerPriceHeaderIdentify";


@interface PassgerPriceViewController ()<CustomSegViewDelegate,UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)CustomSegView *segView;
@property (nonatomic,strong)SMPageControl *pageControl;
@property (nonatomic,strong)UILabel *centerLabel;
@property (nonatomic,strong)UIImageView *centerImage;
@property (nonatomic,strong)UILabel *dateLabel;
@property (nonatomic,strong)UILabel *lastWeekLabel;
@property (nonatomic,strong)UILabel *lastYearLabel;
@property (nonatomic,strong)UILabel *rateLabel;
@property (nonatomic,strong)UILabel *averageLabel;
@property (nonatomic,strong)UIImageView *lastWeekImage;
@property (nonatomic,strong)UIImageView *lastYearImage;

@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataArr;
@end

@implementation PassgerPriceViewController

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


#pragma mark - 布局
- (void)bulidLayout{
    self.view .backgroundColor = [UIColor whiteColor];
    CGRect rect = CGRectMake(10, 10, ScreenSize.width - 10*2, 30);
    NSArray *arr = @[SaleDay,SaleWeek,SaleMonth];
    self.segView = [[CustomSegView alloc]initWithFrame:rect withArr:arr];
    self.segView.delegate = self;
    [self.view addSubview:self.segView];
    
    rect = CGRectMake(50, self.segView.bottom + 20, 30 , 30);
    self.centerImage = [[UIImageView alloc]initWithFrame:rect];
    self.centerImage.image = [UIImage imageNamed:@"goSale"];
    [self.view addSubview:self.centerImage];
    
    rect = CGRectMake(self.centerImage.right + 5, self.segView.bottom + 20, ScreenSize.width - self.centerImage.right, 30);
    self.centerLabel = [[UILabel alloc]initWithFrame:rect];
    self.centerLabel.text = @"35.68%";
    self.centerLabel.font = [UIFont boldSystemFontOfSize:30];
    self.centerLabel.textColor = [UIColor redColor];
    [self.view addSubview:self.centerLabel];
    
    
    rect = CGRectMake(0, self.centerLabel.bottom,ScreenSize.width, 20);
    self.dateLabel = [[UILabel alloc]initWithFrame:rect];
    self.dateLabel.textColor = GXF_CONTENT_COLOR;
    self.dateLabel.font =  GXF_FOURTEENTH_SIZE;
    self.dateLabel.textAlignment = NSTextAlignmentCenter;
    self.dateLabel.text = @"2015-10-21星期一累计毛利率";
    [self.view addSubview:self.dateLabel];
    
    CGFloat bottomWidth = (ScreenSize.width - 20*2)/2;
    
    rect = CGRectMake(20, self.dateLabel.bottom,40,30);
    UILabel *weekLabel = [[UILabel alloc]initWithFrame:rect];
    weekLabel.textColor = [UIColor lightGrayColor];
    weekLabel.text = @"比上周";
    weekLabel.font = GXF_THREETEENTH_SIZE;
    [self.view addSubview:weekLabel];
    
    rect = CGRectMake(weekLabel.right, self.dateLabel.bottom,30, 30);
    UIImageView *lastImage = [[UIImageView alloc]initWithFrame:rect];
    lastImage.image = [UIImage imageNamed:@"goSale"];
    [self.view addSubview:lastImage];
    self.lastWeekImage = lastImage;
    
    rect = CGRectMake(lastImage.right, lastImage.top,bottomWidth - lastImage.width - weekLabel.width, 30);
    self.lastWeekLabel = [[UILabel alloc]initWithFrame:rect];
    self.lastWeekLabel.textColor = GXF_CONTENT_COLOR;
    self.lastWeekLabel.text = @"13.2%";
    self.lastWeekLabel.textColor = [UIColor redColor];
    [self.view addSubview:self.lastWeekLabel];
    
    
    
    rect = CGRectMake(self.lastWeekLabel.right, self.dateLabel.bottom,40,30);
    UILabel *yearLabel = [[UILabel alloc]initWithFrame:rect];
    yearLabel.textColor = [UIColor lightGrayColor];
    yearLabel.text = @"比去年";
    yearLabel.font = GXF_THREETEENTH_SIZE;
    [self.view addSubview:yearLabel];
    
    
    
    rect = CGRectMake(yearLabel.right, lastImage.top,30, 30);
    UIImageView *yearImage = [[UIImageView alloc]initWithFrame:rect];
    yearImage.image = [UIImage imageNamed:@"downSale"];
    [self.view addSubview:yearImage];
    self.lastYearImage = yearImage;
    
    rect = CGRectMake(yearImage.right, lastImage.top,bottomWidth - yearImage.width - yearLabel.width, 30);
    self.lastYearLabel = [[UILabel alloc]initWithFrame:rect];
    self.lastYearLabel.textColor = GXF_CONTENT_COLOR;
    self.lastYearLabel.text = @"13.2%";
    self.lastYearLabel.textColor = GXF_NAVIGAYION_COLOR;
    [self.view addSubview:self.lastYearLabel];
    
    
    
    self.pageControl = [[SMPageControl alloc]initWithFrame:CGRectMake(0, weekLabel.bottom + 5 , self.view.width, 20)];
    self.pageControl.currentPage = 0;
    self.pageControl.pageIndicatorTintColor = XXFBgColor;
    self.pageControl.currentPageIndicatorTintColor = GXF_NAVIGAYION_COLOR;
    self.pageControl.numberOfPages = 3;
    self.pageControl.indicatorMargin = 15.0f;
    self.pageControl.currentPage = 2;
    self.pageControl.indicatorDiameter = 15.0f;
    [self.view addSubview:self.pageControl];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pageClick)];
    [self.pageControl addGestureRecognizer:tap];
    
    CLog(@"%f---------",self.view.height);
    
    rect = CGRectMake(0, self.pageControl.bottom + 5, self.view.width, self.view.height - self.pageControl.bottom - 118);
    self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //    self.tableView.backgroundColor = [UIColor redColor];
    [self.tableView registerClass:[PassgerPriceCell class] forCellReuseIdentifier:passgerPriceCellIdentify];
    [self.tableView registerClass:[PassgerPriceHeaderCell class] forHeaderFooterViewReuseIdentifier:passgerPriceHeaderIdentify];
    
    
    [self.view addSubview:self.tableView];
    
}


#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PassgerPriceCell *cell = (PassgerPriceCell *)[tableView dequeueReusableCellWithIdentifier:passgerPriceCellIdentify forIndexPath:indexPath];
    
    if(cell == nil) {
        cell = [[PassgerPriceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:passgerPriceCellIdentify];
    }
    //没有选中风格
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //取消分割线
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
    //    if(task != nil) {
    [cell updateCellWith:nil index:indexPath];
    //        cell.delegate = self;
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [PassgerPriceCell cellHeight];
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    PassgerPriceHeaderCell *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:passgerPriceHeaderIdentify];
    
    if (headerView == nil) {
        headerView = [[PassgerPriceHeaderCell alloc] initWithReuseIdentifier:passgerPriceHeaderIdentify];
    }
    
    [headerView buildLayout];
    
    return headerView;
}


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

- (void)pageClick{
    CLog(@"=====");
}


#pragma mark - segViewDelegate
- (void)customSegOneClick:(NSString *)title{
    //日周年切换
    
}
- (void)customSegTwoClick:(NSString *)title{
    //选择历史查看
}


- (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