iOS/Sources/App/Scenes/BasicSceneDelegate.swift
Bruno Pantaleão Gonçalves 08482dda8a
Remove max window size for settings on mac (#3568)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-04-24 15:56:39 +02:00

57 lines
1.6 KiB
Swift

import Foundation
import Shared
import UIKit
class BasicSceneDelegate: NSObject, UIWindowSceneDelegate {
var window: UIWindow?
var scene: UIWindowScene?
struct BasicConfig {
var title: String
var rootViewController: UIViewController
}
func basicConfig(in traitCollection: UITraitCollection) -> BasicConfig {
fatalError("must override")
}
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let scene = scene as? UIWindowScene else { return }
self.scene = scene
let config = basicConfig(in: scene.traitCollection)
scene.title = config.title
with(scene.sizeRestrictions) {
if scene.traitCollection.userInterfaceIdiom == .mac {
$0?.minimumSize = CGSize(width: 600.0, height: 200.0)
} else {
$0?.maximumSize.width = 800.0
$0?.minimumSize.width = 300.0
}
}
// never activate these basic scenes scene for anything incoming
scene.activationConditions.canActivateForTargetContentIdentifierPredicate = NSPredicate(value: false)
let window = UIWindow(haScene: scene)
window.rootViewController = config.rootViewController
self.window = window
#if targetEnvironment(macCatalyst)
if let titlebar = scene.titlebar {
titlebar.titleVisibility = .hidden
titlebar.toolbar = nil
}
#endif
informManager(from: connectionOptions)
}
}