mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
a4214ad972
commit
e789170a1a
@ -5876,4 +5876,8 @@ Any member of this group will be able to see messages in the channel.";
|
||||
|
||||
"Location.LiveLocationRequired.Title" = "Share Location";
|
||||
"Location.LiveLocationRequired.Description" = "For the alert to work, please share your live location in this chat.";
|
||||
"Location.LiveLocationRequired.ShareLocation" = "Share Location";
|
||||
"Location.LiveLocationRequired.ShareLocation" = "Share Location";
|
||||
|
||||
"Stats.Message.Views" = "Views";
|
||||
"Stats.Message.PublicShares" = "Public Shares";
|
||||
"Stats.Message.PrivateShares" = "Private Shares";
|
||||
|
@ -95,7 +95,7 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
}
|
||||
}
|
||||
|
||||
public class ChatListControllerImpl: TelegramBaseController, ChatListController, UIViewControllerPreviewingDelegate {
|
||||
public class ChatListControllerImpl: TelegramBaseController, ChatListController {
|
||||
private var validLayout: ContainerViewLayout?
|
||||
|
||||
public let context: AccountContext
|
||||
@ -1780,111 +1780,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
|
||||
(self.navigationController as? NavigationController)?.pushViewController(controller)
|
||||
}
|
||||
|
||||
public func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
|
||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||
if let (controller, rect) = self.previewingController(from: previewingContext.sourceView, for: location) {
|
||||
previewingContext.sourceRect = rect
|
||||
return controller
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func previewingController(from sourceView: UIView, for location: CGPoint) -> (UIViewController, CGRect)? {
|
||||
guard let layout = self.validLayout, case .phone = layout.deviceMetrics.type else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let boundsSize = self.view.bounds.size
|
||||
let contentSize: CGSize
|
||||
if case .unknown = layout.deviceMetrics {
|
||||
contentSize = boundsSize
|
||||
} else {
|
||||
contentSize = layout.deviceMetrics.previewingContentSize(inLandscape: boundsSize.width > boundsSize.height)
|
||||
}
|
||||
|
||||
if let searchController = self.chatListDisplayNode.searchDisplayController {
|
||||
if let (view, bounds, action) = searchController.previewViewAndActionAtLocation(location) {
|
||||
if let peerId = action as? PeerId, peerId.namespace != Namespaces.Peer.SecretChat {
|
||||
var sourceRect = view.superview!.convert(view.frame, to: sourceView)
|
||||
sourceRect = CGRect(x: sourceRect.minX, y: sourceRect.minY + bounds.minY, width: bounds.width, height: bounds.height)
|
||||
sourceRect.size.height -= UIScreenPixel
|
||||
|
||||
let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .peer(peerId), subject: nil, botStart: nil, mode: .standard(previewing: true))
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: contentSize, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (chatController, sourceRect)
|
||||
} else if let messageId = action as? MessageId, messageId.peerId.namespace != Namespaces.Peer.SecretChat {
|
||||
var sourceRect = view.superview!.convert(view.frame, to: sourceView)
|
||||
sourceRect = CGRect(x: sourceRect.minX, y: sourceRect.minY + bounds.minY, width: bounds.width, height: bounds.height)
|
||||
sourceRect.size.height -= UIScreenPixel
|
||||
|
||||
let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .peer(messageId.peerId), subject: .message(id: messageId, highlight: true), botStart: nil, mode: .standard(previewing: true))
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: contentSize, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (chatController, sourceRect)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
let listLocation = self.view.convert(location, to: self.chatListDisplayNode.containerNode.currentItemNode.view)
|
||||
|
||||
var selectedNode: ChatListItemNode?
|
||||
self.chatListDisplayNode.containerNode.currentItemNode.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ChatListItemNode, itemNode.frame.contains(listLocation), !itemNode.isDisplayingRevealedOptions {
|
||||
selectedNode = itemNode
|
||||
}
|
||||
}
|
||||
if let selectedNode = selectedNode, let item = selectedNode.item {
|
||||
var sourceRect = selectedNode.view.superview!.convert(selectedNode.frame, to: sourceView)
|
||||
sourceRect.size.height -= UIScreenPixel
|
||||
switch item.content {
|
||||
case let .peer(_, peer, _, _, _, _, _, _, _, _, _, _):
|
||||
if peer.peerId.namespace != Namespaces.Peer.SecretChat {
|
||||
let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .peer(peer.peerId), subject: nil, botStart: nil, mode: .standard(previewing: true))
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: contentSize, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (chatController, sourceRect)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .groupReference(groupId, _, _, _, _):
|
||||
let chatListController = ChatListControllerImpl(context: self.context, groupId: groupId, controlsHistoryPreload: false, enableDebugActions: false)
|
||||
chatListController.navigationPresentation = .master
|
||||
chatListController.containerLayoutUpdated(ContainerViewLayout(size: contentSize, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (chatListController, sourceRect)
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
|
||||
self.previewingCommit(viewControllerToCommit)
|
||||
}
|
||||
|
||||
func previewingCommit(_ viewControllerToCommit: UIViewController) {
|
||||
if let viewControllerToCommit = viewControllerToCommit as? ViewController {
|
||||
if let chatController = viewControllerToCommit as? ChatController {
|
||||
chatController.canReadHistory.set(true)
|
||||
chatController.updatePresentationMode(.standard(previewing: false))
|
||||
if let navigationController = self.navigationController as? NavigationController {
|
||||
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, chatController: chatController, context: self.context, chatLocation: chatController.chatLocation, animated: false))
|
||||
self.chatListDisplayNode.containerNode.currentItemNode.clearHighlightAnimated(true)
|
||||
}
|
||||
} else if let chatListController = viewControllerToCommit as? ChatListController {
|
||||
if let navigationController = self.navigationController as? NavigationController {
|
||||
navigationController.pushViewController(chatListController, animated: false, completion: {})
|
||||
self.chatListDisplayNode.containerNode.currentItemNode.clearHighlightAnimated(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override var keyShortcuts: [KeyShortcut] {
|
||||
let strings = self.presentationData.strings
|
||||
|
||||
|
@ -14,18 +14,6 @@ import SearchBarNode
|
||||
import SearchUI
|
||||
import ContextUI
|
||||
|
||||
private final class ChatListControllerNodeView: UITracingLayerView, PreviewingHostView {
|
||||
var previewingDelegate: PreviewingHostViewDelegate? {
|
||||
return PreviewingHostViewDelegate(controllerForLocation: { [weak self] sourceView, point in
|
||||
return self?.controller?.previewingController(from: sourceView, for: point)
|
||||
}, commitController: { [weak self] controller in
|
||||
self?.controller?.previewingCommit(controller)
|
||||
})
|
||||
}
|
||||
|
||||
weak var controller: ChatListControllerImpl?
|
||||
}
|
||||
|
||||
enum ChatListContainerNodeFilter: Equatable {
|
||||
case all
|
||||
case filter(ChatListFilter)
|
||||
@ -1027,7 +1015,7 @@ final class ChatListControllerNode: ASDisplayNode {
|
||||
super.init()
|
||||
|
||||
self.setViewBlock({
|
||||
return ChatListControllerNodeView()
|
||||
return UITracingLayerView()
|
||||
})
|
||||
|
||||
self.backgroundColor = presentationData.theme.chatList.backgroundColor
|
||||
@ -1056,8 +1044,6 @@ final class ChatListControllerNode: ASDisplayNode {
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
(self.view as? ChatListControllerNodeView)?.controller = self.controller
|
||||
|
||||
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
|
||||
self.tapRecognizer = tapRecognizer
|
||||
self.view.addGestureRecognizer(tapRecognizer)
|
||||
|
@ -396,80 +396,6 @@ public class ContactsController: ViewController {
|
||||
self.contactsNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationInsetHeight, actualNavigationBarHeight: self.navigationHeight, transition: transition)
|
||||
}
|
||||
|
||||
func previewingController(from sourceView: UIView, for location: CGPoint) -> (UIViewController, CGRect)? {
|
||||
guard let layout = self.validLayout, case .phone = layout.deviceMetrics.type else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let boundsSize = self.view.bounds.size
|
||||
let contentSize: CGSize
|
||||
if case .unknown = layout.deviceMetrics {
|
||||
contentSize = boundsSize
|
||||
} else {
|
||||
contentSize = layout.deviceMetrics.previewingContentSize(inLandscape: boundsSize.width > boundsSize.height)
|
||||
}
|
||||
|
||||
var selectedNode: ContactsPeerItemNode?
|
||||
|
||||
if let searchController = self.contactsNode.searchDisplayController {
|
||||
guard let contentNode = searchController.contentNode as? ContactsSearchContainerNode else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let listLocation = self.view.convert(location, to: contentNode.listNode.view)
|
||||
|
||||
contentNode.listNode.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ContactsPeerItemNode, itemNode.frame.contains(listLocation), !itemNode.isDisplayingRevealedOptions {
|
||||
selectedNode = itemNode
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let listLocation = self.view.convert(location, to: self.contactsNode.contactListNode.listNode.view)
|
||||
|
||||
self.contactsNode.contactListNode.listNode.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ContactsPeerItemNode, itemNode.frame.contains(listLocation), !itemNode.isDisplayingRevealedOptions {
|
||||
selectedNode = itemNode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let selectedNode = selectedNode, let peer = selectedNode.item?.peer {
|
||||
var sourceRect = selectedNode.view.superview!.convert(selectedNode.frame, to: sourceView)
|
||||
sourceRect.size.height -= UIScreenPixel
|
||||
switch peer {
|
||||
case let .peer(peer, _):
|
||||
guard let peer = peer else {
|
||||
return nil
|
||||
}
|
||||
if peer.id.namespace != Namespaces.Peer.SecretChat {
|
||||
let chatController = self.context.sharedContext.makeChatController(context: self.context, chatLocation: .peer(peer.id), subject: nil, botStart: nil, mode: .standard(previewing: true))
|
||||
chatController.canReadHistory.set(false)
|
||||
chatController.containerLayoutUpdated(ContainerViewLayout(size: contentSize, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (chatController, sourceRect)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case .deviceContact:
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func previewingCommit(_ viewControllerToCommit: UIViewController) {
|
||||
if let viewControllerToCommit = viewControllerToCommit as? ViewController {
|
||||
if let chatController = viewControllerToCommit as? ChatController {
|
||||
chatController.canReadHistory.set(true)
|
||||
chatController.updatePresentationMode(.standard(previewing: false))
|
||||
if let navigationController = self.navigationController as? NavigationController {
|
||||
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, chatController: chatController, context: self.context, chatLocation: chatController.chatLocation, animated: false))
|
||||
self.contactsNode.contactListNode.listNode.clearHighlightAnimated(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func activateSearch() {
|
||||
if self.displayNavigationBar {
|
||||
if let searchContentNode = self.searchContentNode {
|
||||
|
@ -15,18 +15,6 @@ import SearchUI
|
||||
import AppBundle
|
||||
import ContextUI
|
||||
|
||||
private final class ContactsControllerNodeView: UITracingLayerView, PreviewingHostView {
|
||||
var previewingDelegate: PreviewingHostViewDelegate? {
|
||||
return PreviewingHostViewDelegate(controllerForLocation: { [weak self] sourceView, point in
|
||||
return self?.controller?.previewingController(from: sourceView, for: point)
|
||||
}, commitController: { [weak self] controller in
|
||||
self?.controller?.previewingCommit(controller)
|
||||
})
|
||||
}
|
||||
|
||||
weak var controller: ContactsController?
|
||||
}
|
||||
|
||||
private final class ContextControllerContentSourceImpl: ContextControllerContentSource {
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
@ -108,7 +96,7 @@ final class ContactsControllerNode: ASDisplayNode {
|
||||
super.init()
|
||||
|
||||
self.setViewBlock({
|
||||
return ContactsControllerNodeView()
|
||||
return UITracingLayerView()
|
||||
})
|
||||
|
||||
self.backgroundColor = self.presentationData.theme.chatList.backgroundColor
|
||||
@ -150,12 +138,6 @@ final class ContactsControllerNode: ASDisplayNode {
|
||||
self.presentationDataDisposable?.dispose()
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
(self.view as? ContactsControllerNodeView)?.controller = self.controller
|
||||
}
|
||||
|
||||
private func updateThemeAndStrings() {
|
||||
self.backgroundColor = self.presentationData.theme.chatList.backgroundColor
|
||||
self.searchDisplayController?.updatePresentationData(self.presentationData)
|
||||
|
@ -12,6 +12,9 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
case iPhone6Plus
|
||||
case iPhoneX
|
||||
case iPhoneXSMax
|
||||
case iPhone12Mini
|
||||
case iPhone12
|
||||
case iPhone12ProMax
|
||||
case iPad
|
||||
case iPadPro10Inch
|
||||
case iPadPro11Inch
|
||||
@ -27,6 +30,9 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
.iPhone6Plus,
|
||||
.iPhoneX,
|
||||
.iPhoneXSMax,
|
||||
.iPhone12Mini,
|
||||
.iPhone12,
|
||||
.iPhone12ProMax,
|
||||
.iPad,
|
||||
.iPadPro10Inch,
|
||||
.iPadPro11Inch,
|
||||
@ -89,6 +95,12 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
return CGSize(width: 375.0, height: 812.0)
|
||||
case .iPhoneXSMax:
|
||||
return CGSize(width: 414.0, height: 896.0)
|
||||
case .iPhone12Mini:
|
||||
return CGSize(width: 360.0, height: 780.0)
|
||||
case .iPhone12:
|
||||
return CGSize(width: 390.0, height: 844.0)
|
||||
case .iPhone12ProMax:
|
||||
return CGSize(width: 428.0, height: 926.0)
|
||||
case .iPad:
|
||||
return CGSize(width: 768.0, height: 1024.0)
|
||||
case .iPadPro10Inch:
|
||||
@ -104,7 +116,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
|
||||
func safeInsets(inLandscape: Bool) -> UIEdgeInsets {
|
||||
switch self {
|
||||
case .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return inLandscape ? UIEdgeInsets(top: 0.0, left: 44.0, bottom: 0.0, right: 44.0) : UIEdgeInsets(top: 44.0, left: 0.0, bottom: 0.0, right: 0.0)
|
||||
default:
|
||||
return UIEdgeInsets.zero
|
||||
@ -113,7 +125,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
|
||||
func onScreenNavigationHeight(inLandscape: Bool, systemOnScreenNavigationHeight: CGFloat?) -> CGFloat? {
|
||||
switch self {
|
||||
case .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return inLandscape ? 21.0 : 34.0
|
||||
case .iPadPro3rdGen, .iPadPro11Inch:
|
||||
return 21.0
|
||||
@ -146,7 +158,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
|
||||
var statusBarHeight: CGFloat {
|
||||
switch self {
|
||||
case .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return 44.0
|
||||
case .iPadPro11Inch, .iPadPro3rdGen:
|
||||
return 24.0
|
||||
@ -164,7 +176,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
return 162.0
|
||||
case .iPhone6, .iPhone6Plus:
|
||||
return 163.0
|
||||
case .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return 172.0
|
||||
case .iPad, .iPadPro10Inch:
|
||||
return 348.0
|
||||
@ -183,9 +195,9 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
return 216.0
|
||||
case .iPhone6Plus:
|
||||
return 226.0
|
||||
case .iPhoneX:
|
||||
case .iPhoneX, .iPhone12Mini, .iPhone12:
|
||||
return 291.0
|
||||
case .iPhoneXSMax:
|
||||
case .iPhoneXSMax, .iPhone12ProMax:
|
||||
return 302.0
|
||||
case .iPad, .iPadPro10Inch:
|
||||
return 263.0
|
||||
@ -204,7 +216,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
func predictiveInputHeight(inLandscape: Bool) -> CGFloat {
|
||||
if inLandscape {
|
||||
switch self {
|
||||
case .iPhone4, .iPhone5, .iPhone6, .iPhone6Plus, .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhone4, .iPhone5, .iPhone6, .iPhone6Plus, .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return 37.0
|
||||
case .iPad, .iPadPro10Inch, .iPadPro11Inch, .iPadPro, .iPadPro3rdGen:
|
||||
return 50.0
|
||||
@ -215,7 +227,7 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
switch self {
|
||||
case .iPhone4, .iPhone5:
|
||||
return 37.0
|
||||
case .iPhone6, .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhone6, .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return 44.0
|
||||
case .iPhone6Plus:
|
||||
return 45.0
|
||||
@ -227,44 +239,9 @@ public enum DeviceMetrics: CaseIterable, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
public func previewingContentSize(inLandscape: Bool) -> CGSize {
|
||||
let screenSize = self.screenSize
|
||||
if inLandscape {
|
||||
switch self {
|
||||
case .iPhone5:
|
||||
return CGSize(width: screenSize.height, height: screenSize.width - 10.0)
|
||||
case .iPhone6:
|
||||
return CGSize(width: screenSize.height, height: screenSize.width - 22.0)
|
||||
case .iPhone6Plus:
|
||||
return CGSize(width: screenSize.height, height: screenSize.width - 22.0)
|
||||
case .iPhoneX:
|
||||
return CGSize(width: screenSize.height, height: screenSize.width + 48.0)
|
||||
case .iPhoneXSMax:
|
||||
return CGSize(width: screenSize.height, height: screenSize.width - 30.0)
|
||||
default:
|
||||
return CGSize(width: screenSize.height, height: screenSize.width - 10.0)
|
||||
}
|
||||
} else {
|
||||
switch self {
|
||||
case .iPhone5:
|
||||
return CGSize(width: screenSize.width, height: screenSize.height - 50.0)
|
||||
case .iPhone6:
|
||||
return CGSize(width: screenSize.width, height: screenSize.height - 97.0)
|
||||
case .iPhone6Plus:
|
||||
return CGSize(width: screenSize.width, height: screenSize.height - 95.0)
|
||||
case .iPhoneX:
|
||||
return CGSize(width: screenSize.width, height: screenSize.height - 154.0)
|
||||
case .iPhoneXSMax:
|
||||
return CGSize(width: screenSize.width, height: screenSize.height - 84.0)
|
||||
default:
|
||||
return CGSize(width: screenSize.width, height: screenSize.height - 50.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var hasTopNotch: Bool {
|
||||
switch self {
|
||||
case .iPhoneX, .iPhoneXSMax:
|
||||
case .iPhoneX, .iPhoneXSMax, .iPhone12Mini, .iPhone12, .iPhone12ProMax:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
@ -224,9 +224,6 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
}
|
||||
}
|
||||
|
||||
public var previewItemWithTag: ((ItemListItemTag) -> UIViewController?)?
|
||||
public var commitPreview: ((UIViewController) -> Void)?
|
||||
|
||||
public var willDisappear: ((Bool) -> Void)?
|
||||
public var didDisappear: ((Bool) -> Void)?
|
||||
|
||||
@ -558,51 +555,10 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
|
||||
(self.displayNode as! ItemListControllerNode).afterLayout(f)
|
||||
}
|
||||
|
||||
public func previewingController(from sourceView: UIView, for location: CGPoint) -> (UIViewController, CGRect)? {
|
||||
guard let layout = self.validLayout, case .phone = layout.deviceMetrics.type else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let boundsSize = self.view.bounds.size
|
||||
let contentSize: CGSize
|
||||
if case .unknown = layout.deviceMetrics {
|
||||
contentSize = boundsSize
|
||||
} else {
|
||||
contentSize = layout.deviceMetrics.previewingContentSize(inLandscape: boundsSize.width > boundsSize.height)
|
||||
}
|
||||
|
||||
var selectedNode: ItemListItemNode?
|
||||
let listLocation = self.view.convert(location, to: (self.displayNode as! ItemListControllerNode).listNode.view)
|
||||
(self.displayNode as! ItemListControllerNode).listNode.forEachItemNode { itemNode in
|
||||
if itemNode.frame.contains(listLocation), let itemNode = itemNode as? ItemListItemNode {
|
||||
selectedNode = itemNode
|
||||
}
|
||||
}
|
||||
if let selectedNode = selectedNode as? (ItemListItemNode & ListViewItemNode), let tag = selectedNode.tag {
|
||||
var sourceRect = selectedNode.view.superview!.convert(selectedNode.frame, to: sourceView)
|
||||
sourceRect.size.height -= UIScreenPixel
|
||||
|
||||
if let controller = self.previewItemWithTag?(tag) {
|
||||
if let controller = controller as? ContainableController {
|
||||
controller.containerLayoutUpdated(ContainerViewLayout(size: contentSize, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
}
|
||||
return (controller, sourceRect)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
public func clearItemNodesHighlight(animated: Bool = false) {
|
||||
(self.displayNode as! ItemListControllerNode).listNode.clearHighlightAnimated(animated)
|
||||
}
|
||||
|
||||
public func previewingCommit(_ viewControllerToCommit: UIViewController) {
|
||||
self.commitPreview?(viewControllerToCommit)
|
||||
}
|
||||
|
||||
public var keyShortcuts: [KeyShortcut] {
|
||||
return [KeyShortcut(input: UIKeyCommand.inputEscape, action: { [weak self] in
|
||||
if !(self?.navigationController?.topViewController is TabBarController) {
|
||||
|
@ -138,7 +138,7 @@ public final class ItemListNodeVisibleEntries: Sequence {
|
||||
}
|
||||
}
|
||||
|
||||
public final class ItemListControllerNodeView: UITracingLayerView, PreviewingHostView {
|
||||
public final class ItemListControllerNodeView: UITracingLayerView {
|
||||
var onLayout: (() -> Void)?
|
||||
|
||||
init(controller: ItemListController?) {
|
||||
@ -171,14 +171,6 @@ public final class ItemListControllerNodeView: UITracingLayerView, PreviewingHos
|
||||
}
|
||||
}
|
||||
|
||||
public var previewingDelegate: PreviewingHostViewDelegate? {
|
||||
return PreviewingHostViewDelegate(controllerForLocation: { [weak self] sourceView, point in
|
||||
return self?.controller?.previewingController(from: sourceView, for: point)
|
||||
}, commitController: { [weak self] controller in
|
||||
self?.controller?.previewingCommit(controller)
|
||||
})
|
||||
}
|
||||
|
||||
weak var controller: ItemListController?
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||
}
|
||||
|
||||
if let distance = self.distances.first, Double(value) > distance {
|
||||
if let distance = self.distances.last, Double(value) > distance {
|
||||
self.doneButton.alpha = 0.0
|
||||
self.doneButton.isUserInteractionEnabled = false
|
||||
self.textNode.alpha = 1.0
|
||||
|
@ -548,7 +548,7 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
||||
subscriber.putCompletion()
|
||||
return EmptyDisposable
|
||||
}
|
||||
let annotationsPoll = (poll |> then(.complete() |> delay(3.0, queue: Queue.concurrentDefaultQueue()))) |> restart
|
||||
let annotationsPoll = (poll |> then(.complete() |> delay(1.0, queue: Queue.concurrentDefaultQueue()))) |> restart
|
||||
|
||||
return combineLatest(self.userLocation, annotationsPoll)
|
||||
|> map { userLocation, annotations -> [Double] in
|
||||
|
@ -884,6 +884,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
||||
let optionsFrame = CGRect(x: 0.0, y: optionsOffset, width: layout.size.width, height: optionsHeight)
|
||||
transition.updateFrame(node: self.optionsNode, frame: optionsFrame)
|
||||
self.optionsNode.updateLayout(size: optionsFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition)
|
||||
self.optionsNode.isUserInteractionEnabled = self.state.displayingMapModeOptions
|
||||
|
||||
if let searchContainerNode = self.searchContainerNode {
|
||||
searchContainerNode.frame = CGRect(origin: CGPoint(), size: layout.size)
|
||||
|
@ -364,7 +364,10 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
timeout = nil
|
||||
}
|
||||
|
||||
entries.append(.toggleLiveLocation(presentationData.theme, title, subtitle, userLocation?.coordinate, beginTime, timeout))
|
||||
if let channel = subject.author as? TelegramChannel, case .broadcast = channel.info {
|
||||
} else {
|
||||
entries.append(.toggleLiveLocation(presentationData.theme, title, subtitle, userLocation?.coordinate, beginTime, timeout))
|
||||
}
|
||||
|
||||
var sortedLiveLocations: [Message] = []
|
||||
|
||||
@ -690,5 +693,6 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
let optionsFrame = CGRect(x: 0.0, y: optionsOffset, width: layout.size.width, height: optionsHeight)
|
||||
transition.updateFrame(node: self.optionsNode, frame: optionsFrame)
|
||||
self.optionsNode.updateLayout(size: optionsFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition)
|
||||
self.optionsNode.isUserInteractionEnabled = self.state.displayingMapModeOptions
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ struct PasscodeKeyboardLayout {
|
||||
self.topOffset = 226.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPhoneX:
|
||||
case .iPhoneX, .iPhone12Mini, .iPhone12:
|
||||
self.buttonSize = 75.0
|
||||
self.horizontalSecond = 103.0
|
||||
self.horizontalThird = 206.0
|
||||
@ -78,7 +78,7 @@ struct PasscodeKeyboardLayout {
|
||||
self.topOffset = 294.0
|
||||
self.biometricsOffset = 30.0
|
||||
self.deleteOffset = 20.0
|
||||
case .iPhoneXSMax:
|
||||
case .iPhoneXSMax, .iPhone12ProMax:
|
||||
self.buttonSize = 85.0
|
||||
self.horizontalSecond = 115.0
|
||||
self.horizontalThird = 230.0
|
||||
@ -151,11 +151,11 @@ public struct PasscodeLayout {
|
||||
self.titleOffset = 112.0
|
||||
self.subtitleOffset = -6.0
|
||||
self.inputFieldOffset = 156.0
|
||||
case .iPhoneX:
|
||||
case .iPhoneX, .iPhone12Mini, .iPhone12:
|
||||
self.titleOffset = 162.0
|
||||
self.subtitleOffset = 0.0
|
||||
self.inputFieldOffset = 206.0
|
||||
case .iPhoneXSMax:
|
||||
case .iPhoneXSMax, .iPhone12ProMax:
|
||||
self.titleOffset = 180.0
|
||||
self.subtitleOffset = 0.0
|
||||
self.inputFieldOffset = 226.0
|
||||
|
@ -1924,42 +1924,6 @@ public func settingsController(context: AccountContext, accountManager: AccountM
|
||||
updateNotifyExceptions()
|
||||
updateActiveSessions()
|
||||
}
|
||||
controller.previewItemWithTag = { tag in
|
||||
if let tag = tag as? SettingsEntryTag, case let .account(id) = tag {
|
||||
var selectedAccount: Account?
|
||||
let _ = (accountsAndPeers.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { accountsAndPeers in
|
||||
for (account, _, _) in accountsAndPeers.1 {
|
||||
if account.id == id {
|
||||
selectedAccount = account
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
var sharedContext: SharedAccountContext?
|
||||
let _ = (contextValue.get()
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)).start(next: { context in
|
||||
sharedContext = context.sharedContext
|
||||
})
|
||||
if let selectedAccount = selectedAccount, let sharedContext = sharedContext {
|
||||
let accountContext = sharedContext.makeTempAccountContext(account: selectedAccount)
|
||||
let chatListController = accountContext.sharedContext.makeChatListController(context: accountContext, groupId: .root, controlsHistoryPreload: false, hideNetworkActivityStatus: true, previewing: true, enableDebugActions: enableDebugActions)
|
||||
return chatListController
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
controller.commitPreview = { previewController in
|
||||
if let chatListController = previewController as? ChatListController {
|
||||
let _ = (contextValue.get()
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)).start(next: { context in
|
||||
context.sharedContext.switchToAccount(id: chatListController.context.account.id, fromSettingsController: nil, withChatListController: chatListController)
|
||||
})
|
||||
}
|
||||
}
|
||||
controller.switchToAccount = { id in
|
||||
let _ = (contextValue.get()
|
||||
|> take(1)
|
||||
|
@ -168,11 +168,11 @@ class MessageStatsOverviewItemNode: ListViewItemNode {
|
||||
|
||||
rightValueLabelLayoutAndApply = makeRightValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.publicShares.flatMap { "≈\( compactNumericCountString(item.stats.forwards - Int($0)))" } ?? "–", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
leftTitleLabelLayoutAndApply = makeLeftTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "Views", font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
leftTitleLabelLayoutAndApply = makeLeftTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Stats_Message_Views, font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
centerTitleLabelLayoutAndApply = makeCenterTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "Public Shares", font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
centerTitleLabelLayoutAndApply = makeCenterTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Stats_Message_PublicShares, font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
rightTitleLabelLayoutAndApply = makeRightTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "Private Shares", font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
rightTitleLabelLayoutAndApply = makeRightTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.presentationData.strings.Stats_Message_PrivateShares, font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
height += rightValueLabelLayoutAndApply!.0.size.height + rightTitleLabelLayoutAndApply!.0.size.height
|
||||
|
||||
@ -257,7 +257,7 @@ class MessageStatsOverviewItemNode: ListViewItemNode {
|
||||
|
||||
let horizontalSpacing = min(60, (params.width - leftInset - rightInset - sideInset * 2.0 - maxLeftWidth - maxCenterWidth - maxRightWidth) / 2.0)
|
||||
|
||||
var x: CGFloat = leftInset + (params.width - maxLeftWidth - maxCenterWidth - maxRightWidth - horizontalSpacing * 2.0) / 2.0
|
||||
var x: CGFloat = leftInset + (params.width - leftInset - rightInset - maxLeftWidth - maxCenterWidth - maxRightWidth - horizontalSpacing * 2.0) / 2.0
|
||||
if let leftValueLabelLayout = leftValueLabelLayoutAndApply?.0, let leftTitleLabelLayout = leftTitleLabelLayoutAndApply?.0 {
|
||||
strongSelf.leftValueLabel.frame = CGRect(origin: CGPoint(x: x, y: topInset), size: leftValueLabelLayout.size)
|
||||
strongSelf.leftTitleLabel.frame = CGRect(origin: CGPoint(x: x, y: strongSelf.leftValueLabel.frame.maxY), size: leftTitleLabelLayout.size)
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -8,25 +8,6 @@ import ContextUI
|
||||
private let normalFont = avatarPlaceholderFont(size: 16.0)
|
||||
private let smallFont = avatarPlaceholderFont(size: 12.0)
|
||||
|
||||
final class ChatAvatarNavigationNodeView: UIView, PreviewingHostView {
|
||||
var previewingDelegate: PreviewingHostViewDelegate? {
|
||||
return PreviewingHostViewDelegate(controllerForLocation: { [weak self] sourceView, point in
|
||||
return self?.chatController?.avatarPreviewingController(from: sourceView)
|
||||
}, commitController: { [weak self] controller in
|
||||
self?.chatController?.previewingCommit(controller)
|
||||
})
|
||||
}
|
||||
|
||||
weak var chatController: ChatControllerImpl?
|
||||
weak var targetNode: ChatAvatarNavigationNode?
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
self.targetNode?.onLayout()
|
||||
}
|
||||
}
|
||||
|
||||
final class ChatAvatarNavigationNode: ASDisplayNode {
|
||||
private let containerNode: ContextControllerSourceNode
|
||||
let avatarNode: AvatarNode
|
||||
@ -40,14 +21,6 @@ final class ChatAvatarNavigationNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
weak var chatController: ChatControllerImpl? {
|
||||
didSet {
|
||||
if self.isNodeLoaded {
|
||||
(self.view as? ChatAvatarNavigationNodeView)?.chatController = self.chatController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tapped: (() -> Void)?
|
||||
|
||||
override init() {
|
||||
@ -56,10 +29,6 @@ final class ChatAvatarNavigationNode: ASDisplayNode {
|
||||
|
||||
super.init()
|
||||
|
||||
self.setViewBlock({
|
||||
return ChatAvatarNavigationNodeView()
|
||||
})
|
||||
|
||||
self.containerNode.addSubnode(self.avatarNode)
|
||||
self.addSubnode(self.containerNode)
|
||||
|
||||
@ -80,11 +49,6 @@ final class ChatAvatarNavigationNode: ASDisplayNode {
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
self.view.isOpaque = false
|
||||
(self.view as? ChatAvatarNavigationNodeView)?.targetNode = self
|
||||
(self.view as? ChatAvatarNavigationNodeView)?.chatController = self.chatController
|
||||
|
||||
/*let tapRecognizer = TapLongTapOrDoubleTapGestureRecognizer(target: self, action: #selector(self.avatarTapGesture(_:)))
|
||||
self.avatarNode.view.addGestureRecognizer(tapRecognizer)*/
|
||||
}
|
||||
|
||||
@objc private func avatarTapGesture(_ recognizer: TapLongTapOrDoubleTapGestureRecognizer) {
|
||||
|
@ -2341,7 +2341,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
switch chatLocation {
|
||||
case .peer, .replyThread:
|
||||
let avatarNode = ChatAvatarNavigationNode()
|
||||
avatarNode.chatController = self
|
||||
avatarNode.contextAction = { [weak self] node, gesture in
|
||||
guard let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer, peer.smallProfileImage != nil else {
|
||||
return
|
||||
|
@ -24,20 +24,10 @@ final class VideoNavigationControllerDropContentItem: NavigationControllerDropCo
|
||||
}
|
||||
}
|
||||
|
||||
private final class ChatControllerNodeView: UITracingLayerView, WindowInputAccessoryHeightProvider, PreviewingHostView {
|
||||
private final class ChatControllerNodeView: UITracingLayerView, WindowInputAccessoryHeightProvider {
|
||||
var inputAccessoryHeight: (() -> CGFloat)?
|
||||
var hitTestImpl: ((CGPoint, UIEvent?) -> UIView?)?
|
||||
|
||||
var previewingDelegate: PreviewingHostViewDelegate? {
|
||||
return PreviewingHostViewDelegate(controllerForLocation: { [weak self] sourceView, point in
|
||||
return self?.controller?.previewingController(from: sourceView, for: point)
|
||||
}, commitController: { [weak self] controller in
|
||||
self?.controller?.previewingCommit(controller)
|
||||
})
|
||||
}
|
||||
|
||||
weak var controller: ChatControllerImpl?
|
||||
|
||||
func getWindowInputAccessoryHeight() -> CGFloat {
|
||||
return self.inputAccessoryHeight?() ?? 0.0
|
||||
}
|
||||
@ -680,8 +670,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
return false
|
||||
}
|
||||
|
||||
(self.view as? ChatControllerNodeView)?.controller = self.controller
|
||||
|
||||
self.displayVideoUnmuteTipDisposable = (combineLatest(queue: Queue.mainQueue(), ApplicationSpecificNotice.getVolumeButtonToUnmute(accountManager: self.context.sharedContext.accountManager), self.historyNode.hasVisiblePlayableItemNodes, self.historyNode.isInteractivelyScrolling)
|
||||
|> mapToSignal { notice, hasVisiblePlayableItemNodes, isInteractivelyScrolling -> Signal<Bool, NoError> in
|
||||
let display = !notice && hasVisiblePlayableItemNodes && !isInteractivelyScrolling
|
||||
|
@ -1142,7 +1142,7 @@ func chatAvailableMessageActionsImpl(postbox: Postbox, accountPeerId: PeerId, me
|
||||
if canDeleteGlobally {
|
||||
optionsMap[id]!.insert(.deleteGlobally)
|
||||
}
|
||||
if user.botInfo != nil && !user.id.isReplies {
|
||||
if user.botInfo != nil && !user.id.isReplies && !isAction {
|
||||
optionsMap[id]!.insert(.report)
|
||||
}
|
||||
} else if let _ = peer as? TelegramSecretChat {
|
||||
|
@ -120,6 +120,7 @@ private final class PrefetchManagerImpl {
|
||||
|
||||
prefetchItems.append(contentsOf: chatHistoryMediaItems)
|
||||
prefetchItems.append(contentsOf: stickerItems)
|
||||
prefetchItems.append(contentsOf: emojiSounds.sounds.values.map { .animatedEmojiSticker($0) })
|
||||
|
||||
return prefetchItems
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user