SurveyListCell.m 4.45 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
//
//  SurveyListCell.m
//  XFFurit
//
//  Created by 陈俊俊 on 15/8/1.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "SurveyListCell.h"

#define TitleSize 16
#define ContentSize 14
#define TitleColor @"444444"
#define ContentColor @"aaaaaa"
15
#define LeftMargin 90
陈俊俊's avatar
陈俊俊 committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#define TopMargin 10
#define TitleHeight 20
#define TableHeight 120
@implementation SurveyListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self bulidLayout];
    }
    return self;
}

- (void)bulidLayout
{
    self.stateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
33
    self.stateBtn.frame = CGRectMake(TopMargin *2 , TopMargin, LeftMargin - TopMargin*3, 20);
n22's avatar
n22 committed
34 35
    self.stateBtn.titleLabel.font = FontSize(ContentSize);
    [self.stateBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
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
    self.stateBtn.enabled = NO;
    
    self.titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, TopMargin, ScreenSize.width - LeftMargin, TitleHeight))];
    self.titleLabel.textColor = HexColor(TitleColor);
    self.titleLabel.font = FontSize(TitleSize);
    
    self.billnumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.titleLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
    self.billnumberLabel.textColor = HexColor(ContentColor);
    self.billnumberLabel.font = FontSize(ContentSize);
    
    self.productnameLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.billnumberLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
    self.productnameLabel.textColor = HexColor(ContentColor);
    self.productnameLabel.font = FontSize(ContentSize);
    
    
    self.begindateLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.productnameLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
    self.begindateLabel.textColor = HexColor(ContentColor);
    self.begindateLabel.font = FontSize(ContentSize);
    
    self.enddateLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin, CGRectGetMaxY(self.begindateLabel.frame), ScreenSize.width - LeftMargin, TitleHeight))];
    self.enddateLabel.textColor = HexColor(ContentColor);
    self.enddateLabel.font = FontSize(ContentSize);
    
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(LeftMargin,TableHeight-1, ScreenSize.width - LeftMargin - TopMargin * 2, 1))];;
    self.lineLabel.backgroundColor = HexColor(@"e5e5e5");
    
    [self.contentView addSubview:self.stateBtn];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.billnumberLabel];
    [self.contentView addSubview:self.productnameLabel];
    [self.contentView addSubview:self.begindateLabel];
    [self.contentView addSubview:self.enddateLabel];
    [self.contentView addSubview:self.lineLabel];

}


- (void)setSurvey:(Survey *)survey{
    self.titleLabel.text = survey.title;
陈俊俊's avatar
陈俊俊 committed
75 76 77 78
    self.billnumberLabel.text = [NSString stringWithFormat:@"单号:%@",survey.billNumber];
    self.productnameLabel.text = [NSString stringWithFormat:@"商品:%@[%@]",survey.productName,survey.productCode];
    self.begindateLabel.text = [NSString stringWithFormat:@"开始时间:%@",[survey.beginDate substringToIndex:10]];
    self.enddateLabel.text = [NSString stringWithFormat:@"结束时间:%@",[survey.endDate substringToIndex:10]];
n22's avatar
n22 committed
79
    NSString *stateStr = @"";
n22's avatar
n22 committed
80
    if ([survey.state isEqualToString:@"initial"]) {
n22's avatar
n22 committed
81 82
        stateStr = @"未提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"initial"]  forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
83
    }else if ([survey.state isEqualToString:@"submitted"]) {
n22's avatar
n22 committed
84 85
        stateStr = @"已提交";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
86
    }else if ([survey.state isEqualToString:@"insurvey"]) {
n22's avatar
n22 committed
87 88
        stateStr = @"调研中";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"insurvey"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
89
        
陈俊俊's avatar
陈俊俊 committed
90
    }else if ([survey.state isEqualToString:@"finished"]) {
n22's avatar
n22 committed
91 92
        stateStr = @"已完成";
        [self.stateBtn setBackgroundImage:[UIImage imageNamed:@"finish"] forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
93
    }
n22's avatar
n22 committed
94
    [self.stateBtn setTitle:stateStr forState:UIControlStateNormal];
陈俊俊's avatar
陈俊俊 committed
95 96 97 98 99 100 101
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end