|
|
@@ -7,29 +7,38 @@
|
|
|
//
|
|
|
|
|
|
#import "HJJoinTableViewCell.h"
|
|
|
-#import "HJFullTimeCellView.h"
|
|
|
-#import "HJClockLabel.h"
|
|
|
+#import "UILabel+HJTitleTagLabel.h"
|
|
|
+#import "FBFlowLayoutView.h"
|
|
|
+#import "NSString+FBBoundingSize.h"
|
|
|
|
|
|
-@interface HJJoinTableViewCell ()
|
|
|
+@interface HJJoinTableViewCell () <FBFlowLayoutDelegate, FBFlowLayoutDataSource>
|
|
|
@property (nonatomic, strong) UIView *bgView;
|
|
|
-@property (nonatomic, strong) HJFullTimeCellView *fullTimeCell;
|
|
|
-@property (nonatomic, strong) UIView *footerView;
|
|
|
-@property (nonatomic, strong) UILabel *peopleCountLabel;
|
|
|
-@property (nonatomic, strong) HJClockLabel *clockLabel;
|
|
|
+@property (nonatomic, assign) UIEdgeInsets edgeInsets;
|
|
|
+@property (nonatomic, strong) UILabel *titleTagLabel;
|
|
|
+@property (nonatomic, strong) FBFlowLayoutView *welfareView;
|
|
|
+@property (nonatomic, strong) UIView *lineH;
|
|
|
+@property (nonatomic, strong) UIView *footer;
|
|
|
@end
|
|
|
|
|
|
@implementation HJJoinTableViewCell
|
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
|
- self.contentView.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1.0];
|
|
|
+ _edgeInsets = UIEdgeInsetsMake(20, 15, 0, 15);
|
|
|
|
|
|
[self.contentView addSubview:self.bgView];
|
|
|
- [self.bgView addSubview:self.fullTimeCell];
|
|
|
- [self.bgView addSubview:self.footerView];
|
|
|
- [self.footerView addSubview:self.peopleCountLabel];
|
|
|
- [self.footerView addSubview:self.clockLabel];
|
|
|
-
|
|
|
+ [self.contentView addSubview:self.titleLabel];
|
|
|
+ [self.contentView addSubview:self.titleTagLabel];
|
|
|
+ [self.contentView addSubview:self.moneyLabel];
|
|
|
+ [self.contentView addSubview:self.companyLabel];
|
|
|
+ [self.contentView addSubview:self.addressLabel];
|
|
|
+ [self.contentView addSubview:self.welfareView];
|
|
|
+ [self.contentView addSubview:self.maxMoneyLabel];
|
|
|
+ [self.contentView addSubview:self.dateLabel];
|
|
|
+ [self.contentView addSubview:self.lineH];
|
|
|
+ [self.contentView addSubview:self.peopleCountLabel];
|
|
|
+ [self.contentView addSubview:self.clockLabel];
|
|
|
+ [self.contentView addSubview:self.footer];
|
|
|
[self makeConstraints];
|
|
|
}
|
|
|
return self;
|
|
|
@@ -37,80 +46,247 @@
|
|
|
|
|
|
- (void)makeConstraints {
|
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.left.right.equalTo(self.contentView);
|
|
|
- make.bottom.equalTo(self.contentView).with.offset(-9);
|
|
|
+ make.edges.equalTo(self.contentView).with.insets(self.edgeInsets);
|
|
|
+ }];
|
|
|
+ [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.left.equalTo(self.bgView);
|
|
|
+ }];
|
|
|
+ [self.titleTagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.titleLabel.mas_right).with.offset(8);
|
|
|
+ make.centerY.equalTo(self.titleLabel);
|
|
|
+ make.size.mas_equalTo(CGSizeMake(33, 16));
|
|
|
+ }];
|
|
|
+ [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.equalTo(self.bgView);
|
|
|
+ make.top.height.equalTo(self.titleLabel);
|
|
|
+ make.left.greaterThanOrEqualTo(self.titleTagLabel.mas_right);
|
|
|
+ make.width.mas_greaterThanOrEqualTo(120);
|
|
|
+ }];
|
|
|
+ [self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.titleLabel.mas_bottom).with.offset(6);
|
|
|
+ make.left.equalTo(self.titleLabel);
|
|
|
+ make.right.equalTo(self.addressLabel.mas_left).with.offset(-8);
|
|
|
}];
|
|
|
- [self.fullTimeCell mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.bgView).with.offset(20);
|
|
|
- make.left.equalTo(self.bgView).with.offset(15);
|
|
|
- make.right.equalTo(self.bgView).with.offset(-15);
|
|
|
- make.bottom.equalTo(self.footerView.mas_top).with.offset(0);
|
|
|
+ [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.companyLabel);
|
|
|
+ make.right.equalTo(self.moneyLabel);
|
|
|
}];
|
|
|
- [self.footerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.equalTo(self.fullTimeCell);
|
|
|
- make.right.equalTo(self.fullTimeCell);
|
|
|
- make.bottom.equalTo(self.bgView);
|
|
|
- make.height.mas_equalTo(28);
|
|
|
+ [self.welfareView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.equalTo(self.bgView);
|
|
|
+ make.top.equalTo(self.companyLabel.mas_bottom).with.offset(6);
|
|
|
+ }];
|
|
|
+ [self.maxMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.welfareView.mas_bottom).with.offset(6);
|
|
|
+ make.left.equalTo(self.titleLabel);
|
|
|
+ }];
|
|
|
+ [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.welfareView.mas_bottom).with.offset(6);
|
|
|
+ make.left.greaterThanOrEqualTo(self.maxMoneyLabel.mas_right).with.offset(8);
|
|
|
+ make.right.equalTo(self.moneyLabel);
|
|
|
+ make.width.mas_greaterThanOrEqualTo(60);
|
|
|
+ }];
|
|
|
+ [self.lineH mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.dateLabel.mas_bottom).with.offset(12);
|
|
|
+ make.left.right.equalTo(self.bgView);
|
|
|
+ make.height.mas_equalTo(0.6);
|
|
|
}];
|
|
|
[self.peopleCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.bottom.equalTo(self.footerView);
|
|
|
- make.top.equalTo(self.footerView).with.offset(1);
|
|
|
- make.width.mas_equalTo(130);
|
|
|
+ make.left.equalTo(self.bgView);
|
|
|
+ make.top.equalTo(self.lineH.mas_bottom).with.offset(8);
|
|
|
+ make.right.equalTo(self.clockLabel.mas_left).with.offset(-5);
|
|
|
}];
|
|
|
[self.clockLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.right.bottom.equalTo(self.footerView);
|
|
|
- make.top.equalTo(self.footerView).with.offset(1);
|
|
|
- make.left.equalTo(self.peopleCountLabel.mas_right);
|
|
|
+ make.right.equalTo(self.bgView);
|
|
|
+ make.top.equalTo(self.peopleCountLabel);
|
|
|
+ make.width.mas_equalTo(175);
|
|
|
+ }];
|
|
|
+ [self.footer mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.peopleCountLabel.mas_bottom).with.offset(8);
|
|
|
+ make.left.right.equalTo(self.contentView);
|
|
|
+ make.height.mas_equalTo(9);
|
|
|
}];
|
|
|
+ [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.equalTo(self.footer);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - CustomDelegate
|
|
|
+
|
|
|
+- (CGFloat)estimateWidthInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
|
|
|
+ return (SCREEN_WIDTH - self.edgeInsets.left - self.edgeInsets.right);
|
|
|
+}
|
|
|
+
|
|
|
+- (CGFloat)subviewHorizontalSpacingInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
|
|
|
+ return 6;
|
|
|
+}
|
|
|
+
|
|
|
+- (CGFloat)subviewVerticalSpacingInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
|
|
|
+ return 6;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSUInteger)numberInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
|
|
|
+ return self.welfareTagArray.count;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)flowLayoutView:(FBFlowLayoutView *)flowLayoutView subviewAtIndex:(NSUInteger)index {
|
|
|
+ NSString *title = self.welfareTagArray[index];
|
|
|
+
|
|
|
+ UIColor *color = [UIColor colorWithRed:191/255.0 green:128/255.0 blue:48/255.0 alpha:1.0];
|
|
|
+ UIFont *font = [UIFont systemFontOfSize:9];
|
|
|
+ UIButton *tagButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [tagButton setTitle:title forState:UIControlStateNormal];
|
|
|
+ [tagButton setTitleColor:color forState:UIControlStateNormal];
|
|
|
+ tagButton.titleLabel.font = font;
|
|
|
+ tagButton.titleLabel.numberOfLines = 0;
|
|
|
+ tagButton.layer.cornerRadius = 3;
|
|
|
+ tagButton.layer.masksToBounds = YES;
|
|
|
+ tagButton.layer.borderColor = color.CGColor;
|
|
|
+ tagButton.layer.borderWidth = 1;
|
|
|
+ tagButton.enabled = NO;
|
|
|
+
|
|
|
+ // 去掉边界留白后,在计算文本的尺寸
|
|
|
+ UIEdgeInsets padding = UIEdgeInsetsMake(2, 5, 2, 5);
|
|
|
+ tagButton.titleEdgeInsets = padding;
|
|
|
+ CGSize contentMaxSize = CGSizeMake(flowLayoutView.contentWidth - padding.left - padding.right, MAXFLOAT - padding.top - padding.bottom);
|
|
|
+ CGSize size = [title fb_boundingSizeWithMaxSize:contentMaxSize font:font];
|
|
|
+ tagButton.frame = CGRectMake(0, 0, floorf(size.width + padding.left + padding.right), floorf(size.height + padding.top + padding.bottom));
|
|
|
+
|
|
|
+ return tagButton;
|
|
|
}
|
|
|
|
|
|
+#pragma mark - private methods
|
|
|
+
|
|
|
#pragma mark - getters and setters
|
|
|
|
|
|
+- (UIView *)bgView {
|
|
|
+ if (_bgView == nil) {
|
|
|
+ _bgView = [[UIView alloc] init];
|
|
|
+ }
|
|
|
+ return _bgView;
|
|
|
+}
|
|
|
+
|
|
|
+- (FBFlowLayoutView *)welfareView {
|
|
|
+ if (_welfareView == nil) {
|
|
|
+ _welfareView = [[FBFlowLayoutView alloc] init];
|
|
|
+ _welfareView.delegate = self;
|
|
|
+ _welfareView.dataSource = self;
|
|
|
+ _welfareView.numberOfLines = 0;
|
|
|
+ }
|
|
|
+ return _welfareView;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)titleLabel {
|
|
|
+ if (_titleLabel == nil) {
|
|
|
+ _titleLabel = [[UILabel alloc] init];
|
|
|
+ //_titleLabel.text = @"夏普电子 操作工";
|
|
|
+ //_titleLabel.backgroundColor = [UIColor greenColor];
|
|
|
+ _titleLabel.textColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
|
|
|
+ _titleLabel.font = [UIFont systemFontOfSize:18];
|
|
|
+ //_titleLabel.numberOfLines = 0;
|
|
|
+ _titleLabel.textAlignment = NSTextAlignmentLeft;
|
|
|
+ }
|
|
|
+ return _titleLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)titleTagLabel {
|
|
|
+ if (_titleTagLabel == nil) {
|
|
|
+ _titleTagLabel = [UILabel hj_titleTagWithTitle:@"拼工"];
|
|
|
+ }
|
|
|
+ return _titleTagLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)moneyLabel {
|
|
|
+ if (_moneyLabel == nil) {
|
|
|
+ _moneyLabel = [[UILabel alloc] init];
|
|
|
+ //_moneyLabel.text = @"5001-8000 元";
|
|
|
+ //_moneyLabel.backgroundColor = [UIColor yellowColor];
|
|
|
+ _moneyLabel.textColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:14/255.0 alpha:1.0];
|
|
|
+ _moneyLabel.font = [UIFont systemFontOfSize:18];
|
|
|
+ //_moneyLabel.numberOfLines = 0;
|
|
|
+ _moneyLabel.textAlignment = NSTextAlignmentRight;
|
|
|
+ }
|
|
|
+ return _moneyLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)companyLabel {
|
|
|
+ if (_companyLabel == nil) {
|
|
|
+ _companyLabel = [[UILabel alloc] init];
|
|
|
+ //_companyLabel.text = @"索尼数字产品(无锡)有限公司";
|
|
|
+ //_companyLabel.backgroundColor = [UIColor redColor];
|
|
|
+ _companyLabel.textColor = [UIColor colorWithRed:136/255.0 green:136/255.0 blue:136/255.0 alpha:1.0];
|
|
|
+ _companyLabel.font = [UIFont systemFontOfSize:10];
|
|
|
+ //_companyLabel.numberOfLines = 0;
|
|
|
+ _companyLabel.textAlignment = NSTextAlignmentLeft;
|
|
|
+ }
|
|
|
+ return _companyLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)addressLabel {
|
|
|
+ if (_addressLabel == nil) {
|
|
|
+ _addressLabel = [[UILabel alloc] init];
|
|
|
+ //_addressLabel.text = @"江苏-无锡-新区";
|
|
|
+ //_addressLabel.backgroundColor = [UIColor blueColor];
|
|
|
+ _addressLabel.textColor = [UIColor colorWithRed:136/255.0 green:136/255.0 blue:136/255.0 alpha:1.0];
|
|
|
+ _addressLabel.font = [UIFont systemFontOfSize:10];
|
|
|
+ //_addressLabel.numberOfLines = 0;
|
|
|
+ _addressLabel.textAlignment = NSTextAlignmentRight;
|
|
|
+ }
|
|
|
+ return _addressLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)dateLabel {
|
|
|
+ if (_dateLabel == nil) {
|
|
|
+ _dateLabel = [[UILabel alloc] init];
|
|
|
+ //_dateLabel.text = @"2019-03-04";
|
|
|
+ //_dateLabel.backgroundColor = [UIColor greenColor];
|
|
|
+ _dateLabel.textColor = [UIColor colorWithRed:136/255.0 green:136/255.0 blue:136/255.0 alpha:1.0];
|
|
|
+ _dateLabel.font = [UIFont systemFontOfSize:10];
|
|
|
+ //_dateLabel.numberOfLines = 0;
|
|
|
+ _dateLabel.textAlignment = NSTextAlignmentRight;
|
|
|
+ }
|
|
|
+ return _dateLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (HJMaxMoneyLabel *)maxMoneyLabel {
|
|
|
+ if (_maxMoneyLabel == nil) {
|
|
|
+ _maxMoneyLabel = [[HJMaxMoneyLabel alloc] init];
|
|
|
+ _maxMoneyLabel.hidden = YES;
|
|
|
+ }
|
|
|
+ return _maxMoneyLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)lineH {
|
|
|
+ if (_lineH == nil) {
|
|
|
+ _lineH = [[UIView alloc] init];
|
|
|
+ _lineH.backgroundColor = [UIColor colorWithRed:221/255.0 green:221/255.0 blue:221/255.0 alpha:1.0];
|
|
|
+ }
|
|
|
+ return _lineH;
|
|
|
+}
|
|
|
+
|
|
|
- (UILabel *)peopleCountLabel {
|
|
|
if (_peopleCountLabel == nil) {
|
|
|
_peopleCountLabel = [[UILabel alloc] init];
|
|
|
_peopleCountLabel.font = [UIFont systemFontOfSize:10];
|
|
|
- _peopleCountLabel.backgroundColor = [UIColor whiteColor];
|
|
|
-
|
|
|
- NSDictionary *attributes = @{NSForegroundColorAttributeName: [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0]};
|
|
|
- NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"已有 1 位伙伴加入了该拼工"
|
|
|
- attributes:attributes];
|
|
|
- [string addAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:143/255.0 blue:1/255.0 alpha:1.0]}
|
|
|
- range:NSMakeRange(3, 1)];
|
|
|
- _peopleCountLabel.attributedText = string;
|
|
|
+ _peopleCountLabel.textColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:34/255.0 alpha:1.0];
|
|
|
}
|
|
|
return _peopleCountLabel;
|
|
|
}
|
|
|
|
|
|
-- (HJClockLabel *)clockLabel {
|
|
|
+- (UILabel *)clockLabel {
|
|
|
if (_clockLabel == nil) {
|
|
|
- _clockLabel = [[HJClockLabel alloc] init];
|
|
|
- _clockLabel.backgroundColor = [UIColor whiteColor];
|
|
|
+ _clockLabel = [[UILabel alloc] init];
|
|
|
+ _clockLabel.font = [UIFont systemFontOfSize:10];
|
|
|
+ _clockLabel.textColor = [UIColor colorWithRed:136/255.0 green:136/255.0 blue:136/255.0 alpha:1.0];
|
|
|
}
|
|
|
return _clockLabel;
|
|
|
}
|
|
|
|
|
|
-- (HJFullTimeCellView *)fullTimeCell {
|
|
|
- if (_fullTimeCell == nil) {
|
|
|
- _fullTimeCell = [[HJFullTimeCellView alloc] init];
|
|
|
+- (UIView *)footer {
|
|
|
+ if (_footer == nil) {
|
|
|
+ _footer = [[UIView alloc] init];
|
|
|
+ _footer.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1.0];
|
|
|
}
|
|
|
- return _fullTimeCell;
|
|
|
-}
|
|
|
-
|
|
|
-- (UIView *)footerView {
|
|
|
- if (_footerView == nil) {
|
|
|
- _footerView = [[UIView alloc] init];
|
|
|
- _footerView.backgroundColor = [UIColor colorWithRed:221/255.0 green:221/255.0 blue:221/255.0 alpha:1.0];
|
|
|
- }
|
|
|
- return _footerView;
|
|
|
-}
|
|
|
-
|
|
|
-- (UIView *)bgView {
|
|
|
- if (_bgView == nil) {
|
|
|
- _bgView = [[UIView alloc] init];
|
|
|
- _bgView.backgroundColor = [UIColor whiteColor];
|
|
|
- }
|
|
|
- return _bgView;
|
|
|
+ return _footer;
|
|
|
}
|
|
|
|
|
|
@end
|