123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- //
- // FKSubmitSingleChannelView.m
- // FirstLink
- //
- // Created by jack on 16/1/19.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKSubmitSingleChannelView.h"
- @interface FKSubmitSingleChannelView ()
- @property (nonatomic, strong) UIImageView *iconImgView;
- @end
- @implementation FKSubmitSingleChannelView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- [self addAllSubviews];
- }
- return self;
- }
- - (void)addAllSubviews{
-
- [self addSubview:self.iconImgView];
- [self addSubview:self.channelLabel];
- [self addSubview:self.ruleLabel];
- [self addSubview:self.priceLabel];
- [self addSubview:self.billWightLabel];
- [self addSubview:self.bottomLine];
-
- [self addSubview:self.clickActionBtn];
- [self addSubview:self.arrowBtn];
-
- [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(10);
- make.centerY.equalTo(self.mas_top).offset(34.5);
- }];
-
- [self.channelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.mas_top).offset(29.5);
- make.left.equalTo(self.iconImgView.mas_right).offset(10);
- make.right.equalTo(self.priceLabel.mas_left).offset(- 5);
- }];
-
- [self.ruleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.mas_top).offset(39.5);
- make.left.equalTo(self.channelLabel);
- make.right.equalTo(self).offset(- 10);
- }];
-
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.channelLabel);
- make.right.equalTo(self).offset(- 5);
- }];
-
- // [self.priceCutLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.right.equalTo(self).offset(- 5);
- // make.top.equalTo(self).offset(39.5);
- // }];
-
- [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self).offset(10);
- make.right.equalTo(self).offset(- 10);
- make.bottom.equalTo(self);
- make.height.mas_equalTo(0.5);
- }];
-
- [self.billWightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.bottom.equalTo(self);
- make.top.equalTo(self.ruleLabel.mas_bottom);
- make.right.equalTo(self.priceLabel);
- }];
-
- [self.clickActionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.insets(UIEdgeInsetsMake(0, 0, 0, - 50));
- }];
-
- [self.arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.ruleLabel);
- make.right.equalTo(self);
- make.size.mas_equalTo(CGSizeMake(45, 50));
- }];
- }
- - (void)resetContentForChannelItem:(FKTransformChannelItem *)channelItem
- enable:(BOOL)enable
- billWeight:(NSString *)billWeight
- {
-
- if (!channelItem) return;
-
- self.channelType = channelItem.channelType;
- self.channelLabel.text = channelItem.name;
- self.ruleLabel.text = channelItem.postageRule;
- self.priceLabel.text = [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:channelItem.price]];
-
- if (!enable) {
- // 不可选
- self.channelLabel.textColor = UIColorFromRGB(0xcccccc);
- self.ruleLabel.textColor = UIColorFromRGB(0xcccccc);
- self.priceLabel.textColor = UIColorFromRGB(0xcccccc);
-
- self.iconImgView.hidden = YES;
- self.clickActionBtn.userInteractionEnabled = NO;
-
- }else{
- self.iconImgView.hidden = NO;
- self.clickActionBtn.userInteractionEnabled = YES;
-
- self.channelLabel.textColor = UIColorFromRGB(0x333333);
- self.ruleLabel.textColor = UIColorFromRGB(0x999999);
- self.priceLabel.textColor = UIColorFromRGB(0x999999);
- }
-
- if (channelItem.selected) {
- self.iconImgView.image = [UIImage imageNamed:@"submit_channel_chose_h"];
- }else{
- self.iconImgView.image = [UIImage imageNamed:@"basket_unSelect"];
- }
- if (billWeight) {
- self.billWightLabel.hidden = NO;
- self.billWightLabel.text = billWeight;
- } else{
- self.billWightLabel.text = nil;
- self.billWightLabel.hidden = YES;
- }
- }
- #pragma mark - property
- - (UIImageView *)iconImgView{
- if (_iconImgView == nil) {
- _iconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"submit_channel_chose_n"]];
- [_iconImgView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [_iconImgView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _iconImgView;
- }
- - (UILabel *)channelLabel{
- if (_channelLabel == nil) {
- _channelLabel = [[UILabel alloc]init];
- _channelLabel.textColor = UIColorFromRGB(0x333333);
- _channelLabel.font = [UIFont systemFontOfSize:14];
- _channelLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- }
- return _channelLabel;
- }
- - (UILabel *)ruleLabel{
- if (_ruleLabel == nil) {
- _ruleLabel = [[UILabel alloc]init];
- _ruleLabel.textColor = UIColorFromRGB(0x666666);
- _ruleLabel.font = [UIFont systemFontOfSize:12];
- }
- return _ruleLabel;
- }
- - (UILabel *)priceLabel{
- if (_priceLabel == nil) {
- _priceLabel = [[UILabel alloc]init];
- _priceLabel.textColor = UIColorFromRGB(0x333333);
- _priceLabel.font = [UIFont systemFontOfSize:14];
- [_priceLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [_priceLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _priceLabel;
- }
- //- (UILabel *)priceCutLabel{
- // if (_priceCutLabel == nil) {
- // _priceCutLabel = [[UILabel alloc]init];
- // _priceCutLabel.textColor = UIColorFromRGB(0xff624a);
- // _priceCutLabel.font = [UIFont systemFontOfSize:12];
- // if (UISCREENWIDTH <= 320) _priceCutLabel.font = [UIFont systemFontOfSize:11]; // 适配45
- // [_priceCutLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- // [_priceCutLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- // }
- // return _priceCutLabel;
- //}
- - (UIView *)bottomLine{
- if (_bottomLine == nil) {
- _bottomLine = [[UIView alloc]init];
- _bottomLine.backgroundColor = UIColorFromRGB(0xcccccc);
- }
- return _bottomLine;
- }
- - (UIButton *)clickActionBtn{
- if (_clickActionBtn == nil) {
- _clickActionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- }
- return _clickActionBtn;
- }
- - (UIButton *)arrowBtn{
- if (_arrowBtn == nil) {
- _arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_arrowBtn setImage:[UIImage imageNamed:@"submit_arrow_down"] forState:UIControlStateNormal];
- [_arrowBtn setImage:[UIImage imageNamed:@"submit_arrow_up"] forState:UIControlStateSelected];
- }
- return _arrowBtn;
- }
- - (UILabel *)billWightLabel{
- if (_billWightLabel == nil) {
- _billWightLabel = [[UILabel alloc]init];
- _billWightLabel.font = [UIFont systemFontOfSize:11];
- _billWightLabel.textColor = UIColorFromRGB(0x666666);
- _billWightLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _billWightLabel;
- }
- @end
|