iOS/Sources/App/WebView/ExperimentalSpace/EntityTile/MoreInfoDialog/EntityConfigurationWebView.swift
Bruno Pantaleão Gonçalves 94da1e42ed
Add EntityConfigurationWebView and integrate in dialog (#4171)
Introduces EntityConfigurationWebView for entity configuration via web
view. Integrates a toolbar button in EntityMoreInfoDialogView to present
the new configuration view as a sheet.

<!-- 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. -->
2026-01-07 02:00:30 +00:00

41 lines
1.1 KiB
Swift

import HAKit
import Shared
import SwiftUI
@available(iOS 26.0, *)
struct EntityConfigurationWebView: View {
@Environment(\.dismiss) private var dismiss
let haEntity: HAEntity
let server: Server
@State private var webView: WebViewController?
var body: some View {
NavigationStack {
VStack {
if let webView {
embed(webView)
}
}
.onAppear {
loadWebView()
}
.onDisappear {
webView = nil
}
}
}
private func loadWebView() {
guard let webViewURL = server.info.connection.webviewURL() else { return }
let newWebView = WebViewController(server: server)
webView = newWebView
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
webView?.load(request: .init(url: webViewURL.appending(queryItems: [.init(
name: AppConstants.QueryItems.openMoreInfoDialog.rawValue,
value: haEntity.entityId
)])))
}
}
}