diff --git a/submodules/Display/Display/WindowContent.swift b/submodules/Display/Display/WindowContent.swift index a794da4b03..feee56aa68 100644 --- a/submodules/Display/Display/WindowContent.swift +++ b/submodules/Display/Display/WindowContent.swift @@ -85,6 +85,7 @@ private struct UpdatingLayout { } } +private let defaultStatusBarHeight: CGFloat = 20.0 private let statusBarHiddenInLandscape: Bool = UIDevice.current.userInterfaceIdiom == .phone private func inputHeightOffsetForLayout(_ layout: WindowLayout) -> CGFloat { @@ -280,7 +281,7 @@ public final class WindowKeyboardGestureRecognizerDelegate: NSObject, UIGestureR public class Window1 { public let hostView: WindowHostView - private let deviceMetrics: DeviceMetrics + private var deviceMetrics: DeviceMetrics private let statusBarHost: StatusBarHost? private let statusBarManager: StatusBarManager? @@ -342,7 +343,7 @@ public class Window1 { self.volumeControlStatusBarNode.isHidden = true let boundsSize = self.hostView.eventView.bounds.size - self.deviceMetrics = DeviceMetrics(screenSize: UIScreen.main.bounds.size, statusBarHeight: statusBarHost?.statusBarFrame.height ?? 20.0, onScreenNavigationHeight: self.hostView.onScreenNavigationHeight) + self.deviceMetrics = DeviceMetrics(screenSize: UIScreen.main.bounds.size, statusBarHeight: statusBarHost?.statusBarFrame.height ?? defaultStatusBarHeight, onScreenNavigationHeight: self.hostView.onScreenNavigationHeight) self.statusBarHost = statusBarHost let statusBarHeight: CGFloat @@ -439,7 +440,7 @@ public class Window1 { self.statusBarChangeObserver = NotificationCenter.default.addObserver(forName: UIApplication.willChangeStatusBarFrameNotification, object: nil, queue: OperationQueue.main, using: { [weak self] notification in if let strongSelf = self { - let statusBarHeight: CGFloat = max(20.0, (notification.userInfo?[UIApplication.statusBarFrameUserInfoKey] as? NSValue)?.cgRectValue.height ?? 20.0) + let statusBarHeight: CGFloat = max(defaultStatusBarHeight, (notification.userInfo?[UIApplication.statusBarFrameUserInfoKey] as? NSValue)?.cgRectValue.height ?? defaultStatusBarHeight) let transition: ContainedViewLayoutTransition = .animated(duration: 0.35, curve: .easeInOut) strongSelf.updateLayout { $0.update(statusBarHeight: statusBarHeight, transition: transition, overrideTransition: false) } @@ -947,6 +948,11 @@ public class Window1 { } else { statusBarHeight = self.deviceMetrics.statusBarHeight } + + if self.deviceMetrics.type == .tablet, let onScreenNavigationHeight = self.hostView.onScreenNavigationHeight, onScreenNavigationHeight != self.deviceMetrics.onScreenNavigationHeight(inLandscape: false) { + self.deviceMetrics = DeviceMetrics(screenSize: UIScreen.main.bounds.size, statusBarHeight: statusBarHeight ?? defaultStatusBarHeight, onScreenNavigationHeight: onScreenNavigationHeight) + } + let statusBarWasHidden = self.statusBarHidden if statusBarHiddenInLandscape && isLandscape { statusBarHeight = nil diff --git a/submodules/TelegramUI/TelegramUI/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/TelegramUI/ChatInterfaceStateContextMenus.swift index 66b225655b..f916078610 100644 --- a/submodules/TelegramUI/TelegramUI/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/TelegramUI/ChatInterfaceStateContextMenus.swift @@ -373,6 +373,24 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState: }))) } + if data.messageActions.options.contains(.sendScheduledNow) { + actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.ScheduledMessages_SendNow, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor) + }, action: { _, f in + controllerInteraction.sendScheduledMessagesNow(selectAll ? messages.map { $0.id } : [message.id]) + f(.dismissWithoutContent) + }))) + } + + if data.messageActions.options.contains(.editScheduledTime) { + actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.ScheduledMessages_EditTime, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Schedule"), color: theme.actionSheet.primaryTextColor) + }, action: { _, f in + controllerInteraction.editScheduledMessagesTime(selectAll ? messages.map { $0.id } : [message.id]) + f(.dismissWithoutContent) + }))) + } + let resourceAvailable: Bool if let resourceStatus = data.resourceStatus, case .Local = resourceStatus { resourceAvailable = true @@ -425,24 +443,6 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState: }))) } - if data.messageActions.options.contains(.sendScheduledNow) { - actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.ScheduledMessages_SendNow, icon: { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.actionSheet.primaryTextColor) - }, action: { _, f in - controllerInteraction.sendScheduledMessagesNow(selectAll ? messages.map { $0.id } : [message.id]) - f(.dismissWithoutContent) - }))) - } - - if data.messageActions.options.contains(.editScheduledTime) { - actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.ScheduledMessages_EditTime, icon: { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Schedule"), color: theme.actionSheet.primaryTextColor) - }, action: { _, f in - controllerInteraction.editScheduledMessagesTime(selectAll ? messages.map { $0.id } : [message.id]) - f(.dismissWithoutContent) - }))) - } - if data.canEdit { actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_MessageDialogEdit, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor)