diff --git a/Sources/App/Resources/en.lproj/Localizable.strings b/Sources/App/Resources/en.lproj/Localizable.strings index 9b43b6779..97bbb6a96 100644 --- a/Sources/App/Resources/en.lproj/Localizable.strings +++ b/Sources/App/Resources/en.lproj/Localizable.strings @@ -185,6 +185,7 @@ "connection.error.details.button.discord" = "Ask in Discord"; "connection.error.details.button.doc" = "Read documentation"; "connection.error.details.button.github" = "Report issue in GitHub"; +"connection.error.details.button.search_github" = "Search in GitHub"; "connection.error.details.label.code" = "Code"; "connection.error.details.label.description" = "Description"; "connection.error.details.label.domain" = "Domain"; @@ -1107,4 +1108,5 @@ Home Assistant is free and open source home automation software with a focus on "widgets.sensors.description" = "Display state of sensors"; "widgets.sensors.not_configured" = "No Sensors Configured"; "widgets.sensors.title" = "Sensors"; -"yes_label" = "Yes"; \ No newline at end of file +"yes_label" = "Yes"; +"url_label" = "URL"; diff --git a/Sources/App/WebView/ConnectionErrorDetailsView.swift b/Sources/App/WebView/ConnectionErrorDetailsView.swift index 51c6e8392..7bd87de5d 100644 --- a/Sources/App/WebView/ConnectionErrorDetailsView.swift +++ b/Sources/App/WebView/ConnectionErrorDetailsView.swift @@ -20,6 +20,9 @@ struct ConnectionErrorDetailsView: View { 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 @@ -57,13 +60,26 @@ struct ConnectionErrorDetailsView: View { ) } + @ViewBuilder private var githubLink: some View { ExternalLinkButton( icon: Image("github.fill"), title: L10n.Connection.Error.Details.Button.github, url: ExternalLink.githubReportIssue, - tint: .black + 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 + })) + ) + } } } diff --git a/Sources/Shared/DesignSystem/Components/ExternalLinkButton.swift b/Sources/Shared/DesignSystem/Components/ExternalLinkButton.swift index 3aecfd12e..91191c26d 100644 --- a/Sources/Shared/DesignSystem/Components/ExternalLinkButton.swift +++ b/Sources/Shared/DesignSystem/Components/ExternalLinkButton.swift @@ -28,16 +28,28 @@ public struct ExternalLinkButton: View { } .frame(maxWidth: 600) .padding() - .background(Color(.systemGray6)) + .background(Color(uiColor: .secondarySystemBackground)) .clipShape(RoundedRectangle(cornerRadius: 12)) } } #Preview { - ExternalLinkButton( - icon: Image(systemName: "xmark"), - title: "Go there", - url: URL(string: "https://google.com")!, - tint: .blue - ) + VStack {} + .sheet(isPresented: .constant(true)) { + VStack { + ExternalLinkButton( + icon: Image(systemName: "xmark"), + title: "Go there", + url: URL(string: "https://google.com")!, + tint: .blue + ) + ExternalLinkButton( + icon: Image(systemName: "xmark"), + title: "Go there", + url: URL(string: "https://google.com")!, + tint: .blue + ) + .preferredColorScheme(.dark) + } + } } diff --git a/Sources/Shared/ExternalLink.swift b/Sources/Shared/ExternalLink.swift index 7ac0ff1f0..685afe282 100644 --- a/Sources/Shared/ExternalLink.swift +++ b/Sources/Shared/ExternalLink.swift @@ -4,4 +4,7 @@ public enum ExternalLink { public static var companionAppDocs = URL(string: "https://companion.home-assistant.io")! public static var discord = URL(string: "https://discord.com/channels/330944238910963714/1284965926336335993")! public static var githubReportIssue = URL(string: "https://github.com/home-assistant/iOS/issues/new/choose")! + public static func githubSearchIssue(domain: String) -> URL? { + URL(string: "https://github.com/home-assistant/iOS/search?q=\(domain)&type=issues") + } } diff --git a/Sources/Shared/Resources/Swiftgen/Strings.swift b/Sources/Shared/Resources/Swiftgen/Strings.swift index 2eb94b099..85e37a68b 100644 --- a/Sources/Shared/Resources/Swiftgen/Strings.swift +++ b/Sources/Shared/Resources/Swiftgen/Strings.swift @@ -54,6 +54,8 @@ public enum L10n { public static var retryLabel: String { return L10n.tr("Localizable", "retry_label") } /// Success public static var successLabel: String { return L10n.tr("Localizable", "success_label") } + /// URL + public static var urlLabel: String { return L10n.tr("Localizable", "url_label") } /// Username public static var usernameLabel: String { return L10n.tr("Localizable", "username_label") } /// Yes @@ -768,6 +770,8 @@ public enum L10n { public static var doc: String { return L10n.tr("Localizable", "connection.error.details.button.doc") } /// Report issue in GitHub public static var github: String { return L10n.tr("Localizable", "connection.error.details.button.github") } + /// Search in GitHub + public static var searchGithub: String { return L10n.tr("Localizable", "connection.error.details.button.search_github") } } public enum Label { /// Code