新增删除弹窗,修改bug

This commit is contained in:
2026-02-04 16:57:19 +08:00
parent 533e23ebfe
commit 3e30f619b9
5 changed files with 349 additions and 22 deletions

View File

@@ -245,6 +245,7 @@
04F4C0B62F33053800E8F08C /* KBSvipSubscribeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0B42F33053800E8F08C /* KBSvipSubscribeCell.m */; }; 04F4C0B62F33053800E8F08C /* KBSvipSubscribeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0B42F33053800E8F08C /* KBSvipSubscribeCell.m */; };
04F4C0BB2F3306CF00E8F08C /* KBSvipFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0BA2F3306CF00E8F08C /* KBSvipFlowLayout.m */; }; 04F4C0BB2F3306CF00E8F08C /* KBSvipFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0BA2F3306CF00E8F08C /* KBSvipFlowLayout.m */; };
04F4C0BC2F3306CF00E8F08C /* KBSvipBenefitBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0B82F3306CF00E8F08C /* KBSvipBenefitBgView.m */; }; 04F4C0BC2F3306CF00E8F08C /* KBSvipBenefitBgView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0B82F3306CF00E8F08C /* KBSvipBenefitBgView.m */; };
04F4C0BF2F33369900E8F08C /* KBAIChatDeleteConfirmView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F4C0BE2F33369900E8F08C /* KBAIChatDeleteConfirmView.m */; };
04FC95672EB0546C007BD342 /* KBKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95652EB0546C007BD342 /* KBKey.m */; }; 04FC95672EB0546C007BD342 /* KBKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95652EB0546C007BD342 /* KBKey.m */; };
04FC956A2EB05497007BD342 /* KBKeyButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95692EB05497007BD342 /* KBKeyButton.m */; }; 04FC956A2EB05497007BD342 /* KBKeyButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC95692EB05497007BD342 /* KBKeyButton.m */; };
04FC956D2EB054B7007BD342 /* KBKeyboardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC956C2EB054B7007BD342 /* KBKeyboardView.m */; }; 04FC956D2EB054B7007BD342 /* KBKeyboardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04FC956C2EB054B7007BD342 /* KBKeyboardView.m */; };
@@ -751,6 +752,8 @@
04F4C0B82F3306CF00E8F08C /* KBSvipBenefitBgView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSvipBenefitBgView.m; sourceTree = "<group>"; }; 04F4C0B82F3306CF00E8F08C /* KBSvipBenefitBgView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSvipBenefitBgView.m; sourceTree = "<group>"; };
04F4C0B92F3306CF00E8F08C /* KBSvipFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBSvipFlowLayout.h; sourceTree = "<group>"; }; 04F4C0B92F3306CF00E8F08C /* KBSvipFlowLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBSvipFlowLayout.h; sourceTree = "<group>"; };
04F4C0BA2F3306CF00E8F08C /* KBSvipFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSvipFlowLayout.m; sourceTree = "<group>"; }; 04F4C0BA2F3306CF00E8F08C /* KBSvipFlowLayout.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBSvipFlowLayout.m; sourceTree = "<group>"; };
04F4C0BD2F33369900E8F08C /* KBAIChatDeleteConfirmView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBAIChatDeleteConfirmView.h; sourceTree = "<group>"; };
04F4C0BE2F33369900E8F08C /* KBAIChatDeleteConfirmView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBAIChatDeleteConfirmView.m; sourceTree = "<group>"; };
04FC953A2EAFAE56007BD342 /* KeyBoardPrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyBoardPrefixHeader.pch; sourceTree = "<group>"; }; 04FC953A2EAFAE56007BD342 /* KeyBoardPrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyBoardPrefixHeader.pch; sourceTree = "<group>"; };
04FC95642EB0546C007BD342 /* KBKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKey.h; sourceTree = "<group>"; }; 04FC95642EB0546C007BD342 /* KBKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KBKey.h; sourceTree = "<group>"; };
04FC95652EB0546C007BD342 /* KBKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKey.m; sourceTree = "<group>"; }; 04FC95652EB0546C007BD342 /* KBKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KBKey.m; sourceTree = "<group>"; };
@@ -1489,6 +1492,8 @@
048FFD232F28A836005D62AE /* KBChatLimitPopView.m */, 048FFD232F28A836005D62AE /* KBChatLimitPopView.m */,
0F2A10112F3C0002002CA5A0 /* KBAIPersonaSidebarView.h */, 0F2A10112F3C0002002CA5A0 /* KBAIPersonaSidebarView.h */,
0F2A10122F3C0002002CA5A0 /* KBAIPersonaSidebarView.m */, 0F2A10122F3C0002002CA5A0 /* KBAIPersonaSidebarView.m */,
04F4C0BD2F33369900E8F08C /* KBAIChatDeleteConfirmView.h */,
04F4C0BE2F33369900E8F08C /* KBAIChatDeleteConfirmView.m */,
); );
path = PopView; path = PopView;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -2488,6 +2493,7 @@
046086CC2F1A092500757C95 /* KBAIReplyModel.m in Sources */, 046086CC2F1A092500757C95 /* KBAIReplyModel.m in Sources */,
046086CD2F1A092500757C95 /* KBAICommentModel.m in Sources */, 046086CD2F1A092500757C95 /* KBAICommentModel.m in Sources */,
04791F8F2ED469C0004E8522 /* KBHostAppLauncher.m in Sources */, 04791F8F2ED469C0004E8522 /* KBHostAppLauncher.m in Sources */,
04F4C0BF2F33369900E8F08C /* KBAIChatDeleteConfirmView.m in Sources */,
047C65582EBCC06D0035E841 /* HomeRankCardCell.m in Sources */, 047C65582EBCC06D0035E841 /* HomeRankCardCell.m in Sources */,
04D1F6B32EDFF10A00B12345 /* KBSkinInstallBridge.m in Sources */, 04D1F6B32EDFF10A00B12345 /* KBSkinInstallBridge.m in Sources */,
04122F912EC73AF700EF7AB3 /* KBVipPay.m in Sources */, 04122F912EC73AF700EF7AB3 /* KBVipPay.m in Sources */,

