BGRoomManagerCell.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //
  2. // BGRoomManagerCell.m
  3. // UniversalApp
  4. //
  5. // Created by bugu on 2020/3/24.
  6. // Copyright © 2020 voidcat. All rights reserved.
  7. //
  8. #import "BGRoomManagerCell.h"
  9. #import "RoomUserInfo.h"
  10. #import "CommonSexView.h"
  11. #import "UIFont+Ext.h"
  12. #import "UIButton+CAGradientLayer.h"
  13. @interface BGRoomManagerCell ()
  14. @property(nonatomic, strong) UILabel *IDLabel;
  15. @property(nonatomic, strong) UIImageView *iconImageView;
  16. @property(nonatomic, strong) QMUIButton *titleSexBtn;
  17. @property(nonatomic, strong) UIButton *addBtn;
  18. @property(nonatomic, strong) UIButton *cancelBtn;
  19. @property(nonatomic, strong) CommonSexView *sexView;
  20. @property(nonatomic, strong) UIView *line;
  21. @end
  22. @implementation BGRoomManagerCell
  23. - (void)awakeFromNib {
  24. [super awakeFromNib];
  25. // Initialization code
  26. }
  27. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  28. [super setSelected:selected animated:animated];
  29. // Configure the view for the selected state
  30. }
  31. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  32. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  33. [self initUI];
  34. }
  35. return self;
  36. }
  37. - (void)initUI {
  38. _iconImageView = ({
  39. UIImageView * imageView = [[UIImageView alloc]init];
  40. imageView.layer.cornerRadius = 22;
  41. imageView.clipsToBounds = YES;
  42. imageView.contentMode = UIViewContentModeScaleAspectFill;
  43. imageView;
  44. });
  45. _titleSexBtn = ({
  46. QMUIButton * button = [[QMUIButton alloc]initWithFrame:CGRectZero];
  47. // [button setTitle:@"0" forState:UIControlStateNormal];
  48. [button.titleLabel setFont:[UIFont systemFontOfSize:16]];
  49. [button setTitleColor:kGrayColor forState:UIControlStateNormal];
  50. [button setImage:[UIImage imageNamed:@"girl"] forState:UIControlStateNormal];
  51. button.imagePosition = QMUIButtonImagePositionRight;
  52. button.spacingBetweenImageAndTitle = 5;
  53. button;
  54. });
  55. _IDLabel = ({
  56. UILabel * label = [[UILabel alloc]init];
  57. label.textColor = kAppGrayColor1;
  58. label.font = [UIFont systemFontOfSize:13];
  59. // label.text = @"Title";
  60. label.textAlignment = NSTextAlignmentCenter;
  61. label;
  62. });
  63. [self.contentView addSubview:_iconImageView];
  64. [self.contentView addSubview:_titleSexBtn];
  65. [self.contentView addSubview:_IDLabel];
  66. [self.contentView addSubview:self.sexView];
  67. _addBtn = [UIButton buttonGradientFrame:CGRectMake(kScreenW-70-20, 20, 70, 30) Title:ASLocalizedString(@"添加") target:self action:@selector(addBtnAction)];
  68. _addBtn.titleLabel.font = UIFont.bg_mediumFont14;
  69. [self.contentView addSubview:_addBtn];
  70. _cancelBtn = [UIButton buttonLayerColor:kAppGrayColor3 Frame:CGRectMake(kScreenW-70-20, 20, 70, 30) Title:ASLocalizedString(@"取消") target:self action:@selector(cancelBtnAction)];
  71. _cancelBtn.titleLabel.font = UIFont.bg_mediumFont14;
  72. [self.contentView addSubview:_cancelBtn];
  73. _line = [[UIView alloc]init];
  74. _line.backgroundColor = [UIColor colorWithHexString:@"#E1E1E1"];
  75. [self.contentView addSubview:_line];
  76. // _cancelBtn.
  77. }
  78. - (void)layoutSubviews {
  79. [super layoutSubviews];
  80. [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.centerY.mas_equalTo(0);
  82. make.left.mas_equalTo(20);
  83. make.size.mas_equalTo(44);
  84. }];
  85. [_titleSexBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.equalTo(_iconImageView.mas_right).offset(12);
  87. make.top.equalTo(_iconImageView);
  88. }];
  89. [_IDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.left.equalTo(_titleSexBtn);
  91. make.bottom.equalTo(_iconImageView);
  92. }];
  93. [self.sexView mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.mas_equalTo(self.titleSexBtn.mas_right).mas_offset(6);
  95. make.size.mas_equalTo(CGSizeMake(32, 17));
  96. make.centerY.mas_equalTo(self.titleSexBtn);
  97. }];
  98. [_line mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.mas_equalTo(41.5);
  100. make.right.mas_equalTo(-22);
  101. make.bottom.mas_equalTo(0);
  102. make.height.mas_equalTo(0.5);
  103. }];
  104. }
  105. - (void)addBtnAction {
  106. if (self.addActionBlock) {
  107. self.addActionBlock();
  108. }
  109. }
  110. - (void)cancelBtnAction {
  111. if (self.cancelActionBlock) {
  112. self.cancelActionBlock();
  113. }
  114. }
  115. - (void)setCellType:(RoomManagerCellType)cellType{
  116. _cellType = cellType;
  117. if (cellType == RoomManagerCellTypeAdd) {
  118. _addBtn.hidden = NO;
  119. _cancelBtn.hidden = YES;
  120. } else {
  121. _addBtn.hidden = YES;
  122. _cancelBtn.hidden = NO;
  123. }
  124. }
  125. - (void)setInfo:(RoomUserInfo *)info{
  126. _info = info;
  127. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:info.head_image] placeholderImage:nil];
  128. [self.titleSexBtn setTitle:info.nick_name forState:UIControlStateNormal];
  129. [self.sexView setSex:info.sex.intValue age:info.age.intValue];
  130. self.IDLabel.text = [NSString stringWithFormat:@"ID:%@",info.user_id];
  131. }
  132. - (CommonSexView *)sexView{
  133. if (!_sexView) {
  134. _sexView = [[CommonSexView alloc]initWithFrame:CGRectZero];
  135. }
  136. return _sexView;
  137. }
  138. @end