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

152 lines
4.8 KiB
Mathematica
Raw Normal View History

2026-01-28 16:35:47 +08:00
//
// KBAIMessageListVC.m
// keyBoard
//
// Created by Mac on 2026/1/28.
//
#import "KBAIMessageListVC.h"
#import "KBAIMessageCell.h"
#import <Masonry/Masonry.h>
@interface KBAIMessageListVC () <UITableViewDelegate, UITableViewDataSource>
@end
@implementation KBAIMessageListVC
#pragma mark - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
2026-01-28 19:31:27 +08:00
self.view.backgroundColor = [UIColor clearColor];
2026-01-28 16:35:47 +08:00
/// 1
[self setupUI];
/// 2
[self loadData];
}
#pragma mark - 1
- (void)setupUI {
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
}
#pragma mark - 2
- (void)loadData {
//
}
- (void)deleteItemAtIndexPath:(NSIndexPath *)indexPath {
//
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
KBAIMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KBAIMessageCell" forIndexPath:indexPath];
cell.indexPath = indexPath;
//
if (indexPath.row < self.dataArray.count) {
NSDictionary *item = self.dataArray[indexPath.row];
[cell configWithAvatar:item[@"avatar"]
name:item[@"name"]
content:item[@"content"]
time:item[@"time"]
isPinned:[item[@"isPinned"] boolValue]];
}
return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 76;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
//
}
///
2026-01-28 18:11:46 +08:00
//- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) {
//
// NSLog(@"[KBAIMessageListVC] trailingSwipeActionsConfigurationForRowAtIndexPath called for row: %ld", (long)indexPath.row);
//
// __weak typeof(self) weakSelf = self;
//
// //
// UIContextualAction *deleteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
// title:nil
// handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
// NSLog(@"[KBAIMessageListVC] Delete action triggered for row: %ld", (long)indexPath.row);
// [weakSelf deleteItemAtIndexPath:indexPath];
// completionHandler(YES);
// }];
// deleteAction.backgroundColor = [UIColor colorWithHex:0xF44336];
// if (@available(iOS 13.0, *)) {
// deleteAction.image = [UIImage systemImageNamed:@"trash.fill"];
// }
//
// UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[deleteAction]];
// config.performsFirstActionWithFullSwipe = NO;
// return config;
//}
//- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// NSLog(@"[KBAIMessageListVC] canEditRowAtIndexPath called for row: %ld", (long)indexPath.row);
// return YES;
//}
//- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
// NSLog(@"[KBAIMessageListVC] editingStyleForRowAtIndexPath called for row: %ld", (long)indexPath.row);
// return UITableViewCellEditingStyleDelete;
//}
2026-01-28 16:35:47 +08:00
#pragma mark - JXCategoryListContentViewDelegate
- (UIView *)listView {
return self.view;
}
#pragma mark - Lazy Load
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
2026-01-28 19:31:27 +08:00
_tableView.backgroundColor = [UIColor clearColor];
2026-01-28 16:35:47 +08:00
_tableView.showsVerticalScrollIndicator = NO;
[_tableView registerClass:[KBAIMessageCell class] forCellReuseIdentifier:@"KBAIMessageCell"];
if (@available(iOS 15.0, *)) {
_tableView.sectionHeaderTopPadding = 0;
}
}
return _tableView;
}
- (NSMutableArray *)dataArray {
if (!_dataArray) {
_dataArray = [NSMutableArray array];
}
return _dataArray;
}
@end