chore: import upstream snapshot with attribution
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TLExpressionGroupModel+DetailRequest.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/2.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionGroupModel.h"
|
||||
|
||||
@interface TLExpressionGroupModel (DetailRequest)
|
||||
|
||||
/**
|
||||
* 表情详情
|
||||
*/
|
||||
- (TLBaseRequest *)requestExpressionGroupDetailByPageIndex:(NSInteger)pageIndex success:(TLRequestSuccessBlock)success failure:(TLRequestFailureBlock)failure;
|
||||
|
||||
@end
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// TLExpressionGroupModel+DetailRequest.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/2.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionGroupModel+DetailRequest.h"
|
||||
#import "TLNetworking.h"
|
||||
|
||||
#define IEXPRESSION_DETAIL_URL [IEXPRESSION_HOST_URL stringByAppendingString:@"expre/getByeId.do?pageNumber=%ld&eId=%@"]
|
||||
|
||||
@implementation TLExpressionGroupModel (DetailRequest)
|
||||
|
||||
- (TLBaseRequest *)requestExpressionGroupDetailByPageIndex:(NSInteger)pageIndex success:(TLRequestSuccessBlock)success failure:(TLRequestFailureBlock)failure
|
||||
{
|
||||
NSString *urlString = [NSString stringWithFormat:IEXPRESSION_DETAIL_URL, (long)pageIndex, self.gId];
|
||||
[TLNetworking postUrl:urlString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
|
||||
NSArray *respArray = [responseObject mj_JSONObject];
|
||||
NSString *status = respArray[0];
|
||||
if ([status isEqualToString:@"OK"]) {
|
||||
NSArray *infoArray = respArray[2];
|
||||
NSMutableArray *data = [TLExpressionModel mj_objectArrayWithKeyValuesArray:infoArray];
|
||||
if (success) {
|
||||
success(data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (failure) {
|
||||
failure(status);
|
||||
}
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask *task, NSError *error) {
|
||||
if (failure) {
|
||||
failure(TLNetworkErrorTip);
|
||||
}
|
||||
}];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TLExpressionDetailViewController.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/4/8.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLViewController.h"
|
||||
|
||||
@class TLExpressionGroupModel;
|
||||
@interface TLExpressionDetailViewController : ZZFlexibleLayoutViewController
|
||||
|
||||
@property (nonatomic, strong, readonly) TLExpressionGroupModel *groupModel;
|
||||
|
||||
- (id)initWithGroupModel:(TLExpressionGroupModel *)groupModel;
|
||||
|
||||
@end
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
//
|
||||
// TLExpressionDetailViewController.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/4/8.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionDetailViewController.h"
|
||||
#import "TLImageExpressionDisplayView.h"
|
||||
#import "TLExpressionGroupModel+DetailRequest.h"
|
||||
#import "TLExpressionDetailItemCell.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, TLExpressionDetailVCSectionType) {
|
||||
TLExpressionDetailVCSectionTypeHeader,
|
||||
TLExpressionDetailVCSectionTypeItems,
|
||||
};
|
||||
|
||||
@interface TLExpressionDetailViewController ()
|
||||
|
||||
@property (nonatomic, assign) NSInteger pageIndex;
|
||||
|
||||
@property (nonatomic, strong) TLImageExpressionDisplayView *emojiDisplayView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLExpressionDetailViewController
|
||||
|
||||
- (id)initWithGroupModel:(TLExpressionGroupModel *)groupModel
|
||||
{
|
||||
if (self = [super init]) {
|
||||
_pageIndex = 1;
|
||||
_groupModel = groupModel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
[super loadView];
|
||||
[self setTitle:self.groupModel.name];
|
||||
[self.view setBackgroundColor:[UIColor whiteColor]];
|
||||
|
||||
// 添加表情长按浏览手势
|
||||
[self p_addDisplayGesture];
|
||||
|
||||
// 加载表情详情cells
|
||||
[self p_loadGroupDetailCells];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
if (self.groupModel.data.count == 0) {
|
||||
[TLUIUtility showLoading:nil];
|
||||
[self requestExpressionGroupDetailDataWithPageIndex:1];
|
||||
}
|
||||
else {
|
||||
[self p_showExpressionItemsWithData:self.groupModel.data];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
|
||||
[TLUIUtility hiddenLoading];
|
||||
}
|
||||
|
||||
#pragma mark - # Requests
|
||||
- (void)requestExpressionGroupDetailDataWithPageIndex:(NSInteger)pageIndex
|
||||
{
|
||||
@weakify(self);
|
||||
[self.groupModel requestExpressionGroupDetailByPageIndex:pageIndex success:^(NSArray *data) {
|
||||
@strongify(self);
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
[TLUIUtility hiddenLoading];
|
||||
self.pageIndex = pageIndex;
|
||||
if (pageIndex == 1) {
|
||||
self.groupModel.data = [data mutableCopy];
|
||||
self.sectionForTag(TLExpressionDetailVCSectionTypeItems).clear();
|
||||
}
|
||||
else {
|
||||
[self.groupModel.data addObjectsFromArray:data];
|
||||
}
|
||||
[self p_showExpressionItemsWithData:data];
|
||||
} failure:^(NSString *error) {
|
||||
[TLUIUtility hiddenLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - # Event Response
|
||||
- (void)didLongPressScreen:(UILongPressGestureRecognizer *)sender
|
||||
{
|
||||
if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled) { // 长按停止
|
||||
[self.emojiDisplayView removeFromSuperview];
|
||||
}
|
||||
else {
|
||||
CGPoint point = [sender locationInView:self.collectionView];
|
||||
for (UICollectionViewCell *cell in self.collectionView.visibleCells) {
|
||||
if (cell.x <= point.x && cell.y <= point.y && cell.x + cell.width >= point.x && cell.y + cell.height >= point.y) {
|
||||
NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];
|
||||
TLExpressionModel *emoji = [self.groupModel objectAtIndex:indexPath.row];
|
||||
CGRect rect = cell.frame;
|
||||
rect.origin.y -= (self.collectionView.contentOffset.y + 13);
|
||||
[self.emojiDisplayView removeFromSuperview];
|
||||
[self.emojiDisplayView displayEmoji:emoji atRect:rect];
|
||||
[self.view addSubview:self.emojiDisplayView];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didTap5TimesScreen:(UITapGestureRecognizer *)sender
|
||||
{
|
||||
CGPoint point = [sender locationInView:self.collectionView];
|
||||
for (UICollectionViewCell *cell in self.collectionView.visibleCells) {
|
||||
if (cell.x <= point.x && cell.y <= point.y && cell.x + cell.width >= point.x && cell.y + cell.height >= point.y) {
|
||||
NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];
|
||||
TLExpressionModel *emoji = [self.groupModel objectAtIndex:indexPath.row];
|
||||
[TLUIUtility showLoading:@"正在将表情保存到系统相册"];
|
||||
NSString *urlString = [TLExpressionModel expressionDownloadURLWithEid:emoji.eId];
|
||||
NSData *data = [NSData dataWithContentsOfURL:TLURL(urlString)];
|
||||
if (!data) {
|
||||
data = [NSData dataWithContentsOfFile:emoji.path];
|
||||
}
|
||||
if (data) {
|
||||
UIImage *image = [UIImage imageWithData:data];
|
||||
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
|
||||
{
|
||||
if (error) {
|
||||
[TLUIUtility showAlertWithTitle:@"错误" message:[NSString stringWithFormat:@"保存图片到系统相册失败\n%@", [error description]]];
|
||||
}
|
||||
else {
|
||||
[TLUIUtility showSuccessHint:@"已保存到系统相册"];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - # Private Methods
|
||||
- (void)p_loadGroupDetailCells
|
||||
{
|
||||
self.addSection(TLExpressionDetailVCSectionTypeHeader);
|
||||
self.addSection(TLExpressionDetailVCSectionTypeItems)
|
||||
.sectionInsets(UIEdgeInsetsMake(EXP_DETAIL_EDGE, EXP_DETAIL_EDGE, EXP_DETAIL_EDGE, EXP_DETAIL_EDGE))
|
||||
.minimumLineSpacing(EXP_DETAIL_SPACE).minimumInteritemSpacing(EXP_DETAIL_SPACE);
|
||||
|
||||
if (self.groupModel) {
|
||||
// banner
|
||||
if (self.groupModel.bannerURL.length > 0) {
|
||||
self.addCell(@"TLExpressionDetailBannerCell").toSection(TLExpressionDetailVCSectionTypeHeader).withDataModel(self.groupModel.bannerURL);
|
||||
}
|
||||
// 介绍
|
||||
self.addCell(@"TLExpressionDetailInfoCell").toSection(TLExpressionDetailVCSectionTypeHeader).withDataModel(self.groupModel);
|
||||
// 分割线
|
||||
self.addCell(@"TLExpressionDetailSeperatorCell").toSection(TLExpressionDetailVCSectionTypeHeader);
|
||||
[self reloadView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)p_addDisplayGesture
|
||||
{
|
||||
UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc] init];
|
||||
[longPressGR setMinimumPressDuration:1.0f];
|
||||
[longPressGR addTarget:self action:@selector(didLongPressScreen:)];
|
||||
[self.collectionView addGestureRecognizer:longPressGR];
|
||||
|
||||
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] init];
|
||||
[tapGR setNumberOfTapsRequired:5];
|
||||
[tapGR setNumberOfTouchesRequired:1];
|
||||
[tapGR addTarget:self action:@selector(didTap5TimesScreen:)];
|
||||
[self.collectionView addGestureRecognizer:tapGR];
|
||||
}
|
||||
|
||||
- (void)p_showExpressionItemsWithData:(NSArray *)data
|
||||
{
|
||||
// 表情
|
||||
self.addCells(@"TLExpressionDetailItemCell").toSection(TLExpressionDetailVCSectionTypeItems).withDataModelArray(data);
|
||||
[self reloadView];
|
||||
}
|
||||
|
||||
#pragma mark - # Getter
|
||||
- (TLImageExpressionDisplayView *)emojiDisplayView
|
||||
{
|
||||
if (_emojiDisplayView == nil) {
|
||||
_emojiDisplayView = [[TLImageExpressionDisplayView alloc] init];
|
||||
}
|
||||
return _emojiDisplayView;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLExpressionDetailBannerCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/4.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TLExpressionDetailBannerCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@end
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// TLExpressionDetailBannerCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/4.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionDetailBannerCell.h"
|
||||
|
||||
@interface TLExpressionDetailBannerCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLExpressionDetailBannerCell
|
||||
|
||||
+ (CGSize)viewSizeByDataModel:(id)dataModel
|
||||
{
|
||||
return CGSizeMake(SCREEN_WIDTH, SCREEN_WIDTH * 0.45);
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(NSString *)dataModel
|
||||
{
|
||||
if (dataModel) {
|
||||
[self.imageView tt_setImageWithURL:TLURL(dataModel)];
|
||||
}
|
||||
else {
|
||||
[self.imageView setImage:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self setBackgroundColor:[UIColor whiteColor]];
|
||||
self.imageView = self.addImageView(1)
|
||||
.clipsToBounds(YES)
|
||||
.contentMode(UIViewContentModeScaleAspectFill)
|
||||
.masonry(^(MASConstraintMaker *make){
|
||||
make.edges.mas_equalTo(0);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TLExpressionDetailInfoCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/4/11.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TLExpressionGroupModel.h"
|
||||
|
||||
#define HEIGHT_EXP_BANNER (SCREEN_WIDTH * 0.45)
|
||||
|
||||
@interface TLExpressionDetailInfoCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) TLExpressionGroupModel *groupModel;
|
||||
|
||||
@end
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// TLExpressionDetailInfoCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/4/11.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionDetailInfoCell.h"
|
||||
#import "TLExpressionGroupModel+Download.h"
|
||||
#import "TLExpressionDownloadButton.h"
|
||||
|
||||
@interface TLExpressionDetailInfoCell ()
|
||||
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic, strong) TLExpressionDownloadButton *downloadButton;
|
||||
|
||||
@property (nonatomic, strong) UILabel *detailLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLExpressionDetailInfoCell
|
||||
|
||||
+ (CGSize)viewSizeByDataModel:(TLExpressionGroupModel *)group
|
||||
{
|
||||
CGFloat detailHeight = [group.detail boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 30, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:13.0f]} context:nil].size.height;
|
||||
CGFloat height = 85.0 + detailHeight;
|
||||
return CGSizeMake(SCREEN_WIDTH, height);
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
[self setGroupModel:dataModel];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.contentView addSubview:self.downloadButton];
|
||||
[self.contentView addSubview:self.detailLabel];
|
||||
|
||||
[self p_addMasonry];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setGroupModel:(TLExpressionGroupModel *)groupModel
|
||||
{
|
||||
_groupModel = groupModel;
|
||||
[self.titleLabel setText:groupModel.name];
|
||||
[self.detailLabel setText:groupModel.detail];
|
||||
|
||||
if (groupModel.status == TLExpressionGroupStatusLocal) {
|
||||
[self.downloadButton setStatus:TLExpressionDownloadButtonStatusDownloaded];
|
||||
}
|
||||
else if (groupModel.status == TLExpressionGroupStatusDownloading) {
|
||||
[self.downloadButton setStatus:TLExpressionDownloadButtonStatusDownloading];
|
||||
}
|
||||
else {
|
||||
[self.downloadButton setStatus:TLExpressionDownloadButtonStatusNet];
|
||||
}
|
||||
|
||||
@weakify(self);
|
||||
[self.downloadButton setProgress:groupModel.downloadProgress];
|
||||
[groupModel setDownloadProgressAction:^(TLExpressionGroupModel *groupModel, CGFloat progress) {
|
||||
@strongify(self);
|
||||
[self.downloadButton setProgress:progress];
|
||||
}];
|
||||
[groupModel setDownloadCompleteAction:^(TLExpressionGroupModel *groupModel, BOOL success, id data) {
|
||||
@strongify(self);
|
||||
[self setGroupModel:groupModel];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - # Private Methods
|
||||
- (void)p_addMasonry
|
||||
{
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(25.0f);
|
||||
make.left.mas_equalTo(15.0f);
|
||||
make.right.mas_lessThanOrEqualTo(self.downloadButton.mas_right).mas_offset(-15);
|
||||
}];
|
||||
[self.downloadButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.titleLabel).mas_offset(-3);
|
||||
make.right.mas_equalTo(self.contentView).mas_offset(-15.0f);
|
||||
make.size.mas_equalTo(CGSizeMake(83, 30));
|
||||
}];
|
||||
[self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel);
|
||||
make.right.mas_equalTo(self.contentView).mas_offset(-15);
|
||||
make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(20);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - # Getter
|
||||
- (UILabel *)titleLabel
|
||||
{
|
||||
if (_titleLabel == nil) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
[_titleLabel setBackgroundColor:[UIColor whiteColor]];
|
||||
[_titleLabel setClipsToBounds:YES];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (TLExpressionDownloadButton *)downloadButton
|
||||
{
|
||||
if (_downloadButton == nil) {
|
||||
_downloadButton = [[TLExpressionDownloadButton alloc] init];
|
||||
@weakify(self);
|
||||
[_downloadButton setDownloadButtonClick:^{
|
||||
@strongify(self);
|
||||
if (self.groupModel.status == TLExpressionGroupStatusNet) {
|
||||
[self.groupModel startDownload];
|
||||
[self setGroupModel:self.groupModel];
|
||||
}
|
||||
}];
|
||||
}
|
||||
return _downloadButton;
|
||||
}
|
||||
|
||||
- (UILabel *)detailLabel
|
||||
{
|
||||
if (_detailLabel == nil) {
|
||||
_detailLabel = [[UILabel alloc] init];
|
||||
[_detailLabel setBackgroundColor:[UIColor whiteColor]];
|
||||
[_detailLabel setClipsToBounds:YES];
|
||||
[_detailLabel setFont:[UIFont systemFontOfSize:13.0f]];
|
||||
[_detailLabel setTextColor:[UIColor grayColor]];
|
||||
[_detailLabel setNumberOfLines:0];
|
||||
}
|
||||
return _detailLabel;
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TLExpressionDetailItemCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/4/8.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TLExpressionModel.h"
|
||||
|
||||
#define EXP_DETAIL_EDGE 20.0
|
||||
#define EXP_DETAIL_SPACE 15.0
|
||||
#define EXP_DETAIL_CELL_WIDTH MIN(((SCREEN_WIDTH - EXP_DETAIL_EDGE * 2 - EXP_DETAIL_SPACE * 3.0) / 4.0), 84)
|
||||
|
||||
@interface TLExpressionDetailItemCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@property (nonatomic, strong) TLExpressionModel *emoji;
|
||||
|
||||
@end
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// TLExpressionDetailItemCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 16/4/8.
|
||||
// Copyright © 2016年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionDetailItemCell.h"
|
||||
#import <SDWebImage/UIImage+GIF.h>
|
||||
#import "UIImage+Color.h"
|
||||
|
||||
@interface TLExpressionDetailItemCell ()
|
||||
|
||||
@property (nonatomic, strong) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TLExpressionDetailItemCell
|
||||
|
||||
+ (CGSize)viewSizeByDataModel:(id)dataModel
|
||||
{
|
||||
return CGSizeMake(EXP_DETAIL_CELL_WIDTH, EXP_DETAIL_CELL_WIDTH);
|
||||
}
|
||||
|
||||
- (void)setViewDataModel:(id)dataModel
|
||||
{
|
||||
[self setEmoji:dataModel];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.imageView = self.contentView.addImageView(1)
|
||||
.cornerRadius(3.0f)
|
||||
.masonry(^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
})
|
||||
.view;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setEmoji:(TLExpressionModel *)emoji
|
||||
{
|
||||
_emoji = emoji;
|
||||
UIImage *image = [UIImage imageNamed:emoji.path];
|
||||
if (image) {
|
||||
[self.imageView setImage:image];
|
||||
}
|
||||
else {
|
||||
[self.imageView tt_setImageWithURL:TLURL(emoji.url)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TLExpressionDetailSeperatorCell.h
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/4.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TLExpressionDetailSeperatorCell : UICollectionViewCell <ZZFlexibleLayoutViewProtocol>
|
||||
|
||||
@end
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// TLExpressionDetailSeperatorCell.m
|
||||
// TLChat
|
||||
//
|
||||
// Created by 李伯坤 on 2018/1/4.
|
||||
// Copyright © 2018年 李伯坤. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TLExpressionDetailSeperatorCell.h"
|
||||
|
||||
@implementation TLExpressionDetailSeperatorCell
|
||||
|
||||
+ (CGSize)viewSizeByDataModel:(id)dataModel
|
||||
{
|
||||
return CGSizeMake(SCREEN_WIDTH, 20);
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self p_initUI];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)p_initUI
|
||||
{
|
||||
UIView *line1 = self.contentView.addView(1).backgroundColor([UIColor colorGrayLine]).view;
|
||||
UIView *line2 = self.contentView.addView(2).backgroundColor([UIColor colorGrayLine]).view;
|
||||
UILabel *label = self.contentView.addLabel(3)
|
||||
.backgroundColor([UIColor whiteColor]).clipsToBounds(YES)
|
||||
.textColor([UIColor colorGrayLine]).font([UIFont systemFontOfSize:12.0f])
|
||||
.text(LOCSTR(@"长按表情可预览")).view;
|
||||
[label mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(-5.0f);
|
||||
make.left.mas_equalTo(line1.mas_right).mas_offset(5.0f);
|
||||
make.right.mas_equalTo(line2.mas_left).mas_offset(-5.0f);
|
||||
}];
|
||||
[line1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(BORDER_WIDTH_1PX);
|
||||
make.left.mas_equalTo(15.0f);
|
||||
make.centerY.mas_equalTo(label);
|
||||
make.width.mas_equalTo(line2);
|
||||
}];
|
||||
[line2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(BORDER_WIDTH_1PX);
|
||||
make.right.mas_equalTo(-15.0f);
|
||||
make.centerY.mas_equalTo(label);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user