2026-01-28 16:35:47 +08:00
|
|
|
|
//
|
|
|
|
|
|
// KBAIMessageVC.m
|
|
|
|
|
|
// keyBoard
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by Mac on 2026/1/28.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "KBAIMessageVC.h"
|
|
|
|
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
|
|
|
|
#import "KBAIMessageZanVC.h"
|
|
|
|
|
|
#import "KBAIMessageChatingVC.h"
|
|
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
|
|
|
|
|
|
|
@interface KBAIMessageVC () <JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
|
|
|
|
|
|
|
2026-01-28 19:31:27 +08:00
|
|
|
|
/// 背景图
|
|
|
|
|
|
@property (nonatomic, strong) UIImageView *backgroundImageView;
|
|
|
|
|
|
|
2026-01-28 16:35:47 +08:00
|
|
|
|
/// 分类标签视图
|
|
|
|
|
|
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
|
|
|
|
|
|
|
|
|
|
|
/// 列表容器
|
|
|
|
|
|
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
|
|
|
|
|
|
|
|
|
|
|
|
/// 右侧搜索按钮
|
2026-02-02 21:25:28 +08:00
|
|
|
|
//@property (nonatomic, strong) UIButton *searchButton;
|
2026-01-28 16:35:47 +08:00
|
|
|
|
|
|
|
|
|
|
/// 标题数组
|
|
|
|
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation KBAIMessageVC
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Lifecycle
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
|
|
|
|
/// 1:控件初始化
|
|
|
|
|
|
[self setupUI];
|
|
|
|
|
|
|
|
|
|
|
|
/// 2:绑定事件
|
2026-02-02 21:25:28 +08:00
|
|
|
|
// [self bindActions];
|
2026-01-28 16:35:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - 1:控件初始化
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setupUI {
|
2026-01-28 19:31:27 +08:00
|
|
|
|
// 添加背景图
|
|
|
|
|
|
// [self.view addSubview:self.backgroundImageView];
|
|
|
|
|
|
self.kb_navView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
[self.view insertSubview:self.backgroundImageView belowSubview:self.kb_navView];
|
|
|
|
|
|
[self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.edges.equalTo(self.view);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
2026-01-28 16:35:47 +08:00
|
|
|
|
// 隐藏默认导航栏标题
|
|
|
|
|
|
self.kb_titleLabel.hidden = YES;
|
|
|
|
|
|
|
|
|
|
|
|
// 添加分类视图到导航栏位置
|
|
|
|
|
|
[self.kb_navView addSubview:self.categoryView];
|
|
|
|
|
|
[self.categoryView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.left.equalTo(self.kb_backButton.mas_right).offset(0);
|
|
|
|
|
|
make.centerY.equalTo(self.kb_backButton);
|
|
|
|
|
|
make.height.mas_equalTo(44);
|
2026-01-28 18:11:46 +08:00
|
|
|
|
make.width.mas_equalTo(250);
|
2026-01-28 16:35:47 +08:00
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
// 添加搜索按钮
|
2026-02-02 21:25:28 +08:00
|
|
|
|
// [self.kb_navView addSubview:self.searchButton];
|
|
|
|
|
|
// [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
// make.right.equalTo(self.kb_navView).offset(-16);
|
|
|
|
|
|
// make.centerY.equalTo(self.kb_backButton);
|
|
|
|
|
|
// make.width.height.mas_equalTo(24);
|
|
|
|
|
|
// }];
|
2026-01-28 16:35:47 +08:00
|
|
|
|
|
|
|
|
|
|
// 添加列表容器
|
|
|
|
|
|
[self.view addSubview:self.listContainerView];
|
|
|
|
|
|
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.top.equalTo(self.kb_navView.mas_bottom);
|
|
|
|
|
|
make.left.right.bottom.equalTo(self.view);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
// 关联 categoryView 和 listContainerView
|
|
|
|
|
|
self.categoryView.listContainer = self.listContainerView;
|
2026-01-28 19:31:27 +08:00
|
|
|
|
self.listContainerView.backgroundColor = [UIColor clearColor];
|
2026-01-28 18:11:46 +08:00
|
|
|
|
|
|
|
|
|
|
// 初始状态:默认选中第一个 tab (Thumbs Up),允许左右滑动切换
|
|
|
|
|
|
// self.listContainerView.scrollView.scrollEnabled = YES;
|
|
|
|
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
2026-01-28 16:35:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - 2:绑定事件
|
|
|
|
|
|
|
2026-02-02 21:25:28 +08:00
|
|
|
|
//- (void)bindActions {
|
|
|
|
|
|
// [self.searchButton addTarget:self action:@selector(searchButtonTapped) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
//}
|
2026-01-28 16:35:47 +08:00
|
|
|
|
|
|
|
|
|
|
#pragma mark - Actions
|
|
|
|
|
|
|
|
|
|
|
|
- (void)searchButtonTapped {
|
|
|
|
|
|
// TODO: 跳转搜索页面
|
|
|
|
|
|
NSLog(@"搜索按钮点击");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
|
|
|
|
|
|
|
|
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|
|
|
|
|
NSLog(@"选中分类:%@", self.titles[index]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - JXCategoryListContainerViewDelegate
|
|
|
|
|
|
|
|
|
|
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
|
|
|
|
return self.titles.count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
return [[KBAIMessageZanVC alloc] init];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return [[KBAIMessageChatingVC alloc] init];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Lazy Load
|
|
|
|
|
|
|
2026-01-28 19:31:27 +08:00
|
|
|
|
- (UIImageView *)backgroundImageView {
|
|
|
|
|
|
if (!_backgroundImageView) {
|
|
|
|
|
|
_backgroundImageView = [[UIImageView alloc] init];
|
|
|
|
|
|
_backgroundImageView.image = [UIImage imageNamed:@"message_bg_icon"];
|
|
|
|
|
|
_backgroundImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
|
|
_backgroundImageView.clipsToBounds = YES;
|
|
|
|
|
|
}
|
|
|
|
|
|
return _backgroundImageView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-28 16:35:47 +08:00
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
|
|
|
|
if (!_titles) {
|
|
|
|
|
|
_titles = @[KBLocalized(@"Thumbs Up"), KBLocalized(@"Chatting")];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _titles;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (JXCategoryTitleView *)categoryView {
|
|
|
|
|
|
if (!_categoryView) {
|
|
|
|
|
|
_categoryView = [[JXCategoryTitleView alloc] init];
|
|
|
|
|
|
_categoryView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
_categoryView.titles = self.titles;
|
|
|
|
|
|
_categoryView.delegate = self;
|
|
|
|
|
|
|
|
|
|
|
|
// 标题样式
|
|
|
|
|
|
_categoryView.titleFont = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
|
|
|
|
|
_categoryView.titleSelectedFont = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
|
|
|
|
|
_categoryView.titleColor = [UIColor colorWithHex:0x9F9F9F];
|
|
|
|
|
|
_categoryView.titleSelectedColor = [UIColor colorWithHex:0x1B1F1A];
|
|
|
|
|
|
|
|
|
|
|
|
// 不需要指示器
|
|
|
|
|
|
_categoryView.indicators = @[];
|
|
|
|
|
|
|
|
|
|
|
|
// 间距设置
|
|
|
|
|
|
_categoryView.cellSpacing = 20;
|
|
|
|
|
|
_categoryView.contentEdgeInsetLeft = 0;
|
|
|
|
|
|
_categoryView.contentEdgeInsetRight = 0;
|
|
|
|
|
|
_categoryView.averageCellSpacingEnabled = NO;
|
|
|
|
|
|
|
|
|
|
|
|
// 禁用缩放和渐变
|
|
|
|
|
|
_categoryView.cellWidthZoomEnabled = NO;
|
|
|
|
|
|
_categoryView.titleColorGradientEnabled = NO;
|
|
|
|
|
|
}
|
|
|
|
|
|
return _categoryView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (JXCategoryListContainerView *)listContainerView {
|
|
|
|
|
|
if (!_listContainerView) {
|
|
|
|
|
|
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
|
|
|
|
_listContainerView.scrollView.bounces = NO;
|
2026-01-28 18:11:46 +08:00
|
|
|
|
// _listContainerView.scrollView.scrollEnabled = false;
|
|
|
|
|
|
|
|
|
|
|
|
// 不延迟触摸事件,让手势能更快响应
|
|
|
|
|
|
// for (UIGestureRecognizer *gestureRecognizer in _listContainerView.scrollView.gestureRecognizers) {
|
|
|
|
|
|
// if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
|
|
|
|
// gestureRecognizer.delaysTouchesBegan = NO;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2026-01-28 16:35:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
return _listContainerView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 21:25:28 +08:00
|
|
|
|
//- (UIButton *)searchButton {
|
|
|
|
|
|
// if (!_searchButton) {
|
|
|
|
|
|
// _searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
|
// if (@available(iOS 13.0, *)) {
|
|
|
|
|
|
// UIImage *searchImage = [UIImage systemImageNamed:@"magnifyingglass"];
|
|
|
|
|
|
// [_searchButton setImage:searchImage forState:UIControlStateNormal];
|
|
|
|
|
|
// _searchButton.tintColor = [UIColor colorWithHex:0x1B1F1A];
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return _searchButton;
|
|
|
|
|
|
//}
|
2026-01-28 16:35:47 +08:00
|
|
|
|
|
|
|
|
|
|
@end
|