Add layer screenshort protection

This commit is contained in:
Isaac
2023-11-23 16:00:15 +04:00
parent c3df326987
commit 5dd156f2fc
7 changed files with 87 additions and 173 deletions

View File

@@ -38,6 +38,7 @@ import ManagedDiceAnimationNode
import ChatMessageTransitionNode
import ChatLoadingNode
import ChatRecentActionsController
import UIKitRuntimeUtils
final class VideoNavigationControllerDropContentItem: NavigationControllerDropContentItem {
let itemNode: OverlayMediaItemNode
@@ -82,13 +83,10 @@ private struct ChatControllerNodeDerivedLayoutState {
}
class HistoryNodeContainer: ASDisplayNode {
private(set) var secretContainer: UIView?
public var isSecret: Bool = false {
var isSecret: Bool {
didSet {
if self.isSecret != oldValue {
if self.isNodeLoaded {
(self.view as? UITextField)?.isSecureTextEntry = self.isSecret
}
setLayerDisableScreenshots(self.layer, self.isSecret)
}
}
}
@@ -98,35 +96,9 @@ class HistoryNodeContainer: ASDisplayNode {
super.init()
self.setViewBlock {
let captureProtectedView = UITextField(frame: CGRect())
captureProtectedView.isSecureTextEntry = self.isSecret
self.secretContainer = captureProtectedView.subviews.first
return captureProtectedView
if self.isSecret {
setLayerDisableScreenshots(self.layer, self.isSecret)
}
let _ = self.view
}
override func addSubnode(_ subnode: ASDisplayNode) {
if let secretContainer = self.secretContainer {
secretContainer.addSubnode(subnode)
} else {
super.addSubnode(subnode)
}
}
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let secretContainer = self.secretContainer {
return secretContainer.hitTest(point, with: event)
} else {
return super.hitTest(point, with: event)
}
}
func updateSize(size: CGSize, transition: ContainedViewLayoutTransition) {
/*if let secretContainer = self.secretContainer {
}*/
}
}
@@ -612,8 +584,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
//self.historyScrollingArea = SparseDiscreteScrollingArea()
//self.historyNode.historyScrollingArea = self.historyScrollingArea
//self.historyNodeContainer = HistoryNodeContainer(isSecret: chatLocation.peerId?.namespace == Namespaces.Peer.SecretChat)
self.historyNodeContainer = ASDisplayNode()
self.historyNodeContainer = HistoryNodeContainer(isSecret: chatLocation.peerId?.namespace == Namespaces.Peer.SecretChat)
self.historyNodeContainer.addSubnode(self.historyNode)
@@ -1671,10 +1642,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
transition.updateBounds(node: self.historyNodeContainer, bounds: contentBounds)
transition.updatePosition(node: self.historyNodeContainer, position: contentBounds.center)
if let historyNodeContainer = self.historyNodeContainer as? HistoryNodeContainer {
historyNodeContainer.updateSize(size: contentBounds.size, transition: transition)
}
transition.updateBounds(node: self.historyNode, bounds: CGRect(origin: CGPoint(), size: contentBounds.size))
transition.updatePosition(node: self.historyNode, position: CGPoint(x: contentBounds.size.width / 2.0, y: contentBounds.size.height / 2.0))
if let blurredHistoryNode = self.blurredHistoryNode {