Skip to content

Commit

Permalink
Merge branch 'master' into custom-widgets-state
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoncal authored Feb 20, 2025
2 parents 2ee57af + 791e575 commit f907acc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1172,4 +1172,5 @@ Home Assistant is free and open source home automation software with a focus on
"widgets.sensors.title" = "Sensors";
"widgets.custom.show_last_update_time.param.title" = "Show last update time";
"widgets.custom.show_states.param.title" = "Show states (BETA)";
"connection_error.open_settings.title" = "Open settings";
"yes_label" = "Yes";
33 changes: 32 additions & 1 deletion Sources/App/WebView/ConnectionErrorDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct ConnectionErrorDetailsView: View {
}
}
}
openSettingsButton
CollapsibleView {
Text("Advanced")
.font(.body.bold())
Expand All @@ -73,8 +74,18 @@ struct ConnectionErrorDetailsView: View {
.padding()
}
}
.ignoresSafeArea()
.ignoresSafeArea(edges: .top)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button(action: {
openSettings()
}, label: {
Image(uiImage: MaterialDesignIcons.cogIcon.image(
ofSize: .init(width: 28, height: 28),
color: .white
))
})
}
ToolbarItem(placement: .topBarTrailing) {
CloseButton(tint: .white) {
dismiss()
Expand All @@ -84,6 +95,12 @@ struct ConnectionErrorDetailsView: View {
}
}

private func openSettings() {
Current.sceneManager.webViewWindowControllerPromise.then(\.webViewControllerPromise).done { controller in
controller.showSettingsViewController()
}
}

private var headerView: some View {
VStack {
ZStack(alignment: .topTrailing) {
Expand Down Expand Up @@ -151,6 +168,20 @@ struct ConnectionErrorDetailsView: View {
}
}

private var openSettingsButton: some View {
ActionLinkButton(
icon: Image(uiImage: MaterialDesignIcons.cogIcon.image(
ofSize: .init(width: 28, height: 28),
color: .label
)),
title: L10n.ConnectionError.OpenSettings.title,
tint: .init(uiColor: Asset.Colors.haPrimary.color)
) {
openSettings()
}
.padding(.top)
}

private var documentationLink: some View {
ExternalLinkButton(
icon: Image(systemSymbol: .docTextFill),
Expand Down
7 changes: 7 additions & 0 deletions Sources/Shared/Resources/Swiftgen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,13 @@ public enum L10n {
}
}

public enum ConnectionError {
public enum OpenSettings {
/// Open settings
public static var title: String { return L10n.tr("Localizable", "connection_error.open_settings.title") }
}
}

public enum Database {
public enum Problem {
/// Delete Database & Quit App
Expand Down

0 comments on commit f907acc

Please sign in to comment.