Nessuna descrizione

FKSubmitSingleChannelView.m 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //
  2. // FKSubmitSingleChannelView.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/1/19.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKSubmitSingleChannelView.h"
  9. @interface FKSubmitSingleChannelView ()
  10. @property (nonatomic, strong) UIImageView *iconImgView;
  11. @end
  12. @implementation FKSubmitSingleChannelView
  13. - (instancetype)initWithFrame:(CGRect)frame{
  14. if (self = [super initWithFrame:frame]) {
  15. [self addAllSubviews];
  16. }
  17. return self;
  18. }
  19. - (void)addAllSubviews{
  20. [self addSubview:self.iconImgView];
  21. [self addSubview:self.channelLabel];
  22. [self addSubview:self.ruleLabel];
  23. [self addSubview:self.priceLabel];
  24. [self addSubview:self.billWightLabel];
  25. [self addSubview:self.bottomLine];
  26. [self addSubview:self.clickActionBtn];
  27. [self addSubview:self.arrowBtn];
  28. [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.equalTo(self).offset(10);
  30. make.centerY.equalTo(self.mas_top).offset(34.5);
  31. }];
  32. [self.channelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.bottom.equalTo(self.mas_top).offset(29.5);
  34. make.left.equalTo(self.iconImgView.mas_right).offset(10);
  35. make.right.equalTo(self.priceLabel.mas_left).offset(- 5);
  36. }];
  37. [self.ruleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(self.mas_top).offset(39.5);
  39. make.left.equalTo(self.channelLabel);
  40. make.right.equalTo(self).offset(- 10);
  41. }];
  42. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.centerY.equalTo(self.channelLabel);
  44. make.right.equalTo(self).offset(- 5);
  45. }];
  46. // [self.priceCutLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  47. // make.right.equalTo(self).offset(- 5);
  48. // make.top.equalTo(self).offset(39.5);
  49. // }];
  50. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(self).offset(10);
  52. make.right.equalTo(self).offset(- 10);
  53. make.bottom.equalTo(self);
  54. make.height.mas_equalTo(0.5);
  55. }];
  56. [self.billWightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.bottom.equalTo(self);
  58. make.top.equalTo(self.ruleLabel.mas_bottom);
  59. make.right.equalTo(self.priceLabel);
  60. }];
  61. [self.clickActionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.edges.insets(UIEdgeInsetsMake(0, 0, 0, - 50));
  63. }];
  64. [self.arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.centerY.equalTo(self.ruleLabel);
  66. make.right.equalTo(self);
  67. make.size.mas_equalTo(CGSizeMake(45, 50));
  68. }];
  69. }
  70. - (void)resetContentForChannelItem:(FKTransformChannelItem *)channelItem
  71. enable:(BOOL)enable
  72. billWeight:(NSString *)billWeight
  73. {
  74. if (!channelItem) return;
  75. self.channelType = channelItem.channelType;
  76. self.channelLabel.text = channelItem.name;
  77. self.ruleLabel.text = channelItem.postageRule;
  78. self.priceLabel.text = [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:channelItem.price]];
  79. if (!enable) {
  80. // 不可选
  81. self.channelLabel.textColor = UIColorFromRGB(0xcccccc);
  82. self.ruleLabel.textColor = UIColorFromRGB(0xcccccc);
  83. self.priceLabel.textColor = UIColorFromRGB(0xcccccc);
  84. self.iconImgView.hidden = YES;
  85. self.clickActionBtn.userInteractionEnabled = NO;
  86. }else{
  87. self.iconImgView.hidden = NO;
  88. self.clickActionBtn.userInteractionEnabled = YES;
  89. self.channelLabel.textColor = UIColorFromRGB(0x333333);
  90. self.ruleLabel.textColor = UIColorFromRGB(0x999999);
  91. self.priceLabel.textColor = UIColorFromRGB(0x999999);
  92. }
  93. if (channelItem.selected) {
  94. self.iconImgView.image = [UIImage imageNamed:@"submit_channel_chose_h"];
  95. }else{
  96. self.iconImgView.image = [UIImage imageNamed:@"basket_unSelect"];
  97. }
  98. if (billWeight) {
  99. self.billWightLabel.hidden = NO;
  100. self.billWightLabel.text = billWeight;
  101. } else{
  102. self.billWightLabel.text = nil;
  103. self.billWightLabel.hidden = YES;
  104. }
  105. }
  106. #pragma mark - property
  107. - (UIImageView *)iconImgView{
  108. if (_iconImgView == nil) {
  109. _iconImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"submit_channel_chose_n"]];
  110. [_iconImgView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  111. [_iconImgView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  112. }
  113. return _iconImgView;
  114. }
  115. - (UILabel *)channelLabel{
  116. if (_channelLabel == nil) {
  117. _channelLabel = [[UILabel alloc]init];
  118. _channelLabel.textColor = UIColorFromRGB(0x333333);
  119. _channelLabel.font = [UIFont systemFontOfSize:14];
  120. _channelLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  121. }
  122. return _channelLabel;
  123. }
  124. - (UILabel *)ruleLabel{
  125. if (_ruleLabel == nil) {
  126. _ruleLabel = [[UILabel alloc]init];
  127. _ruleLabel.textColor = UIColorFromRGB(0x666666);
  128. _ruleLabel.font = [UIFont systemFontOfSize:12];
  129. }
  130. return _ruleLabel;
  131. }
  132. - (UILabel *)priceLabel{
  133. if (_priceLabel == nil) {
  134. _priceLabel = [[UILabel alloc]init];
  135. _priceLabel.textColor = UIColorFromRGB(0x333333);
  136. _priceLabel.font = [UIFont systemFontOfSize:14];
  137. [_priceLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  138. [_priceLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  139. }
  140. return _priceLabel;
  141. }
  142. //- (UILabel *)priceCutLabel{
  143. // if (_priceCutLabel == nil) {
  144. // _priceCutLabel = [[UILabel alloc]init];
  145. // _priceCutLabel.textColor = UIColorFromRGB(0xff624a);
  146. // _priceCutLabel.font = [UIFont systemFontOfSize:12];
  147. // if (UISCREENWIDTH <= 320) _priceCutLabel.font = [UIFont systemFontOfSize:11]; // 适配45
  148. // [_priceCutLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  149. // [_priceCutLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  150. // }
  151. // return _priceCutLabel;
  152. //}
  153. - (UIView *)bottomLine{
  154. if (_bottomLine == nil) {
  155. _bottomLine = [[UIView alloc]init];
  156. _bottomLine.backgroundColor = UIColorFromRGB(0xcccccc);
  157. }
  158. return _bottomLine;
  159. }
  160. - (UIButton *)clickActionBtn{
  161. if (_clickActionBtn == nil) {
  162. _clickActionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  163. }
  164. return _clickActionBtn;
  165. }
  166. - (UIButton *)arrowBtn{
  167. if (_arrowBtn == nil) {
  168. _arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  169. [_arrowBtn setImage:[UIImage imageNamed:@"submit_arrow_down"] forState:UIControlStateNormal];
  170. [_arrowBtn setImage:[UIImage imageNamed:@"submit_arrow_up"] forState:UIControlStateSelected];
  171. }
  172. return _arrowBtn;
  173. }
  174. - (UILabel *)billWightLabel{
  175. if (_billWightLabel == nil) {
  176. _billWightLabel = [[UILabel alloc]init];
  177. _billWightLabel.font = [UIFont systemFontOfSize:11];
  178. _billWightLabel.textColor = UIColorFromRGB(0x666666);
  179. _billWightLabel.textAlignment = NSTextAlignmentCenter;
  180. }
  181. return _billWightLabel;
  182. }
  183. @end