mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-24 10:49:41 -05:00
<!-- 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 --> This PR is a massive refactor of how the app handles UI presentation and navigation, goin from the UIKit based apps style to SwiftUI. ## 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. --> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
66 lines
2.1 KiB
Swift
66 lines
2.1 KiB
Swift
import UIKit
|
|
|
|
enum SceneActivity: CaseIterable {
|
|
case webView
|
|
case settings
|
|
case about
|
|
case carPlay
|
|
case assist
|
|
case onboarding
|
|
|
|
init(activityIdentifier: String) {
|
|
self = Self.allCases.first(where: { $0.activityIdentifier == activityIdentifier }) ?? .webView
|
|
}
|
|
|
|
init(configurationName: String) {
|
|
self = Self.allCases.first(where: { $0.configurationName == configurationName }) ?? .webView
|
|
}
|
|
|
|
var activity: NSUserActivity {
|
|
let activity = NSUserActivity(activityType: activityIdentifier)
|
|
// `targetContentIdentifier` is what SwiftUI `handlesExternalEvents(matching:)` matches against, so
|
|
// scenes activated for this activity route to the right `WindowGroup` (e.g. Settings) in `HAApp`.
|
|
activity.targetContentIdentifier = activityIdentifier
|
|
return activity
|
|
}
|
|
|
|
func activity(with userInfo: [AnyHashable: Any]) -> NSUserActivity {
|
|
let activity = NSUserActivity(activityType: activityIdentifier)
|
|
activity.targetContentIdentifier = activityIdentifier
|
|
activity.userInfo = userInfo
|
|
return activity
|
|
}
|
|
|
|
var activityIdentifier: String {
|
|
switch self {
|
|
case .settings: return "ha.settings"
|
|
case .webView: return "ha.webview"
|
|
case .about: return "ha.about"
|
|
case .carPlay: return "ha.carPlay"
|
|
case .assist: return "ha.assist"
|
|
case .onboarding: return "ha.onboarding"
|
|
}
|
|
}
|
|
|
|
var configurationName: String {
|
|
switch self {
|
|
case .webView: return "WebView"
|
|
case .settings: return "Settings"
|
|
case .about: return "About"
|
|
case .carPlay: return "CarPlay"
|
|
case .assist: return "Assist"
|
|
case .onboarding: return "Onboarding"
|
|
}
|
|
}
|
|
|
|
var configuration: UISceneConfiguration {
|
|
switch self {
|
|
case .webView, .settings, .about, .assist, .onboarding: return .init(
|
|
name: configurationName,
|
|
sessionRole: .windowApplication
|
|
)
|
|
case .carPlay: return .init(name: configurationName, sessionRole: .carTemplateApplication)
|
|
}
|
|
}
|
|
}
|