Various improvements

This commit is contained in:
Isaac 2024-02-06 01:04:15 +04:00
parent 9006b615e6
commit 3ce47cc05a
5 changed files with 29 additions and 8 deletions

View File

@ -30,6 +30,7 @@ swift_library(
"//submodules/TelegramUI/Components/TabSelectorComponent", "//submodules/TelegramUI/Components/TabSelectorComponent",
"//submodules/TelegramUI/Components/LottieComponent", "//submodules/TelegramUI/Components/LottieComponent",
"//submodules/TelegramUI/Components/PlainButtonComponent", "//submodules/TelegramUI/Components/PlainButtonComponent",
"//submodules/UIKitRuntimeUtils",
], ],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",

View File

@ -13,6 +13,7 @@ import EntityKeyboard
import AnimationCache import AnimationCache
import MultiAnimationRenderer import MultiAnimationRenderer
import UndoUI import UndoUI
import UIKitRuntimeUtils
private let animationDurationFactor: Double = 1.0 private let animationDurationFactor: Double = 1.0
@ -559,6 +560,10 @@ final class ContextControllerNode: ViewControllerTracingNode, UIScrollViewDelega
self?.dimNodeTapped() self?.dimNodeTapped()
return true return true
} }
if controller.disableScreenshots {
setLayerDisableScreenshots(self.layer, true)
}
} }
deinit { deinit {
@ -2426,6 +2431,7 @@ public final class ContextController: ViewController, StandalonePresentableContr
public var useComplexItemsTransitionAnimation = false public var useComplexItemsTransitionAnimation = false
public var immediateItemsTransitionAnimation = false public var immediateItemsTransitionAnimation = false
let workaroundUseLegacyImplementation: Bool let workaroundUseLegacyImplementation: Bool
let disableScreenshots: Bool
public enum HandledTouchEvent { public enum HandledTouchEvent {
case ignore case ignore
@ -2441,7 +2447,7 @@ public final class ContextController: ViewController, StandalonePresentableContr
public var getOverlayViews: (() -> [UIView])? public var getOverlayViews: (() -> [UIView])?
convenience public init(presentationData: PresentationData, source: ContextContentSource, items: Signal<ContextController.Items, NoError>, recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, gesture: ContextGesture? = nil, workaroundUseLegacyImplementation: Bool = false) { convenience public init(presentationData: PresentationData, source: ContextContentSource, items: Signal<ContextController.Items, NoError>, recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, gesture: ContextGesture? = nil, workaroundUseLegacyImplementation: Bool = false, disableScreenshots: Bool = false) {
self.init( self.init(
presentationData: presentationData, presentationData: presentationData,
configuration: ContextController.Configuration( configuration: ContextController.Configuration(
@ -2455,7 +2461,8 @@ public final class ContextController: ViewController, StandalonePresentableContr
), ),
recognizer: recognizer, recognizer: recognizer,
gesture: gesture, gesture: gesture,
workaroundUseLegacyImplementation: workaroundUseLegacyImplementation workaroundUseLegacyImplementation: workaroundUseLegacyImplementation,
disableScreenshots: disableScreenshots
) )
} }
@ -2464,13 +2471,15 @@ public final class ContextController: ViewController, StandalonePresentableContr
configuration: ContextController.Configuration, configuration: ContextController.Configuration,
recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil, recognizer: TapLongTapOrDoubleTapGestureRecognizer? = nil,
gesture: ContextGesture? = nil, gesture: ContextGesture? = nil,
workaroundUseLegacyImplementation: Bool = false workaroundUseLegacyImplementation: Bool = false,
disableScreenshots: Bool = false
) { ) {
self.presentationData = presentationData self.presentationData = presentationData
self.configuration = configuration self.configuration = configuration
self.recognizer = recognizer self.recognizer = recognizer
self.gesture = gesture self.gesture = gesture
self.workaroundUseLegacyImplementation = workaroundUseLegacyImplementation self.workaroundUseLegacyImplementation = workaroundUseLegacyImplementation
self.disableScreenshots = disableScreenshots
super.init(navigationBarPresentationData: nil) super.init(navigationBarPresentationData: nil)

View File

@ -6,6 +6,7 @@ import TelegramPresentationData
import TextSelectionNode import TextSelectionNode
import TelegramCore import TelegramCore
import SwiftSignalKit import SwiftSignalKit
import UIKitRuntimeUtils
final class PinchSourceGesture: UIPinchGestureRecognizer { final class PinchSourceGesture: UIPinchGestureRecognizer {
private final class Target { private final class Target {
@ -237,6 +238,7 @@ private final class PinchControllerNode: ViewControllerTracingNode {
private let scrollingContainer: ASDisplayNode private let scrollingContainer: ASDisplayNode
private let sourceNode: PinchSourceContainerNode private let sourceNode: PinchSourceContainerNode
private let disableScreenshots: Bool
private let getContentAreaInScreenSpace: () -> CGRect private let getContentAreaInScreenSpace: () -> CGRect
private let dimNode: ASDisplayNode private let dimNode: ASDisplayNode
@ -246,9 +248,10 @@ private final class PinchControllerNode: ViewControllerTracingNode {
private var hapticFeedback: HapticFeedback? private var hapticFeedback: HapticFeedback?
init(controller: PinchController, sourceNode: PinchSourceContainerNode, getContentAreaInScreenSpace: @escaping () -> CGRect) { init(controller: PinchController, sourceNode: PinchSourceContainerNode, disableScreenshots: Bool, getContentAreaInScreenSpace: @escaping () -> CGRect) {
self.controller = controller self.controller = controller
self.sourceNode = sourceNode self.sourceNode = sourceNode
self.disableScreenshots = disableScreenshots
self.getContentAreaInScreenSpace = getContentAreaInScreenSpace self.getContentAreaInScreenSpace = getContentAreaInScreenSpace
self.dimNode = ASDisplayNode() self.dimNode = ASDisplayNode()
@ -290,6 +293,10 @@ private final class PinchControllerNode: ViewControllerTracingNode {
strongSelf.sourceNode.contentNode.transform = transform strongSelf.sourceNode.contentNode.transform = transform
} }
if self.disableScreenshots {
setLayerDisableScreenshots(self.layer, true)
}
} }
deinit { deinit {
@ -407,6 +414,7 @@ public final class PinchController: ViewController, StandalonePresentableControl
} }
private let sourceNode: PinchSourceContainerNode private let sourceNode: PinchSourceContainerNode
private let disableScreenshots: Bool
private let getContentAreaInScreenSpace: () -> CGRect private let getContentAreaInScreenSpace: () -> CGRect
private var wasDismissed = false private var wasDismissed = false
@ -415,8 +423,9 @@ public final class PinchController: ViewController, StandalonePresentableControl
return self.displayNode as! PinchControllerNode return self.displayNode as! PinchControllerNode
} }
public init(sourceNode: PinchSourceContainerNode, getContentAreaInScreenSpace: @escaping () -> CGRect) { public init(sourceNode: PinchSourceContainerNode, disableScreenshots: Bool = false, getContentAreaInScreenSpace: @escaping () -> CGRect) {
self.sourceNode = sourceNode self.sourceNode = sourceNode
self.disableScreenshots = disableScreenshots
self.getContentAreaInScreenSpace = getContentAreaInScreenSpace self.getContentAreaInScreenSpace = getContentAreaInScreenSpace
super.init(navigationBarPresentationData: nil) super.init(navigationBarPresentationData: nil)
@ -435,7 +444,7 @@ public final class PinchController: ViewController, StandalonePresentableControl
} }
override public func loadDisplayNode() { override public func loadDisplayNode() {
self.displayNode = PinchControllerNode(controller: self, sourceNode: self.sourceNode, getContentAreaInScreenSpace: self.getContentAreaInScreenSpace) self.displayNode = PinchControllerNode(controller: self, sourceNode: self.sourceNode, disableScreenshots: self.disableScreenshots, getContentAreaInScreenSpace: self.getContentAreaInScreenSpace)
self.displayNodeDidLoad() self.displayNodeDidLoad()

View File

@ -294,7 +294,8 @@ extension ChatControllerImpl {
self.canReadHistory.set(false) self.canReadHistory.set(false)
let controller = ContextController(presentationData: self.presentationData, source: source, items: actionsSignal, recognizer: recognizer, gesture: gesture) let isSecret = self.presentationInterfaceState.copyProtectionEnabled || self.chatLocation.peerId?.namespace == Namespaces.Peer.SecretChat
let controller = ContextController(presentationData: self.presentationData, source: source, items: actionsSignal, recognizer: recognizer, gesture: gesture, disableScreenshots: isSecret)
controller.dismissed = { [weak self] in controller.dismissed = { [weak self] in
self?.canReadHistory.set(true) self?.canReadHistory.set(true)
} }

View File

@ -1588,7 +1588,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
} }
let pinchController = PinchController(sourceNode: sourceNode, getContentAreaInScreenSpace: { let isSecret = strongSelf.presentationInterfaceState.copyProtectionEnabled || strongSelf.chatLocation.peerId?.namespace == Namespaces.Peer.SecretChat
let pinchController = PinchController(sourceNode: sourceNode, disableScreenshots: isSecret, getContentAreaInScreenSpace: {
guard let strongSelf = self else { guard let strongSelf = self else {
return CGRect() return CGRect()
} }