129 lines
4.8 KiB
Objective-C
129 lines
4.8 KiB
Objective-C
//
|
|
// QXRoomEmojiView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/10/22.
|
|
//
|
|
|
|
#import "QXRoomEmojiView.h"
|
|
#import "JXCategoryView.h"
|
|
#import "QXMineNetwork.h"
|
|
#import "QXRoomEmojiContentView.h"
|
|
|
|
@interface QXRoomEmojiView()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate,UIGestureRecognizerDelegate,QXRoomEmojiContentViewDelegate>
|
|
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
|
|
@property (nonatomic,strong)JXCategoryListContainerView *containerView;
|
|
@property (nonatomic,strong)QXRoomEmojiContentView *contentView;
|
|
@property (nonatomic,strong)NSMutableArray *dataArray;
|
|
@property (nonatomic,strong)NSMutableArray *titleArray;
|
|
@property (nonatomic,strong)UIView *bgView;
|
|
@end
|
|
@implementation QXRoomEmojiView
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)initSubviews{
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
|
tap.delegate = self;
|
|
[self addGestureRecognizer:tap];
|
|
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
|
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(330))];
|
|
self.bgView.backgroundColor = RGB16(0x1B1926);
|
|
[self.bgView addRoundedCornersWithRadius:14 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
|
[self addSubview:self.bgView];
|
|
|
|
|
|
self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(14, 0, SCREEN_WIDTH, 50)];
|
|
self.categoryView.delegate = self;
|
|
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#FFFFFF"];
|
|
self.categoryView.titleColor = [UIColor colorWithHexString:@"#BDBBC8"];
|
|
self.categoryView.cellWidth = JXCategoryViewAutomaticDimension;
|
|
self.categoryView.contentEdgeInsetLeft = 5;
|
|
self.categoryView.cellSpacing = 24;
|
|
// self.categoryView.titleLabelZoomScale = 1.1;
|
|
self.categoryView.titleLabelZoomEnabled = YES;
|
|
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:16];
|
|
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:18];
|
|
self.categoryView.averageCellSpacingEnabled = NO;
|
|
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
|
lineView.indicatorColor = RGB16(0xffffff);
|
|
lineView.indicatorWidth = JXCategoryViewAutomaticDimension;
|
|
self.categoryView.indicators = @[lineView];
|
|
self.containerView = [[JXCategoryListContainerView alloc] initWithType:(JXCategoryListContainerType_ScrollView) delegate:self];
|
|
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom);
|
|
[self.bgView addSubview:self.categoryView];
|
|
[self.bgView addSubview:self.containerView];
|
|
self.categoryView.listContainer = self.containerView;
|
|
[self getEmojiTypeList];
|
|
}
|
|
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
|
return touch.view == self;
|
|
}
|
|
-(void)getEmojiTypeList{
|
|
@weakify(self)
|
|
[QXMineNetwork roomEmojiTypeListSuccessBlock:^(NSArray<QXEmojiTypeModel *> * _Nonnull list) {
|
|
@strongify(self);
|
|
[self.dataArray removeAllObjects];
|
|
[self.dataArray addObjectsFromArray:list];
|
|
[self.titleArray removeAllObjects];
|
|
for (QXEmojiTypeModel *md in list) {
|
|
[self.titleArray addObject:md.type_name];
|
|
}
|
|
self.categoryView.titles = self.titleArray;
|
|
[self.categoryView reloadData];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
|
|
-(void)didSelectedEmoji:(QXEmojiModel *)model{
|
|
[self hide];
|
|
[[QXRoomMessageManager shared] sendChatEmoji:model];
|
|
}
|
|
-(NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
|
|
return self.dataArray.count;
|
|
}
|
|
-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
|
|
QXRoomEmojiContentView *emojiView = [[QXRoomEmojiContentView alloc] initWithFrame:self.containerView.bounds];
|
|
emojiView.model = self.dataArray[index];
|
|
emojiView.delegate = self;
|
|
return emojiView;
|
|
}
|
|
|
|
-(void)showInView:(UIView *)view{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
[view addSubview:self];
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(330);
|
|
}];
|
|
}
|
|
-(void)hide{
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
|
|
-(NSMutableArray *)dataArray{
|
|
if (!_dataArray) {
|
|
_dataArray = [NSMutableArray array];
|
|
}
|
|
return _dataArray;
|
|
}
|
|
-(NSMutableArray *)titleArray{
|
|
if (!_titleArray) {
|
|
_titleArray = [NSMutableArray array];
|
|
}
|
|
return _titleArray;
|
|
}
|
|
@end
|