Files
keyboard/keyBoard/Class/AiTalk/VC/KBAIMessageVC.m

205 lines
6.6 KiB
Mathematica
Raw Normal View History

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