View File

@@ -99,8 +99,12 @@
- (void)sendButtonTapped { - (void)sendButtonTapped {
NSString *text = self.textField.text; NSString *text = self.textField.text;
if (text.length > 0 && self.onSend) { if (text.length > 0) {
self.onSend(text); if (self.onSend) {
self.onSend(text);
}
//
[self clearText];
} }
} }

View File

@@ -0,0 +1,27 @@
//
// KBAIChatDeleteConfirmView.h
// keyBoard
//
// Created by Codex on 2026/02/03.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class KBAIChatDeleteConfirmView;
@protocol KBAIChatDeleteConfirmViewDelegate <NSObject>
- (void)chatDeleteConfirmViewDidTapDelete:(KBAIChatDeleteConfirmView *)view;
- (void)chatDeleteConfirmViewDidTapCancel:(KBAIChatDeleteConfirmView *)view;
@end
@interface KBAIChatDeleteConfirmView : UIView
@property (nonatomic, weak) id<KBAIChatDeleteConfirmViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,172 @@
//
// KBAIChatDeleteConfirmView.m
// keyBoard
//
// Created by Codex on 2026/02/03.
//
#import "KBAIChatDeleteConfirmView.h"
#import <Masonry/Masonry.h>
@interface KBAIChatDeleteConfirmView ()
@property (nonatomic, strong) UIView *coverView;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *messageLabel;
@property (nonatomic, strong) UIButton *deleteButton;
@property (nonatomic, strong) UIButton *cancelButton;
@end
@implementation KBAIChatDeleteConfirmView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor clearColor];
self.layer.cornerRadius = 16.0;
self.layer.masksToBounds = YES;
[self setupUI];
}
return self;
}
#pragma mark - UI
- (void)setupUI {
[self addSubview:self.coverView];
[self addSubview:self.iconView];
[self.coverView addSubview:self.titleLabel];
[self.coverView addSubview:self.messageLabel];
[self.coverView addSubview:self.deleteButton];
[self.coverView addSubview:self.cancelButton];
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(216);
make.bottom.left.right.bottom.equalTo(self);
}];
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(5);
make.centerX.equalTo(self);
make.width.height.mas_equalTo(64);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.coverView).offset(50);
make.left.equalTo(self.coverView).offset(16);
make.right.equalTo(self.coverView).offset(-16);
}];
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).offset(16);
make.left.equalTo(self.coverView).offset(20);
make.right.equalTo(self.coverView).offset(-20);
}];
[self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.coverView).offset(24);
make.bottom.equalTo(self.coverView).offset(-20);
make.height.mas_equalTo(40);
make.right.equalTo(self.coverView.mas_centerX).offset(-15);
}];
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.coverView).offset(-24);
make.bottom.equalTo(self.coverView).offset(-20);
make.height.mas_equalTo(40);
make.left.equalTo(self.coverView.mas_centerX).offset(15);
}];
}
#pragma mark - Actions
- (void)onTapDelete {
if ([self.delegate respondsToSelector:@selector(chatDeleteConfirmViewDidTapDelete:)]) {
[self.delegate chatDeleteConfirmViewDidTapDelete:self];
}
}
- (void)onTapCancel {
if ([self.delegate respondsToSelector:@selector(chatDeleteConfirmViewDidTapCancel:)]) {
[self.delegate chatDeleteConfirmViewDidTapCancel:self];
}
}
#pragma mark - Lazy
- (UIImageView *)iconView {
if (!_iconView) {
_iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chat_del_icon"]];
_iconView.contentMode = UIViewContentModeScaleAspectFit;
}
return _iconView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = KBLocalized(@"Are you sure to delete?");
_titleLabel.font = [UIFont boldSystemFontOfSize:18];
_titleLabel.textColor = [UIColor colorWithWhite:0.1 alpha:1.0];
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (UILabel *)messageLabel {
if (!_messageLabel) {
_messageLabel = [[UILabel alloc] init];
_messageLabel.text = KBLocalized(@"The existing conversation history will be cleared.");
_messageLabel.font = [UIFont systemFontOfSize:14];
_messageLabel.textColor = [UIColor colorWithWhite:0.45 alpha:1.0];
_messageLabel.textAlignment = NSTextAlignmentCenter;
_messageLabel.numberOfLines = 0;
}
return _messageLabel;
}
- (UIButton *)deleteButton {
if (!_deleteButton) {
_deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_deleteButton setTitle:KBLocalized(@"Delete") forState:UIControlStateNormal];
[_deleteButton setTitleColor:[UIColor colorWithWhite:0.2 alpha:1.0] forState:UIControlStateNormal];
_deleteButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
_deleteButton.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1.0];
_deleteButton.layer.cornerRadius = 20;
_deleteButton.layer.masksToBounds = YES;
[_deleteButton addTarget:self action:@selector(onTapDelete) forControlEvents:UIControlEventTouchUpInside];
}
return _deleteButton;
}
- (UIButton *)cancelButton {
if (!_cancelButton) {
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setTitle:KBLocalized(@"Think Again") forState:UIControlStateNormal];
[_cancelButton setTitleColor:[UIColor colorWithWhite:0.15 alpha:1.0] forState:UIControlStateNormal];
_cancelButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
_cancelButton.backgroundColor = [UIColor colorWithRed:0.80 green:0.94 blue:0.72 alpha:1.0];
_cancelButton.layer.cornerRadius = 20;
_cancelButton.layer.masksToBounds = YES;
[_cancelButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButton;
}
- (UIView *)coverView{
if (!_coverView) {
_coverView = [[UIView alloc] init];
_coverView.backgroundColor = [UIColor whiteColor];
_coverView.layer.cornerRadius = 30;
_coverView.layer.masksToBounds = true;
}
return _coverView;
}
@end

View File

@@ -10,12 +10,14 @@
#import "KBChattedCompanionModel.h" #import "KBChattedCompanionModel.h"
#import "KBHUD.h" #import "KBHUD.h"
#import "KBAIChatMessageCacheManager.h" #import "KBAIChatMessageCacheManager.h"
#import "KBAIChatDeleteConfirmView.h"
#import "LSTPopView.h"
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
/// ///
static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidResetNotification"; static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidResetNotification";
@interface KBAIMessageChatingVC () @interface KBAIMessageChatingVC () <KBAIChatDeleteConfirmViewDelegate, UIGestureRecognizerDelegate>
@property (nonatomic, strong) AiVM *viewModel; @property (nonatomic, strong) AiVM *viewModel;
@property (nonatomic, strong) NSMutableArray<KBChattedCompanionModel *> *chattedList; @property (nonatomic, strong) NSMutableArray<KBChattedCompanionModel *> *chattedList;
@@ -24,6 +26,16 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
@property (nonatomic, strong) UIButton *deleteButton; @property (nonatomic, strong) UIButton *deleteButton;
/// indexPath /// indexPath
@property (nonatomic, strong) NSIndexPath *longPressIndexPath; @property (nonatomic, strong) NSIndexPath *longPressIndexPath;
///
@property (nonatomic, strong) UILongPressGestureRecognizer *longPressGesture;
///
@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;
/// completion
@property (nonatomic, assign) NSInteger deleteButtonGeneration;
/// indexPath使
@property (nonatomic, strong) NSIndexPath *pendingDeleteIndexPath;
///
@property (nonatomic, weak) LSTPopView *deleteConfirmPopView;
@end @end
@@ -39,23 +51,53 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
[self setupLongPressGesture]; [self setupLongPressGesture];
// //
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
tapGesture.cancelsTouchesInView = NO; // cell self.tapGesture.cancelsTouchesInView = NO; // cell
[self.tableView addGestureRecognizer:tapGesture]; self.tapGesture.delegate = self;
if (self.longPressGesture) {
[self.tapGesture requireGestureRecognizerToFail:self.longPressGesture];
}
[self.tableView addGestureRecognizer:self.tapGesture];
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
// tableView tap
if (gestureRecognizer == self.tapGesture) {
if (self.deleteButton && !self.deleteButton.hidden) {
CGPoint p = [touch locationInView:self.deleteButton];
if (CGRectContainsPoint(self.deleteButton.bounds, p)) {
return NO;
}
}
}
return YES;
} }
#pragma mark - #pragma mark -
- (void)setupLongPressGesture { - (void)setupLongPressGesture {
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; self.longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 0.5; // 0.5 self.longPressGesture.minimumPressDuration = 0.5; // 0.5
[self.tableView addGestureRecognizer:longPress]; self.longPressGesture.delegate = self;
[self.tableView addGestureRecognizer:self.longPressGesture];
} }
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture { - (void)handleLongPress:(UILongPressGestureRecognizer *)gesture {
CGPoint point = [gesture locationInView:self.tableView];
NSLog(@"[KBAIMessageChatingVC] longPress state=%ld point=(%.1f, %.1f)",
(long)gesture.state, point.x, point.y);
if (gesture.state == UIGestureRecognizerStateBegan) { if (gesture.state == UIGestureRecognizerStateBegan) {
CGPoint point = [gesture locationInView:self.tableView]; // tap tap
if (self.tapGesture.enabled) {
self.tapGesture.enabled = NO;
NSLog(@"[KBAIMessageChatingVC] tapGesture disabled for longPress");
}
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
NSLog(@"[KBAIMessageChatingVC] longPress began indexPath=%@",
indexPath);
if (indexPath) { if (indexPath) {
// //
@@ -64,12 +106,23 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
// showDeleteButtonAtPoint hideDeleteButton // showDeleteButtonAtPoint hideDeleteButton
self.longPressIndexPath = indexPath; self.longPressIndexPath = indexPath;
} }
} else if (gesture.state == UIGestureRecognizerStateEnded ||
gesture.state == UIGestureRecognizerStateCancelled ||
gesture.state == UIGestureRecognizerStateFailed) {
if (!self.tapGesture.enabled) {
self.tapGesture.enabled = YES;
NSLog(@"[KBAIMessageChatingVC] tapGesture re-enabled after longPress");
}
} }
} }
- (void)handleTapGesture:(UITapGestureRecognizer *)gesture { - (void)handleTapGesture:(UITapGestureRecognizer *)gesture {
// //
if (self.deleteButton && !self.deleteButton.hidden) { if (self.deleteButton && !self.deleteButton.hidden) {
CGPoint pointInView = [gesture locationInView:self.tableView];
NSLog(@"[KBAIMessageChatingVC] tap state=%ld point=(%.1f, %.1f)",
(long)gesture.state, pointInView.x, pointInView.y);
CGPoint pointInButton = [gesture locationInView:self.deleteButton]; CGPoint pointInButton = [gesture locationInView:self.deleteButton];
// //
@@ -83,8 +136,10 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
} }
- (void)showDeleteButtonAtPoint:(CGPoint)point { - (void)showDeleteButtonAtPoint:(CGPoint)point {
// // 使 completion
[self hideDeleteButton]; self.deleteButtonGeneration += 1;
NSLog(@"[KBAIMessageChatingVC] showDeleteButtonAtPoint=(%.1f, %.1f) generation=%ld",
point.x, point.y, (long)self.deleteButtonGeneration);
// //
if (!self.deleteButton) { if (!self.deleteButton) {
@@ -105,7 +160,14 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
} }
// //
[self.view addSubview:self.deleteButton]; if (self.deleteButton.superview != self.view) {
[self.view addSubview:self.deleteButton];
} else {
[self.view bringSubviewToFront:self.deleteButton];
}
//
[self.deleteButton.layer removeAllAnimations];
// //
CGSize buttonSize = CGSizeMake(110, 40); CGSize buttonSize = CGSizeMake(110, 40);
@@ -138,6 +200,9 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
}]; }];
self.deleteButton.hidden = NO; self.deleteButton.hidden = NO;
self.deleteButton.alpha = 1.0;
self.deleteButton.transform = CGAffineTransformIdentity;
NSLog(@"[KBAIMessageChatingVC] deleteButton shown");
// //
self.deleteButton.transform = CGAffineTransformMakeScale(0.3, 0.3); self.deleteButton.transform = CGAffineTransformMakeScale(0.3, 0.3);
@@ -150,10 +215,20 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
- (void)hideDeleteButton { - (void)hideDeleteButton {
if (self.deleteButton) { if (self.deleteButton) {
NSInteger generation = self.deleteButtonGeneration;
NSLog(@"[KBAIMessageChatingVC] hideDeleteButton generation=%ld", (long)generation);
//
[self.deleteButton.layer removeAllAnimations];
[UIView animateWithDuration:0.15 animations:^{ [UIView animateWithDuration:0.15 animations:^{
self.deleteButton.alpha = 0; self.deleteButton.alpha = 0;
self.deleteButton.transform = CGAffineTransformMakeScale(0.8, 0.8); self.deleteButton.transform = CGAffineTransformMakeScale(0.8, 0.8);
} completion:^(BOOL finished) { } completion:^(BOOL finished) {
//
if (generation != self.deleteButtonGeneration) {
NSLog(@"[KBAIMessageChatingVC] hide completion ignored (generation changed: %ld -> %ld)",
(long)generation, (long)self.deleteButtonGeneration);
return;
}
self.deleteButton.hidden = YES; self.deleteButton.hidden = YES;
[self.deleteButton removeFromSuperview]; [self.deleteButton removeFromSuperview];
}]; }];
@@ -166,14 +241,60 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
return; return;
} }
// indexPath // indexPath hideDeleteButton
NSIndexPath *indexPath = self.longPressIndexPath; self.pendingDeleteIndexPath = self.longPressIndexPath;
[self hideDeleteButton];
[self showDeleteConfirmPopView];
}
#pragma mark -
- (void)showDeleteConfirmPopView {
if (self.deleteConfirmPopView) {
[self.deleteConfirmPopView dismiss];
}
CGFloat width = KB_SCREEN_WIDTH - 80;
KBAIChatDeleteConfirmView *content = [[KBAIChatDeleteConfirmView alloc] initWithFrame:CGRectMake(0, 0, width, 260)];
content.delegate = self;
LSTPopView *popView = [LSTPopView initWithCustomView:content
parentView:nil
popStyle:LSTPopStyleFade
dismissStyle:LSTDismissStyleFade];
popView.bgColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
popView.hemStyle = LSTHemStyleCenter;
popView.isClickBgDismiss = YES;
popView.isAvoidKeyboard = NO;
self.deleteConfirmPopView = popView;
[popView pop];
}
#pragma mark - KBAIChatDeleteConfirmViewDelegate
- (void)chatDeleteConfirmViewDidTapDelete:(KBAIChatDeleteConfirmView *)view {
[self.deleteConfirmPopView dismiss];
NSIndexPath *indexPath = self.pendingDeleteIndexPath;
self.pendingDeleteIndexPath = nil;
[self performDeleteAtIndexPath:indexPath];
}
- (void)chatDeleteConfirmViewDidTapCancel:(KBAIChatDeleteConfirmView *)view {
[self.deleteConfirmPopView dismiss];
self.pendingDeleteIndexPath = nil;
}
#pragma mark -
- (void)performDeleteAtIndexPath:(NSIndexPath *)indexPath {
if (!indexPath) {
return;
}
// //
if (indexPath.row >= self.chattedList.count) { if (indexPath.row >= self.chattedList.count) {
NSLog(@"[KBAIMessageChatingVC] 错误索引越界row=%ld, count=%ld", NSLog(@"[KBAIMessageChatingVC] 错误索引越界row=%ld, count=%ld",
(long)indexPath.row, (long)self.chattedList.count); (long)indexPath.row, (long)self.chattedList.count);
[self hideDeleteButton];
return; return;
} }
@@ -183,9 +304,6 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
NSLog(@"[KBAIMessageChatingVC] 开始删除聊天记录companionId=%ld, name=%@", NSLog(@"[KBAIMessageChatingVC] 开始删除聊天记录companionId=%ld, name=%@",
(long)companionId, model.name); (long)companionId, model.name);
//
[self hideDeleteButton];
// //
[KBHUD show]; [KBHUD show];