From 755fc3ff674b3c12ba354ac2dfb7ef661ec8d5de Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Tue, 1 Feb 2022 21:55:51 +0100 Subject: [PATCH] feat: adjusting the height of window size to the active screen size when open --- Kit/module/popup.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Kit/module/popup.swift b/Kit/module/popup.swift index b70a573a..8771f6ff 100644 --- a/Kit/module/popup.swift +++ b/Kit/module/popup.swift @@ -124,6 +124,7 @@ internal class PopupView: NSView { override var intrinsicContentSize: CGSize { return CGSize(width: self.frame.width, height: self.frame.height) } + private var windowHeight: CGFloat? override init(frame: NSRect) { self.header = HeaderView(frame: NSRect( @@ -138,6 +139,7 @@ internal class PopupView: NSView { width: frame.width - Constants.Popup.margins*2, height: frame.height - self.header.frame.height - Constants.Popup.margins*2 )) + self.windowHeight = NSScreen.main?.visibleFrame.height super.init(frame: CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.width, height: frame.height)) @@ -192,6 +194,12 @@ internal class PopupView: NSView { internal func appear() { self.display() self.body.subviews.first?.display() + + if let screenHeight = NSScreen.main?.visibleFrame.height, let size = self.body.documentView?.frame.size { + if screenHeight != self.windowHeight { + self.recalculateHeight(size) + } + } } internal func disappear() {} @@ -202,6 +210,7 @@ internal class PopupView: NSView { height: size.height + Constants.Popup.headerHeight + (Constants.Popup.margins*2) ) + self.windowHeight = NSScreen.main?.visibleFrame.height if let screenHeight = NSScreen.main?.visibleFrame.height, windowSize.height > screenHeight { windowSize.height = screenHeight - Constants.Widget.height isScrollVisible = true