From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001 From: 单军华 Date: Wed, 11 Jul 2018 10:47:42 +0800 Subject: [PATCH] 首次上传 --- screendisplay/Pods/EaseUI/EaseUI/EMUIKit/Views/contact/EaseUserCell.m | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 227 insertions(+), 0 deletions(-) diff --git a/screendisplay/Pods/EaseUI/EaseUI/EMUIKit/Views/contact/EaseUserCell.m b/screendisplay/Pods/EaseUI/EaseUI/EMUIKit/Views/contact/EaseUserCell.m new file mode 100755 index 0000000..9ff16e0 --- /dev/null +++ b/screendisplay/Pods/EaseUI/EaseUI/EMUIKit/Views/contact/EaseUserCell.m @@ -0,0 +1,227 @@ +/************************************************************ + * * Hyphenate CONFIDENTIAL + * __________________ + * Copyright (C) 2016 Hyphenate Inc. All rights reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Hyphenate Inc. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Hyphenate Inc. + */ + +#import "EaseUserCell.h" + +#import "EaseImageView.h" +#import "UIImageView+WebCache.h" + +CGFloat const EaseUserCellPadding = 10; + +@interface EaseUserCell() + +@property (nonatomic) NSLayoutConstraint *titleWithAvatarLeftConstraint; + +@property (nonatomic) NSLayoutConstraint *titleWithoutAvatarLeftConstraint; + +@end + +@implementation EaseUserCell + ++ (void)initialize +{ + // UIAppearance Proxy Defaults + /** @brief ������������ */ + EaseUserCell *cell = [self appearance]; + cell.titleLabelColor = [UIColor blackColor]; + cell.titleLabelFont = [UIFont systemFontOfSize:18]; +} + +- (instancetype)initWithStyle:(UITableViewCellStyle)style + reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + self.accessibilityIdentifier = @"table_cell"; + + [self _setupSubview]; + + UILongPressGestureRecognizer *headerLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(headerLongPress:)]; + [self addGestureRecognizer:headerLongPress]; + } + + return self; +} + +#pragma mark - private layout subviews + +/*! + @method + @brief ������������ + @discussion + @return + */ +- (void)_setupSubview +{ + _avatarView = [[EaseImageView alloc] init]; + _avatarView.translatesAutoresizingMaskIntoConstraints = NO; + [self.contentView addSubview:_avatarView]; + + _titleLabel = [[UILabel alloc] init]; + _titleLabel.accessibilityIdentifier = @"title"; + _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; + _titleLabel.numberOfLines = 2; + _titleLabel.backgroundColor = [UIColor clearColor]; + _titleLabel.font = _titleLabelFont; + _titleLabel.textColor = _titleLabelColor; + [self.contentView addSubview:_titleLabel]; + + [self _setupAvatarViewConstraints]; + [self _setupTitleLabelConstraints]; +} + +#pragma mark - Setup Constraints + +/*! + @method + @brief ������avatarView��������� + @discussion + @return + */ +- (void)_setupAvatarViewConstraints +{ + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.avatarView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:EaseUserCellPadding]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.avatarView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-EaseUserCellPadding]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.avatarView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:EaseUserCellPadding]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.avatarView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.avatarView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.avatarView attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0]]; +} + +/*! + @method + @brief ������titleLabel��������� + @discussion + @return + */ +- (void)_setupTitleLabelConstraints +{ + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:EaseUserCellPadding]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-EaseUserCellPadding]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-EaseUserCellPadding]]; + + self.titleWithAvatarLeftConstraint = [NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.avatarView attribute:NSLayoutAttributeRight multiplier:1.0 constant:EaseUserCellPadding]; + self.titleWithoutAvatarLeftConstraint = [NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:EaseUserCellPadding]; + [self addConstraint:self.titleWithAvatarLeftConstraint]; +} + +#pragma mark - setter + +- (void)setShowAvatar:(BOOL)showAvatar +{ + if (_showAvatar != showAvatar) { + _showAvatar = showAvatar; + self.avatarView.hidden = !showAvatar; + if (_showAvatar) { + [self removeConstraint:self.titleWithoutAvatarLeftConstraint]; + [self addConstraint:self.titleWithAvatarLeftConstraint]; + } + else{ + [self removeConstraint:self.titleWithAvatarLeftConstraint]; + [self addConstraint:self.titleWithoutAvatarLeftConstraint]; + } + } +} + +- (void)setModel:(id<IUserModel>)model +{ + _model = model; + + if ([_model.nickname length] > 0) { + self.titleLabel.text = _model.nickname; + } + else{ + self.titleLabel.text = _model.buddy; + } + + if ([_model.avatarURLPath length] > 0){ + [self.avatarView.imageView sd_setImageWithURL:[NSURL URLWithString:_model.avatarURLPath] placeholderImage:_model.avatarImage]; + } else { + if (_model.avatarImage) { + self.avatarView.image = _model.avatarImage; + } + } +} + +- (void)setTitleLabelFont:(UIFont *)titleLabelFont +{ + _titleLabelFont = titleLabelFont; + _titleLabel.font = _titleLabelFont; +} + +- (void)setTitleLabelColor:(UIColor *)titleLabelColor +{ + _titleLabelColor = titleLabelColor; + _titleLabel.textColor = _titleLabelColor; +} + +#pragma mark - class method + +/*! + @method + @brief ������cell��������������� + @discussion + @param model ������model + @return ������cell��������������� + */ ++ (NSString *)cellIdentifierWithModel:(id)model +{ + return @"EaseUserCell"; +} + +/*! + @method + @brief ������cell��������� + @discussion + @param model ������model + @return ������cell��������� + */ ++ (CGFloat)cellHeightWithModel:(id)model +{ + return EaseUserCellMinHeight; +} + +#pragma mark - action + +/*! + @method + @brief ������������������ + @discussion + @param longPress ������������ + @return + */ +- (void)headerLongPress:(UILongPressGestureRecognizer *)longPress +{ + if (longPress.state == UIGestureRecognizerStateBegan) { + if(_delegate && _indexPath && [_delegate respondsToSelector:@selector(cellLongPressAtIndexPath:)]) + { + [_delegate cellLongPressAtIndexPath:self.indexPath]; + } + } +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + if (_avatarView.badge) { + _avatarView.badgeBackgroudColor = [UIColor redColor]; + } +} + +-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{ + [super setHighlighted:highlighted animated:animated]; + if (_avatarView.badge) { + _avatarView.badgeBackgroudColor = [UIColor redColor]; + } +} + +@end -- Gitblit v1.8.0