Skip to content

Commit eade42d

Browse files
Fix extras double-tap edit, tab bar hide, and sticker scale
Double-tap-to-edit now intercepts the bubble gesture before the reaction path and uses setupEditMessage. Hide-tab-bar survives search/profile unhide. Animated sticker 240pt path respects sticker size percent. Co-authored-by: D3C0Y <decoder-dev@users.noreply.github.com>
1 parent 73260df commit eade42d

15 files changed

Lines changed: 51 additions & 29 deletions

File tree

‎submodules/BrowserUI/Sources/BrowserBookmarksScreen.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public final class BrowserBookmarksScreen: ViewController {
112112
}, openCheckoutOrReceipt: { _, _ in
113113
}, openSearch: {
114114
}, setupReply: { _ in
115+
}, setupEditMessage: { _ in
115116
}, canSetupReply: { _ in
116117
return .none
117118
}, canSendMessages: {

‎submodules/ChatListUI/Sources/ChatListController.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4854,7 +4854,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
48544854
completion?()
48554855

48564856
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: false), transition: transition)
4857-
(self.parent as? TabBarController)?.updateIsTabBarHidden(false, transition: transition)
4857+
(self.parent as? TabBarController)?.updateIsTabBarHidden(ForkExtrasHotFlags.hideTabBar, transition: transition)
48584858

48594859
self.isSearchActive = false
48604860
if let navigationController = self.navigationController as? NavigationController {

‎submodules/ContactListUI/Sources/ContactsController.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public class ContactsController: ViewController {
561561
private func deactivateSearch(animated: Bool) {
562562
self.contactsNode.deactivateSearch(placeholderNode: self.searchContentNode()?.placeholderNode, animated: animated)
563563
self.updateTabBarSearchState(ViewController.TabBarSearchState(isActive: false), transition: .animated(duration: 0.5, curve: .spring))
564-
(self.parent as? TabBarController)?.updateIsTabBarHidden(false, transition: .animated(duration: 0.5, curve: .spring))
564+
(self.parent as? TabBarController)?.updateIsTabBarHidden(ForkExtrasHotFlags.hideTabBar, transition: .animated(duration: 0.5, curve: .spring))
565565
self.requestLayout(transition: .animated(duration: 0.5, curve: .spring))
566566
}
567567

‎submodules/TelegramUI/Components/AlertComponent/AlertWebpagePreviewComponent/Sources/AlertWebpagePreviewComponent.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public final class AlertWebpagePreviewComponent: Component {
176176
openCheckoutOrReceipt: { _, _ in },
177177
openSearch: {},
178178
setupReply: { _ in },
179+
setupEditMessage: { _ in },
179180
canSetupReply: { _ in
180181
return .none
181182
},

‎submodules/TelegramUI/Components/Chat/ChatMessageAnimatedStickerItemNode/Sources/ChatMessageAnimatedStickerItemNode.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ public class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
871871
var imageBottomPadding: CGFloat = 0.0
872872
var imageHorizontalOffset: CGFloat = 0.0
873873
if !(telegramFile?.videoThumbnails.isEmpty ?? true) {
874-
displaySize = CGSize(width: 240.0, height: 240.0)
874+
displaySize = CGSize(width: 240.0 * stickerScale, height: 240.0 * stickerScale)
875875
imageVerticalInset = -20.0
876876
imageHorizontalOffset = 12.0
877877
}

‎submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/BUILD‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ swift_library(
3333
"//submodules/Markdown",
3434
"//submodules/WallpaperBackgroundNode",
3535
"//submodules/ChatPresentationInterfaceState",
36-
"//submodules/ChatInterfaceState",
3736
"//submodules/ChatMessageBackground",
3837
"//submodules/TelegramUI/Components/AnimationCache",
3938
"//submodules/TelegramUI/Components/MultiAnimationRenderer",

‎submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift‎

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import Markdown
2424
import TelegramStringFormatting
2525
import WallpaperBackgroundNode
2626
import ChatPresentationInterfaceState
27-
import ChatInterfaceState
2827
import ChatMessageBackground
2928
import AnimationCache
3029
import MultiAnimationRenderer
@@ -5736,14 +5735,42 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
57365735
super.animateFrameTransition(progress, currentValue)
57375736
}
57385737

5738+
private func beginDoubleTapEditIfNeeded(message: Message, item: ChatMessageItem) -> Bool {
5739+
guard ForkExtrasHotFlags.doubleTapToEdit else {
5740+
return false
5741+
}
5742+
switch message.id.namespace {
5743+
case Namespaces.Message.Cloud, Namespaces.Message.ScheduledCloud, Namespaces.Message.QuickReplyCloud:
5744+
break
5745+
default:
5746+
return false
5747+
}
5748+
if message.media.contains(where: { $0 is TelegramMediaAction }) {
5749+
return false
5750+
}
5751+
let isOwn = message.author?.id == item.context.account.peerId || !message.flags.contains(.Incoming)
5752+
guard isOwn else {
5753+
return false
5754+
}
5755+
item.controllerInteraction.setupEditMessage(message.id)
5756+
return true
5757+
}
5758+
57395759
@objc private func tapLongTapOrDoubleTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) {
57405760
switch recognizer.state {
57415761
case .ended:
57425762
if let (gesture, location) = recognizer.lastRecognizedGestureAndLocation, let item = self.item {
5743-
if let action = self.gestureRecognized(gesture: gesture, location: location, recognizer: nil) {
5744-
if case .doubleTap = gesture {
5745-
self.mainContainerNode.cancelGesture()
5763+
if case .doubleTap = gesture {
5764+
self.mainContainerNode.cancelGesture()
5765+
var editMessage = item.message
5766+
if let action = self.gestureRecognized(gesture: gesture, location: location, recognizer: nil), case let .openContextMenu(openContextMenu) = action {
5767+
editMessage = openContextMenu.tapMessage
5768+
}
5769+
if self.beginDoubleTapEditIfNeeded(message: editMessage, item: item) {
5770+
return
57465771
}
5772+
}
5773+
if let action = self.gestureRecognized(gesture: gesture, location: location, recognizer: nil) {
57475774
switch action {
57485775
case let .action(f):
57495776
f.action()
@@ -5759,24 +5786,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
57595786
} else if case .tap = gesture {
57605787
item.controllerInteraction.clickThroughMessage(self.view, location)
57615788
} else if case .doubleTap = gesture {
5762-
if ForkExtrasHotFlags.doubleTapToEdit, item.message.author?.id == item.context.account.peerId, item.message.id.namespace == Namespaces.Message.Cloud {
5763-
var entities: [MessageTextEntity] = []
5764-
for attribute in item.message.attributes {
5765-
if let attribute = attribute as? TextEntitiesMessageAttribute {
5766-
entities = attribute.entities
5767-
break
5768-
}
5769-
}
5770-
let inputText = chatInputStateStringWithAppliedEntities(item.message.text, entities: entities)
5771-
let editInputState = ChatTextInputState(inputText: inputText)
5772-
item.controllerInteraction.updatePresentationState { state in
5773-
return state.updatedInterfaceState { interfaceState in
5774-
return interfaceState.withUpdatedEditMessage(ChatEditMessageState(messageId: item.message.id, inputState: editInputState, disableUrlPreviews: [], inputTextMaxLength: 4096, mediaCaptionIsAbove: nil))
5775-
}.updatedInputMode({ _ in
5776-
return .text
5777-
})
5778-
}
5779-
} else if canAddMessageReactions(message: EngineMessage(item.message)) {
5789+
if canAddMessageReactions(message: EngineMessage(item.message)) {
57805790
item.controllerInteraction.updateMessageReaction(item.message, .default, false, nil)
57815791
}
57825792
}

‎submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsControllerNode.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
751751
}, openCheckoutOrReceipt: { _, _ in
752752
}, openSearch: {
753753
}, setupReply: { _ in
754+
}, setupEditMessage: { _ in
754755
}, canSetupReply: { _ in
755756
return .none
756757
}, canSendMessages: {

‎submodules/TelegramUI/Components/Chat/ChatSendAudioMessageContextPreview/Sources/ChatSendAudioMessageContextPreview.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ public final class ChatSendGroupMediaMessageContextPreview: UIView, ChatSendMess
437437
}, presentGlobalOverlayController: { _, _ in }, callPeer: { _, _ in }, openConferenceCall: { _ in
438438
}, longTap: { _, _ in }, todoItemLongTap: { _, _ in }, pollOptionLongTap: { _, _ in
439439
}, openCheckoutOrReceipt: { _, _ in }, openSearch: { }, setupReply: { _ in
440+
}, setupEditMessage: { _ in
440441
}, canSetupReply: { _ in
441442
return .none
442443
}, canSendMessages: {

‎submodules/TelegramUI/Components/ChatControllerInteraction/Sources/ChatControllerInteraction.swift‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol
244244
public let openCheckoutOrReceipt: (EngineMessage.Id, OpenMessageParams?) -> Void
245245
public let openSearch: () -> Void
246246
public let setupReply: (EngineMessage.Id) -> Void
247+
public let setupEditMessage: (EngineMessage.Id) -> Void
247248
public let canSetupReply: (EngineRawMessage) -> ChatControllerInteractionSwipeAction
248249
public let canSendMessages: () -> Bool
249250
public let navigateToFirstDateMessage: (Int32, Bool) -> Void
@@ -429,6 +430,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol
429430
openCheckoutOrReceipt: @escaping (EngineMessage.Id, OpenMessageParams?) -> Void,
430431
openSearch: @escaping () -> Void,
431432
setupReply: @escaping (EngineMessage.Id) -> Void,
433+
setupEditMessage: @escaping (EngineMessage.Id) -> Void,
432434
canSetupReply: @escaping (EngineRawMessage) -> ChatControllerInteractionSwipeAction,
433435
canSendMessages: @escaping () -> Bool,
434436
navigateToFirstDateMessage: @escaping(Int32, Bool) ->Void,
@@ -563,6 +565,7 @@ public final class ChatControllerInteraction: ChatControllerInteractionProtocol
563565
self.openCheckoutOrReceipt = openCheckoutOrReceipt
564566
self.openSearch = openSearch
565567
self.setupReply = setupReply
568+
self.setupEditMessage = setupEditMessage
566569
self.canSetupReply = canSetupReply
567570
self.canSendMessages = canSendMessages
568571
self.navigateToFirstDateMessage = navigateToFirstDateMessage

0 commit comments

Comments
 (0)