chore: import upstream snapshot with attribution
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TLExpressionMoreCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2017/7/21.
|
||||
// Copyright © 2017年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TLExpressionGroupModel.h"
|
||||
|
||||
#define WIDTH_EXPRESSION_MORE_CELL MIN(((SCREEN_WIDTH - 15 * 4) / 3 - 1), 115)
|
||||
|
||||
@interface TLExpressionMoreCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) TLExpressionGroupModel *groupModel;
|
||||
|
||||
@end
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// TLExpressionMoreCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2017/7/21.
|
||||
// Copyright © 2017年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionMoreCell.h"
|
||||
|
||||
@interface TLExpressionMoreCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLExpressionMoreCell
|
||||
|
||||
#pragma mark - # Protocol
|
||||
+ (CGSize)viewSizeByDataModel:(id)dataModel
|
||||
{
|
||||
return CGSizeMake(WIDTH_EXPRESSION_MORE_CELL, WIDTH_EXPRESSION_MORE_CELL + 40);
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
[self setGroupModel:dataModel];
|
||||
}
|
||||
|
||||
#pragma mark - # Public Methods
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self.contentView addSubview:self.imageView];
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self p_addMasonry];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setGroupModel:(TLExpressionGroupModel *)groupModel
|
||||
{
|
||||
if (_groupModel == groupModel) {
|
||||
return;
|
||||
}
|
||||
_groupModel = groupModel;
|
||||
[self.titleLabel setText:groupModel.name];
|
||||
UIImage *image = [UIImage imageWithContentsOfFile:groupModel.iconPath];
|
||||
if (image) {
|
||||
[self.imageView setImage:image];
|
||||
}
|
||||
else {
|
||||
[self.imageView tt_setImageWithURL:TLURL(groupModel.iconURL) placeholderImage:[UIImage imageWithColor:[UIColor colorGrayBG]]];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - # Private Methods
|
||||
- (void)p_addMasonry
|
||||
{
|
||||
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.and.top.and.right.mas_equalTo(self.contentView);
|
||||
make.height.mas_equalTo(self.imageView.mas_width);
|
||||
}];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.contentView);
|
||||
make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(7.0f);
|
||||
make.width.mas_lessThanOrEqualTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - # Getters
|
||||
- (UIImageView *)imageView
|
||||
{
|
||||
if (_imageView == nil) {
|
||||
_imageView = [[UIImageView alloc] init];
|
||||
[_imageView setBackgroundColor:[UIColor whiteColor]];
|
||||
[_imageView.layer setMasksToBounds:YES];
|
||||
[_imageView.layer setCornerRadius:10.0f];
|
||||
[_imageView.layer setBorderWidth:BORDER_WIDTH_1PX];
|
||||
[_imageView.layer setBorderColor:[UIColor colorGrayLine].CGColor];
|
||||
}
|
||||
return _imageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel
|
||||
{
|
||||
if (_titleLabel == nil) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
[_titleLabel setTextAlignment:NSTextAlignmentCenter];
|
||||
[_titleLabel setFont:[UIFont systemFontOfSize:12.0f]];
|
||||
[_titleLabel setBackgroundColor:[UIColor whiteColor]];
|
||||
[_titleLabel setClipsToBounds:YES];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLExpressionMoreSearchCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2017/7/21.
|
||||
// Copyright © 2017年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TLExpressionMoreSearchCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@end
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// TLExpressionMoreSearchCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2017/7/21.
|
||||
// Copyright © 2017年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionMoreSearchCell.h"
|
||||
#import "TLExpressionSearchResultViewController.h"
|
||||
#import "TLSearchController.h"
|
||||
|
||||
@interface TLExpressionMoreSearchCell ()
|
||||
|
||||
@property (nonatomic, strong) TLSearchController *searchController;
|
||||
|
||||
@property (nonatomic, copy) id (^eventAction)(NSInteger, id);
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLExpressionMoreSearchCell
|
||||
|
||||
#pragma mark - # Protocol
|
||||
+ (CGSize)viewSizeByDataModel:(id)dataModel
|
||||
{
|
||||
return CGSizeMake(SCREEN_WIDTH, SEARCHBAR_HEIGHT);
|
||||
}
|
||||
|
||||
- (void)setViewEventAction:(id (^)(NSInteger, id))eventAction
|
||||
{
|
||||
self.eventAction = eventAction;
|
||||
}
|
||||
|
||||
#pragma mark - # Public Methods
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setBackgroundColor:[UIColor whiteColor]];
|
||||
@weakify(self);
|
||||
TLExpressionSearchResultViewController *searchResultVC = [[TLExpressionSearchResultViewController alloc] init];
|
||||
[searchResultVC setItemClickAction:^(TLExpressionSearchResultViewController *searchController, id data) {
|
||||
@strongify(self);
|
||||
[self.searchController setActive:NO];
|
||||
if (self.eventAction) {
|
||||
self.eventAction(0, data);
|
||||
}
|
||||
}];
|
||||
self.searchController = [TLSearchController createWithResultsContrller:searchResultVC];
|
||||
[self.searchController.searchBar setPlaceholder:LOCSTR(@"搜索表情")];
|
||||
[self.contentView addSubview:self.searchController.searchBar];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
if (!CGSizeEqualToSize(self.bounds.size, self.searchController.searchBar.frame.size)) {
|
||||
[self.searchController.searchBar setSize:self.bounds.size];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user