This commit is contained in:
2026-01-28 16:35:47 +08:00
parent 22f77d56ea
commit b4db79eba8
23 changed files with 1185 additions and 0 deletions

View File

@@ -0,0 +1,170 @@
//
// 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>
///
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
///
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
///
@property (nonatomic, strong) UIButton *searchButton;
///
@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
[self bindActions];
}
#pragma mark - 1
- (void)setupUI {
//
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);
make.width.mas_equalTo(180);
}];
//
[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);
}];
//
[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;
}
#pragma mark - 2
- (void)bindActions {
[self.searchButton addTarget:self action:@selector(searchButtonTapped) forControlEvents:UIControlEventTouchUpInside];
}
#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
- (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;
}
return _listContainerView;
}
- (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;
}
@end