|
@@ -14,16 +14,38 @@ final class ViewController: NSViewController {
|
|
|
override func loadView() {
|
|
override func loadView() {
|
|
|
let homeView = HomeView(viewModel: viewModel)
|
|
let homeView = HomeView(viewModel: viewModel)
|
|
|
let hostingView = NSHostingView(rootView: homeView)
|
|
let hostingView = NSHostingView(rootView: homeView)
|
|
|
- hostingView.autoresizingMask = [.width, .height]
|
|
|
|
|
|
|
+ hostingView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
hostingView.safeAreaRegions = .container
|
|
hostingView.safeAreaRegions = .container
|
|
|
- self.view = hostingView
|
|
|
|
|
|
|
+
|
|
|
|
|
+ let containerView = NSView()
|
|
|
|
|
+ containerView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
+ containerView.addSubview(hostingView)
|
|
|
|
|
+
|
|
|
|
|
+ let minimumWidth = WindowConfiguration.minimumContentSize.width
|
|
|
|
|
+ let minimumHeight = WindowConfiguration.minimumContentSize.height
|
|
|
|
|
+
|
|
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
|
|
+ hostingView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
|
|
|
|
|
+ hostingView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor),
|
|
|
|
|
+ hostingView.topAnchor.constraint(equalTo: containerView.topAnchor),
|
|
|
|
|
+ hostingView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor),
|
|
|
|
|
+ containerView.widthAnchor.constraint(greaterThanOrEqualToConstant: minimumWidth),
|
|
|
|
|
+ containerView.heightAnchor.constraint(greaterThanOrEqualToConstant: minimumHeight),
|
|
|
|
|
+ ])
|
|
|
|
|
+
|
|
|
|
|
+ self.view = containerView
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override func viewDidAppear() {
|
|
override func viewDidAppear() {
|
|
|
super.viewDidAppear()
|
|
super.viewDidAppear()
|
|
|
|
|
|
|
|
- if let window = view.window {
|
|
|
|
|
- WindowConfigurator.applyUnifiedChrome(to: window)
|
|
|
|
|
|
|
+ guard let window = view.window else { return }
|
|
|
|
|
+ WindowConfiguration.applySharedChrome(to: window)
|
|
|
|
|
+
|
|
|
|
|
+ let contentSize = window.contentRect(forFrameRect: window.frame).size
|
|
|
|
|
+ if contentSize.width < WindowConfiguration.minimumContentSize.width
|
|
|
|
|
+ || contentSize.height < WindowConfiguration.minimumContentSize.height {
|
|
|
|
|
+ WindowConfiguration.applyLaunchConfiguration(to: window)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|