chore: import upstream snapshot with attribution
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TLEmojiBaseCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/3/9.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TLExpressionModel.h"
|
||||
|
||||
@protocol TLEmojiCellProtocol <NSObject>
|
||||
|
||||
- (CGRect)displayBaseRect;
|
||||
|
||||
@end
|
||||
|
||||
@interface TLEmojiBaseCell : UICollectionViewCell <TLEmojiCellProtocol>
|
||||
|
||||
@property (nonatomic, strong) TLExpressionModel *emojiItem;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *bgView;
|
||||
|
||||
/**
|
||||
* 选中时的背景图片,默认nil
|
||||
*/
|
||||
@property (nonatomic, strong) UIImage *highlightImage;
|
||||
|
||||
@property (nonatomic, assign) BOOL showHighlightImage;
|
||||
|
||||
@end
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// TLEmojiBaseCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/3/9.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiBaseCell.h"
|
||||
|
||||
@implementation TLEmojiBaseCell
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGRect)displayBaseRect
|
||||
{
|
||||
return self.frame;
|
||||
}
|
||||
|
||||
- (void)setShowHighlightImage:(BOOL)showHighlightImage
|
||||
{
|
||||
if (showHighlightImage) {
|
||||
[self.bgView setImage:self.highlightImage];
|
||||
}
|
||||
else {
|
||||
[self.bgView setImage:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getter -
|
||||
- (UIImageView *)bgView
|
||||
{
|
||||
if (_bgView == nil) {
|
||||
_bgView = [[UIImageView alloc] init];
|
||||
[_bgView.layer setMasksToBounds:YES];
|
||||
[_bgView.layer setCornerRadius:5.0f];
|
||||
}
|
||||
return _bgView;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLEmojiFaceItemCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/3/9.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiBaseCell.h"
|
||||
|
||||
@interface TLEmojiFaceItemCell : TLEmojiBaseCell
|
||||
|
||||
@end
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
|
||||
//
|
||||
// TLEmojiFaceItemCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/3/9.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiFaceItemCell.h"
|
||||
|
||||
@interface TLEmojiFaceItemCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *label;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLEmojiFaceItemCell
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self.contentView addSubview:self.imageView];
|
||||
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self);
|
||||
make.size.mas_equalTo(CGSizeMake(32, 32));
|
||||
}];
|
||||
[self.contentView addSubview:self.label];
|
||||
[self.label mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.imageView);
|
||||
}];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setEmojiItem:(TLExpressionModel *)emojiItem
|
||||
{
|
||||
[super setEmojiItem:emojiItem];
|
||||
if ([emojiItem.eId isEqualToString:@"-1"]) {
|
||||
[self.imageView setHidden:NO];
|
||||
[self.label setHidden:YES];
|
||||
[self.imageView setImage:[UIImage imageNamed:@"emojiKB_emoji_delete"]];
|
||||
}
|
||||
else {
|
||||
if (emojiItem.type == TLEmojiTypeFace) {
|
||||
[self.imageView setHidden:NO];
|
||||
[self.label setHidden:YES];
|
||||
[self.imageView setImage:emojiItem.name == nil ? nil : [UIImage imageNamed:emojiItem.name]];
|
||||
}
|
||||
else {
|
||||
[self.imageView setHidden:YES];
|
||||
[self.label setHidden:NO];
|
||||
[self.label setText:emojiItem.name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - # Getter
|
||||
- (UIImageView *)imageView
|
||||
{
|
||||
if (_imageView == nil) {
|
||||
_imageView = [[UIImageView alloc] init];
|
||||
}
|
||||
return _imageView;
|
||||
}
|
||||
|
||||
- (UILabel *)label
|
||||
{
|
||||
if (_label == nil) {
|
||||
_label = [[UILabel alloc] init];
|
||||
[_label setFont:[UIFont systemFontOfSize:28.0f]];
|
||||
[_label setTextAlignment:NSTextAlignmentCenter];
|
||||
}
|
||||
return _label;
|
||||
}
|
||||
|
||||
@end
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// TLEmojiImageItemCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/20.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiBaseCell.h"
|
||||
|
||||
@interface TLEmojiImageItemCell : TLEmojiBaseCell
|
||||
|
||||
|
||||
@end
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// TLEmojiImageItemCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/20.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiImageItemCell.h"
|
||||
|
||||
@interface TLEmojiImageItemCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLEmojiImageItemCell
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self.contentView addSubview:self.imageView];
|
||||
[self setHighlightImage:[UIImage imageNamed:@"emoji_hl_background"]];
|
||||
[self p_addMasonry];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGRect)displayBaseRect
|
||||
{
|
||||
CGRect rect = self.imageView.frame;
|
||||
rect.origin.x += self.x;
|
||||
rect.origin.y += self.y;
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)setEmojiItem:(TLExpressionModel *)emojiItem
|
||||
{
|
||||
[super setEmojiItem:emojiItem];
|
||||
[self.imageView setImage:emojiItem.path == nil ? nil : [UIImage imageNamed:emojiItem.path]];
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods -
|
||||
- (void)p_addMasonry
|
||||
{
|
||||
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.mas_equalTo(self.contentView);
|
||||
make.size.mas_equalTo(CGSizeMake(52, 52));
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getter -
|
||||
- (UIImageView *)imageView
|
||||
{
|
||||
if (_imageView == nil) {
|
||||
_imageView = [[UIImageView alloc] init];
|
||||
}
|
||||
return _imageView;
|
||||
}
|
||||
|
||||
@end
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// TLEmojiImageTitleItemCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/21.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiBaseCell.h"
|
||||
|
||||
@interface TLEmojiImageTitleItemCell : TLEmojiBaseCell
|
||||
|
||||
|
||||
@end
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// TLEmojiImageTitleItemCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/2/21.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLEmojiImageTitleItemCell.h"
|
||||
#import "UIImage+Color.h"
|
||||
|
||||
@interface TLEmojiImageTitleItemCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *label;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLEmojiImageTitleItemCell
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setHighlightImage:[UIImage imageNamed:@"emoji_hl_background"]];
|
||||
[self.contentView addSubview:self.imageView];
|
||||
[self.contentView addSubview:self.label];
|
||||
[self p_addMasonry];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setEmojiItem:(TLExpressionModel *)emojiItem
|
||||
{
|
||||
[super setEmojiItem:emojiItem];
|
||||
[self.imageView setImage:emojiItem.path == nil ? nil : [UIImage imageNamed:emojiItem.path]];
|
||||
[self.label setText:emojiItem.name];
|
||||
}
|
||||
|
||||
- (CGRect)displayBaseRect
|
||||
{
|
||||
CGRect rect = self.imageView.frame;
|
||||
rect.origin.x += self.x;
|
||||
rect.origin.y += self.y;
|
||||
return rect;
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods -
|
||||
- (void)p_addMasonry
|
||||
{
|
||||
[self.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.imageView).mas_offset(UIEdgeInsetsMake(-3, -3, -3, -3));
|
||||
}];
|
||||
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(3);
|
||||
make.centerX.mas_equalTo(0);
|
||||
make.size.mas_equalTo(CGSizeMake(50, 50));
|
||||
}];
|
||||
[self.label mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(0);
|
||||
make.width.mas_lessThanOrEqualTo(self).mas_offset(-8);
|
||||
make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(4);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getter -
|
||||
- (UIImageView *)imageView
|
||||
{
|
||||
if (_imageView == nil) {
|
||||
_imageView = [[UIImageView alloc] init];
|
||||
}
|
||||
return _imageView;
|
||||
}
|
||||
|
||||
- (UILabel *)label
|
||||
{
|
||||
if (_label == nil) {
|
||||
_label = [[UILabel alloc] init];
|
||||
[_label setFont:[UIFont systemFontOfSize:12.0f]];
|
||||
[_label setTextColor:[UIColor grayColor]];
|
||||
[_label setTextAlignment:NSTextAlignmentCenter];
|
||||
}
|
||||
return _label;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user