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+SearchRequest.h
// TLChat
//
// Created by 李伯坤 on 2018/1/2.
// Copyright © 2018年 李伯坤. All rights reserved.
//
#import "TLExpressionGroupModel.h"
@interface TLExpressionGroupModel (SearchRequest)
/**
* 表情搜索
*/
+ (TLBaseRequest *)requestExpressionSearchByKeyword:(NSString *)keyword success:(TLRequestSuccessBlock)success failure:(TLRequestFailureBlock)failure;
@end
@@ -0,0 +1,43 @@
//
// TLExpressionGroupModel+SearchRequest.m
// TLChat
//
// Created by 李伯坤 on 2018/1/2.
// Copyright © 2018年 李伯坤. All rights reserved.
//
#import "TLExpressionGroupModel+SearchRequest.h"
#import "TLNetworking.h"
#define IEXPRESSION_SEARCH_URL [IEXPRESSION_HOST_URL stringByAppendingString:@"expre/listBy.do?pageNumber=1&status=Y&eName=%@&seach=yes"]
@implementation TLExpressionGroupModel (SearchRequest)
+ (TLBaseRequest *)requestExpressionSearchByKeyword:(NSString *)keyword success:(TLRequestSuccessBlock)success failure:(TLRequestFailureBlock)failure
{
NSString *urlString = [NSString stringWithFormat:IEXPRESSION_SEARCH_URL, [[keyword urlEncode] urlEncode]];
[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);
}
}];
return nil;
}
@end
@@ -0,0 +1,16 @@
//
// TLExpressionSearchResultViewController.h
// TLChat
//
// Created by 李伯坤 on 16/4/4.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLViewController.h"
#import "TLSearchResultControllerProtocol.h"
@interface TLExpressionSearchResultViewController : TLViewController <TLSearchResultControllerProtocol>
@property (nonatomic, copy) void (^itemClickAction)(TLExpressionSearchResultViewController *searchController, id data);
@end
@@ -0,0 +1,118 @@
//
// TLExpressionSearchResultViewController.m
// TLChat
//
// Created by 李伯坤 on 16/4/4.
// Copyright © 2016年 李伯坤. All rights reserved.
//
#import "TLExpressionSearchResultViewController.h"
#import "TLExpressionDetailViewController.h"
#import "TLExpressionGroupModel+SearchRequest.h"
#define HEGIHT_EXPCELL 80
typedef NS_ENUM(NSInteger, TLExpressionSearchVCSectionType) {
TLExpressionSearchVCSectionTypeItems,
};
@interface TLExpressionSearchResultViewController ()
/// 列表
@property (nonatomic, strong) UITableView *tableView;
/// 列表管理器
@property (nonatomic, strong) ZZFLEXAngel *tableViewAngel;
@end
@implementation TLExpressionSearchResultViewController
- (void)loadView
{
[super loadView];
[self setStatusBarStyle:UIStatusBarStyleDefault];
self.tableView = self.view.addTableView(1)
.tableHeaderView([UIView new])
.separatorStyle(UITableViewCellSeparatorStyleNone)
.estimatedRowHeight(0).estimatedSectionFooterHeight(0).estimatedSectionHeaderHeight(0)
.masonry(^ (MASConstraintMaker *make) {
make.edges.mas_equalTo(0);
})
.view;
self.tableViewAngel = [[ZZFLEXAngel alloc] initWithHostView:self.tableView];
}
#pragma mark - # Request
- (void)requsetSearchExpressionGroupWithKeyword:(NSString *)keyword
{
[TLUIUtility showLoading:nil];
@weakify(self);
[TLExpressionGroupModel requestExpressionSearchByKeyword:keyword success:^(NSArray *data) {
[TLUIUtility hiddenLoading];
if (data.count > 0) {
[self p_reloadViewWithData:data];
}
else {
[self p_reloadViewWithData:nil];
[self.tableView showEmptyViewWithTitle:@"未搜索到相关表情包"];
}
} failure:^(NSString *error) {
[TLUIUtility showErrorHint:error];
[self p_reloadViewWithData:nil];
[self.tableView showErrorViewWithTitle:error retryAction:^(id userData) {
@strongify(self);
[self requsetSearchExpressionGroupWithKeyword:keyword];
}];
}];
}
#pragma mark - # Delegate
//MARK: UISearchBarDelegate
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[self.tableView removeTipView];
NSString *keyword = searchBar.text;
if (keyword.length > 0) {
[self requsetSearchExpressionGroupWithKeyword:keyword];
}
}
//MARK: UISearchControllerDelegate
- (void)willPresentSearchController:(UISearchController *)searchController;
{
[self p_clearView];
}
//MARK: UISearchResultsUpdating
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
NSString *keyword = searchController.searchBar.text;
if (keyword.length == 0) {
[self p_clearView];
}
}
#pragma mark - # Private Methods
- (void)p_clearView
{
[self.tableView removeTipView];
self.tableViewAngel.clear();
self.tableViewAngel.addSection(TLExpressionSearchVCSectionTypeItems);
[self.tableView reloadData];
}
- (void)p_reloadViewWithData:(NSArray *)data
{
@weakify(self);
self.tableViewAngel.sectionForTag(TLExpressionSearchVCSectionTypeItems).clear();
self.tableViewAngel.addCells(@"TLExpressionItemCell").toSection(TLExpressionSearchVCSectionTypeItems).withDataModelArray(data).selectedAction(^ (TLExpressionGroupModel *model) {
@strongify(self);
if (self.itemClickAction) {
self.itemClickAction(self, model);
}
});
[self.tableView reloadData];
}
@end