Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add URL to error screen and improve UI in dark mode #3349

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
"yes_label" = "Yes";
"url_label" = "URL";
18 changes: 17 additions & 1 deletion Sources/App/WebView/ConnectionErrorDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}))
)
}
}
}

Expand Down
26 changes: 19 additions & 7 deletions Sources/Shared/DesignSystem/Components/ExternalLinkButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
3 changes: 3 additions & 0 deletions Sources/Shared/ExternalLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
4 changes: 4 additions & 0 deletions Sources/Shared/Resources/Swiftgen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading