parent
fbba2f5dd7
commit
c70b1e9681
|
@ -2671,6 +2671,22 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
}
|
||||
|
||||
- (void)didLongPressSystemMessageCell:(OWSSystemMessageCell *)systemMessageCell;
|
||||
{
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
OWSAssert(systemMessageCell);
|
||||
OWSAssert(systemMessageCell.interaction);
|
||||
|
||||
DDLogDebug(@"%@ long pressed system message cell: %@", self.tag, systemMessageCell);
|
||||
|
||||
[systemMessageCell becomeFirstResponder];
|
||||
|
||||
UIMenuController *theMenu = [UIMenuController sharedMenuController];
|
||||
|
||||
[theMenu setTargetRect:systemMessageCell.titleLabel.frame inView:systemMessageCell];
|
||||
[theMenu setMenuVisible:YES animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - ContactEditingDelegate
|
||||
|
||||
- (void)didFinishEditingContact
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TSInteraction;
|
||||
@class OWSSystemMessageCell;
|
||||
|
||||
@protocol OWSSystemMessageCellDelegate <NSObject>
|
||||
|
||||
- (void)didTapSystemMessageWithInteraction:(TSInteraction *)interaction;
|
||||
- (void)didLongPressSystemMessageCell:(OWSSystemMessageCell *)systemMessageCell;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -21,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@property (nonatomic, weak) id<OWSSystemMessageCellDelegate> systemMessageCellDelegate;
|
||||
|
||||
@property (nonatomic, readonly) UILabel *titleLabel;
|
||||
@property (nonatomic, nullable, readonly) TSInteraction *interaction;
|
||||
|
||||
- (void)configureWithInteraction:(TSInteraction *)interaction;
|
||||
|
|
|
@ -72,6 +72,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
UITapGestureRecognizer *tap =
|
||||
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
|
||||
[self addGestureRecognizer:tap];
|
||||
|
||||
UILongPressGestureRecognizer *longpress =
|
||||
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongpressGesture:)];
|
||||
[self addGestureRecognizer:longpress];
|
||||
}
|
||||
|
||||
+ (NSString *)cellReuseIdentifier
|
||||
|
@ -290,6 +294,21 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
self.interaction = nil;
|
||||
}
|
||||
|
||||
#pragma mark - editing
|
||||
|
||||
- (BOOL)canBecomeFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)delete:(nullable id)sender
|
||||
{
|
||||
DDLogInfo(@"%@ chose delete", self.logTag);
|
||||
OWSAssert(self.interaction);
|
||||
|
||||
[self.interaction remove];
|
||||
}
|
||||
|
||||
#pragma mark - Gesture recognizers
|
||||
|
||||
- (void)handleTapGesture:(UITapGestureRecognizer *)tap
|
||||
|
@ -299,6 +318,26 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.systemMessageCellDelegate didTapSystemMessageWithInteraction:self.interaction];
|
||||
}
|
||||
|
||||
- (void)handleLongpressGesture:(UILongPressGestureRecognizer *)longpress
|
||||
{
|
||||
OWSAssert(self.interaction);
|
||||
if (longpress.state == UIGestureRecognizerStateBegan) {
|
||||
[self.systemMessageCellDelegate didLongPressSystemMessageCell:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Logging
|
||||
|
||||
+ (NSString *)logTag
|
||||
{
|
||||
return [NSString stringWithFormat:@"[%@]", self.class];
|
||||
}
|
||||
|
||||
- (NSString *)logTag
|
||||
{
|
||||
return self.class.logTag;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
Loading…
Reference in New Issue