123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //
- // GroupSquareCell.m
- // smartRhino
- //
- // Created by niuzhen on 2020/5/6.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "GroupSquareCell.h"
- @implementation GroupSquareCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- self.JoinBtn.layer.cornerRadius = 2.f;
- self.JoinBtn.layer.borderWidth = 0.5f;
- self.JoinBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
- self.JoinBtn.layer.masksToBounds = YES;
- }
- + (CGFloat)configCell0Height
- {
- return 60.f;
- }
- + (CGFloat)configCell1Height
- {
- return 98.f;
- }
- + (GroupSquareCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"GroupSquareCell0";
- GroupSquareCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"GroupSquareCell" owner:nil options:nil] objectAtIndex:0];
- }
- return cell;
- }
- + (GroupSquareCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"GroupSquareCell1";
- GroupSquareCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"GroupSquareCell" owner:nil options:nil] objectAtIndex:1];
- }
- return cell;
- }
- - (void)setLeftDataModel:(GroupSquareModel *)model
- {
- self.BlueView.hidden = !model.isSelect;
- if (model.isSelect) {
- self.NameL.textColor = UIColorHex(0x262626);
- self.contentView.backgroundColor = UIColorHex(0xffffff);
- self.NameL.font = [UIFont systemFontOfSize:15];
- }else{
- self.NameL.textColor = UIColorHex(0x333333);
- self.contentView.backgroundColor = UIColorHex(0xF2F2F2);
- self.NameL.font = [UIFont systemFontOfSize:13];
- }
- self.NameL.text = model.PiazzaName;
- }
- - (void)setRightDataSubModel:(GroupSquareSubModel *)model
- {
- [self.IconView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:IMG(@"img_placeHolder")];
- self.titleL.text = model.Name;
- self.userCountL.text = [self userCountText:model.UserCount];
- self.TopicCountL.text = [self userCountText:model.TopicCount];
- self.subTitleL.text = model.Introduce;
- if (model.IsUser) {
- self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
- [self.JoinBtn setTitle:@"已加入" forState:UIControlStateNormal];
- [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
- self.JoinBtn.enabled = NO;
- }else{
- if (model.IsApply) {
- self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
- [self.JoinBtn setTitle:@"已申请" forState:UIControlStateNormal];
- [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
- self.JoinBtn.enabled = NO;
- }else{
- self.JoinBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
- [self.JoinBtn setTitle:@"加入" forState:UIControlStateNormal];
- [self.JoinBtn setTitleColor:UIColorHex(0x13A3FF) forState:UIControlStateNormal];
- self.JoinBtn.enabled = YES;
- }
- }
- }
- - (void)setRightDataSubModel:(GroupSquareSubModel *)model withSearchText:(NSString *)text
- {
- [self.IconView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:IMG(@"img_placeHolder")];
- self.titleL.attributedText = [ZYCTool checkOfString:model.Name withSearchText:text withColor:UIColorHex(0xFF5252)];
- self.userCountL.text = [self userCountText:model.UserCount];
- self.TopicCountL.text = [self userCountText:model.TopicCount];
- self.subTitleL.text = model.Introduce;
- if (model.IsUser) {
- self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
- [self.JoinBtn setTitle:@"已加入" forState:UIControlStateNormal];
- [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
- self.JoinBtn.enabled = NO;
- }else{
- if (model.IsApply) {
- self.JoinBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
- [self.JoinBtn setTitle:@"已申请" forState:UIControlStateNormal];
- [self.JoinBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
- self.JoinBtn.enabled = NO;
- }else{
- self.JoinBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
- [self.JoinBtn setTitle:@"加入" forState:UIControlStateNormal];
- [self.JoinBtn setTitleColor:UIColorHex(0x13A3FF) forState:UIControlStateNormal];
- self.JoinBtn.enabled = YES;
- }
- }
- }
- - (NSString *)userCountText:(NSInteger)userCount
- {
- if (userCount >= 1000) {
- CGFloat s = userCount / 1000;
- return [NSString stringWithFormat:@"%.1f%@",s,@"k"];
- }else{
- return [NSString stringWithFormat:@"%ld",userCount];
- }
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|