mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-23 05:34:34 -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 --> ## 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. -->
93 lines
3.1 KiB
Swift
93 lines
3.1 KiB
Swift
import SFSafeSymbols
|
|
import Shared
|
|
import SwiftUI
|
|
|
|
struct ConnectionErrorDetailsView: View {
|
|
@Environment(\.dismiss) private var dismiss
|
|
let error: Error
|
|
var body: some View {
|
|
ScrollView {
|
|
VStack(alignment: .leading) {
|
|
HStack {
|
|
SheetCloseButton {
|
|
dismiss()
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
}
|
|
Text(L10n.Connection.Error.Details.title)
|
|
.font(.title.bold())
|
|
VStack(alignment: .leading, spacing: Spaces.two) {
|
|
makeRow(title: L10n.Connection.Error.Details.Label.description, body: error.localizedDescription)
|
|
makeRow(title: L10n.Connection.Error.Details.Label.domain, body: (error as NSError).domain)
|
|
makeRow(title: L10n.Connection.Error.Details.Label.code, body: "\((error as NSError).code)")
|
|
if let urlError = error as? URLError {
|
|
makeRow(title: L10n.urlLabel, body: urlError.failingURL?.absoluteString ?? "")
|
|
}
|
|
}
|
|
.padding(.vertical)
|
|
documentationLink
|
|
discordLink
|
|
githubLink
|
|
}
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
private func makeRow(title: String, body: String) -> some View {
|
|
VStack(alignment: .leading) {
|
|
Text(title)
|
|
.font(.headline.bold())
|
|
Text(body)
|
|
.textSelection(.enabled)
|
|
}
|
|
}
|
|
|
|
private var documentationLink: some View {
|
|
ExternalLinkButton(
|
|
icon: Image(systemSymbol: .docTextFill),
|
|
title: L10n.Connection.Error.Details.Button.doc,
|
|
url: ExternalLink.companionAppDocs,
|
|
tint: .init(uiColor: Asset.Colors.haPrimary.color)
|
|
)
|
|
}
|
|
|
|
private var discordLink: some View {
|
|
ExternalLinkButton(
|
|
icon: Image("discord.fill"),
|
|
title: L10n.Connection.Error.Details.Button.discord,
|
|
url: ExternalLink.discord,
|
|
tint: .purple
|
|
)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var githubLink: some View {
|
|
ExternalLinkButton(
|
|
icon: Image("github.fill"),
|
|
title: L10n.Connection.Error.Details.Button.github,
|
|
url: ExternalLink.githubReportIssue,
|
|
tint: .init(uiColor: .init(dynamicProvider: { trait in
|
|
trait.userInterfaceStyle == .dark ? .white : .black
|
|
}))
|
|
)
|
|
if let searchURL = ExternalLink.githubSearchIssue(domain: (error as NSError).domain) {
|
|
ExternalLinkButton(
|
|
icon: Image("github.fill"),
|
|
title: L10n.Connection.Error.Details.Button.searchGithub,
|
|
url: searchURL,
|
|
tint: .init(uiColor: .init(dynamicProvider: { trait in
|
|
trait.userInterfaceStyle == .dark ? .white : .black
|
|
}))
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ConnectionErrorDetailsView(error: SomeError.some)
|
|
}
|
|
|
|
enum SomeError: Error {
|
|
case some
|
|
}
|