chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:35:01 +08:00
commit a2e318a963
2974 changed files with 158180 additions and 0 deletions
@@ -0,0 +1,18 @@
//
// TLExpressionGroupModel+MoreRequest.h
// TLChat
//
// Created by 李伯坤 on 2018/1/2.
// Copyright © 2018年 李伯坤. All rights reserved.
//
#import "TLExpressionGroupModel.h"
@interface TLExpressionGroupModel (MoreRequest)
/**
* 更多表情 —— 更多列表
*/
+ (TLBaseRequest *)requestExpressionMoreListByPageIndex:(NSInteger)page success:(TLRequestSuccessBlock)success failure:(TLRequestFailureBlock)failure;
@end
@@ -0,0 +1,65 @@
//
// TLExpressionGroupModel+MoreRequest.m
// TLChat
//
// Created by 李伯坤 on 2018/1/2.
// Copyright © 2018年 李伯坤. All rights reserved.
//
#import "TLExpressionGroupModel+MoreRequest.h"
#import "TLNetworking.h"
#define IEXPRESSION_MORE_URL [IEXPRESSION_HOST_URL stringByAppendingString:@"expre/listBy.do?pageNumber=%ld&status=Y&status1=B&count=yes"]
@implementation TLExpressionGroupModel (MoreRequest)
+ (TLBaseRequest *)requestExpressionMoreListByPageIndex:(NSInteger)page success:(TLRequestSuccessBlock)success failure:(TLRequestFailureBlock)failure
{
NSString *urlString = [NSString stringWithFormat:IEXPRESSION_MORE_URL, (long)page];
[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 = [TLExpressionGroupModel mj_objectArrayWithKeyValuesArray:infoArray];
if (success) {
success(data);
}
}
else {
if (failure) {
failure(status);
}
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
if (failure) {
failure(TLNetworkErrorTip);
}
}];
// NSString *urlString = [NSString stringWithFormat:IEXPRESSION_MORE_URL, (long)page];
// TLBaseRequest *request = [TLBaseRequest requestWithMethod:TLRequestMethodPOST url:urlString parameters:nil];
// [request startRequestWithSuccessAction:^(TLResponse *response) {
// NSArray *respArray = [response.responseData mj_JSONObject];
// NSString *status = respArray[0];
// if ([status isEqualToString:@"OK"]) {
// NSArray *infoArray = respArray[2];
// NSMutableArray *data = [TLExpressionGroupModel mj_objectArrayWithKeyValuesArray:infoArray];
// if (success) {
// success(data);
// }
// }
// else {
// if (failure) {
// failure(status);
// }
// }
// } failureAction:^(TLResponse *response) {
// if (failure) {
// failure(TLNetworkErrorTip);
// }
// }];
// return request;
return nil;
}
@end
@@ -0,0 +1,15 @@
//
// TLExpressionMoreViewController.h
// TLChat
//
// Created by 李伯坤 on 2017/7/18.
// Copyright © 2017年 李伯坤. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TLExpressionMoreViewController : ZZFlexibleLayoutViewController
- (void)requestDataIfNeed;
@end
@@ -0,0 +1,114 @@
//
// TLExpressionMoreViewController.m
// TLChat
//
// Created by 李伯坤 on 2017/7/18.
// Copyright © 2017年 李伯坤. All rights reserved.
//
#import "TLExpressionMoreViewController.h"
#import "TLExpressionDetailViewController.h"
#import "TLExpressionGroupModel+MoreRequest.h"
typedef NS_ENUM(NSInteger, TLExpressionMoreSectionType) {
TLExpressionMoreSectionTypeSearch,
TLExpressionMoreSectionTypeExprs,
};
@interface TLExpressionMoreViewController ()
@property (nonatomic, assign) NSInteger pageIndex;
@end
@implementation TLExpressionMoreViewController
- (void)loadView
{
[super loadView];
[self.collectionView setBackgroundColor:[UIColor whiteColor]];
@weakify(self);
// 搜索
self.addSection(TLExpressionMoreSectionTypeSearch);
self.addCell(@"TLExpressionMoreSearchCell").toSection(TLExpressionMoreSectionTypeSearch).eventAction(^ id(NSInteger eventType, id data) {
@strongify(self);
[self didSelectedExpressionGroup:data];
return nil;
});
// 表情
self.addSection(TLExpressionMoreSectionTypeExprs).backgrounColor([UIColor whiteColor]).sectionInsets(UIEdgeInsetsMake(15, 15, 0, 15)).minimumInteritemSpacing(15);
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
if (!CGRectEqualToRect(self.collectionView.frame, self.view.bounds)) {
[self.collectionView setFrame:self.view.bounds];
self.updateCells.all();
[self.collectionView reloadData];
}
}
- (void)requestDataIfNeed
{
if ([self dataModelArrayForSection:TLExpressionMoreSectionTypeExprs].count == 0) {
[TLUIUtility showLoading:nil];
[self requestExpressionMoreDataWithPageIndex:1];
}
}
#pragma mark - # Event Action
- (void)didSelectedExpressionGroup:(TLExpressionGroupModel *)groupModel
{
TLExpressionDetailViewController *detailVC = [[TLExpressionDetailViewController alloc] initWithGroupModel:groupModel];
PushVC(detailVC);
}
#pragma mark - # Request
- (void)requestExpressionMoreDataWithPageIndex:(NSInteger)pageIndex
{
if (pageIndex == 1) {
[self.collectionView tt_removeLoadMoreFooter];
}
self.pageIndex = pageIndex;
[self removeTipView];
@weakify(self);
[TLExpressionGroupModel requestExpressionMoreListByPageIndex:pageIndex success:^(NSArray *successData) {
@strongify(self);
[TLUIUtility hiddenLoading];
if (pageIndex == 1) {
[self deleteAllItemsForSection:TLExpressionMoreSectionTypeExprs];
}
if (successData.count > 0) {
if (pageIndex == 1) {
[self.collectionView tt_addLoadMoreFooterWithAction:^{
@strongify(self);
[self requestExpressionMoreDataWithPageIndex:self.pageIndex + 1];
}];
}
self.addCells(@"TLExpressionMoreCell").withDataModelArray(successData).toSection(TLExpressionMoreSectionTypeExprs).selectedAction(^ (id data) {
@strongify(self);
[self didSelectedExpressionGroup:data];
});
[self.collectionView tt_endLoadMore];
}
else {
[self.collectionView tt_showNoMoreFooter];
}
[self reloadView];
} failure:^(id failureData) {
@strongify(self);
[TLUIUtility hiddenLoading];
[self.collectionView tt_endLoadMore];
[self.view showErrorViewWithTitle:failureData retryAction:^(id userData) {
@strongify(self);
[self requestDataIfNeed];
}];
}];
}
@end
@@ -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
@@ -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
@@ -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
@@ -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