mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
no message
This commit is contained in:
@@ -3,7 +3,12 @@ import Display
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
|
||||
public func navigateToChatController(navigationController: NavigationController, chatController: ChatController? = nil, account: Account, chatLocation: ChatLocation, messageId: MessageId? = nil, botStart: ChatControllerInitialBotStart? = nil, animated: Bool = true) {
|
||||
public enum NavigateToChatKeepStack {
|
||||
case `default`
|
||||
case always
|
||||
}
|
||||
|
||||
public func navigateToChatController(navigationController: NavigationController, chatController: ChatController? = nil, account: Account, chatLocation: ChatLocation, messageId: MessageId? = nil, botStart: ChatControllerInitialBotStart? = nil, keepStack: NavigateToChatKeepStack = .default, animated: Bool = true) {
|
||||
var found = false
|
||||
var isFirst = true
|
||||
for controller in navigationController.viewControllers.reversed() {
|
||||
@@ -30,7 +35,14 @@ public func navigateToChatController(navigationController: NavigationController,
|
||||
} else {
|
||||
controller = ChatController(account: account, chatLocation: chatLocation, messageId: messageId, botStart: botStart)
|
||||
}
|
||||
if account.telegramApplicationContext.immediateExperimentalUISettings.keepChatNavigationStack {
|
||||
let resolvedKeepStack: Bool
|
||||
switch keepStack {
|
||||
case .default:
|
||||
resolvedKeepStack = account.telegramApplicationContext.immediateExperimentalUISettings.keepChatNavigationStack
|
||||
case .always:
|
||||
resolvedKeepStack = true
|
||||
}
|
||||
if resolvedKeepStack {
|
||||
navigationController.pushViewController(controller)
|
||||
} else {
|
||||
navigationController.replaceAllButRootController(controller, animated: animated)
|
||||
@@ -38,6 +50,31 @@ public func navigateToChatController(navigationController: NavigationController,
|
||||
}
|
||||
}
|
||||
|
||||
private func findOpaqueLayer(rootLayer: CALayer, layer: CALayer) -> Bool {
|
||||
if layer.isHidden || layer.opacity < 0.8 {
|
||||
return false
|
||||
}
|
||||
|
||||
if !layer.isHidden, let backgroundColor = layer.backgroundColor, backgroundColor.alpha > 0.8 {
|
||||
let coveringRect = layer.convert(layer.bounds, to: rootLayer)
|
||||
let intersection = coveringRect.intersection(rootLayer.bounds)
|
||||
let intersectionArea = intersection.width * intersection.height
|
||||
let rootArea = rootLayer.bounds.width * rootLayer.bounds.height
|
||||
if !rootArea.isZero && intersectionArea / rootArea > 0.8 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if let sublayers = layer.sublayers {
|
||||
for sublayer in sublayers {
|
||||
if findOpaqueLayer(rootLayer: rootLayer, layer: sublayer) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public func isOverlayControllerForChatNotificationOverlayPresentation(_ controller: ViewController) -> Bool {
|
||||
if controller is GalleryController || controller is AvatarGalleryController || controller is ThemeGalleryController || controller is InstantPageGalleryController {
|
||||
return true
|
||||
@@ -47,6 +84,10 @@ public func isOverlayControllerForChatNotificationOverlayPresentation(_ controll
|
||||
if let backgroundColor = controller.displayNode.backgroundColor, !backgroundColor.isEqual(UIColor.clear) {
|
||||
return true
|
||||
}
|
||||
|
||||
if findOpaqueLayer(rootLayer: controller.view.layer, layer: controller.view.layer) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user