JLFacePackgeViewCell.m 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // JLFacePackgeViewCell.m
  3. // shiku_im
  4. //
  5. // Created by JayLuo on 2019/12/10.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "JLFacePackgeViewCell.h"
  9. @interface JLFacePackgeViewCell()
  10. @property (weak, nonatomic) IBOutlet UIView *containerView;
  11. @property (weak, nonatomic) IBOutlet UIImageView *imageView;
  12. @property (weak, nonatomic) IBOutlet UILabel *label;
  13. @property (nonatomic, assign) BOOL isSelected;
  14. @property (weak, nonatomic) IBOutlet UIButton *markButton;
  15. @end
  16. @implementation JLFacePackgeViewCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. _isSelectedImageHidden = NO;
  21. self.imageView.layer.borderWidth = 0.5;
  22. self.imageView.layer.borderColor = [UIColor lightGrayColor].CGColor;
  23. self.imageView.layer.cornerRadius = 5;
  24. self.imageView.layer.masksToBounds = YES;
  25. [self.imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selected)]];
  26. _isSelected = NO;
  27. [g_notify addObserver:self selector:@selector(updateStatus) name:@"NOTSELECTED" object:nil];
  28. }
  29. - (void)dealloc {
  30. [g_notify removeObserver:self];
  31. }
  32. - (void)updateStatus {
  33. [_markButton setSelected:NO];
  34. }
  35. - (void)selected {
  36. _isSelected = !_isSelected;
  37. [_markButton setSelected:_isSelected];
  38. if (_JLFacePackgeViewCellCallBack) {
  39. _JLFacePackgeViewCellCallBack(_model.id, _markButton.selected);
  40. }
  41. }
  42. - (void)setModel:(JLFacePackgeModel *)model {
  43. _model = model;
  44. // NSString *path = model.path? model.path: model.url;
  45. NSString *path = model.path? model.path.firstObject: model.url;
  46. if([model.id isEqualToString:@"plusButtonID"]) {
  47. _imageView.userInteractionEnabled = YES;
  48. _markButton.hidden = YES;
  49. [_imageView sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"addfriend_room"]];
  50. }else {
  51. [_imageView sd_setImageWithURL:[NSURL URLWithString:path]];
  52. }
  53. _label.text = model.name;
  54. }
  55. - (void)setJLFacePackgeViewCellCallBack:(void (^)(NSString * _Nonnull, BOOL))JLFacePackgeViewCellCallBack {
  56. _JLFacePackgeViewCellCallBack = JLFacePackgeViewCellCallBack;
  57. }
  58. //- (void)setIsLableHidden:(BOOL)isLableHidden {
  59. // _isLableHidden = isLableHidden;
  60. // [_label setHidden:isLableHidden];
  61. //
  62. //}
  63. - (void)setIsSelectedImageHidden:(BOOL)isSelectedImageHidden {
  64. _isSelectedImageHidden = isSelectedImageHidden;
  65. if ([_model.id isEqualToString:@"plusButtonID"]) {
  66. _imageView.userInteractionEnabled = YES;
  67. _markButton.hidden = YES;
  68. }else {
  69. _imageView.userInteractionEnabled = _isSelectedImageHidden;
  70. _markButton.hidden = !_isSelectedImageHidden;
  71. }
  72. }
  73. @end