Skip to content

Commit 791e575

Browse files
authored
Add settings entry point from connection error screen (#3449)
1 parent d1de79b commit 791e575

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

Sources/App/Resources/en.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,4 +1170,5 @@ Home Assistant is free and open source home automation software with a focus on
11701170
"widgets.sensors.description" = "Display state of sensors";
11711171
"widgets.sensors.not_configured" = "No Sensors Configured";
11721172
"widgets.sensors.title" = "Sensors";
1173-
"yes_label" = "Yes";
1173+
"connection_error.open_settings.title" = "Open settings";
1174+
"yes_label" = "Yes";

Sources/App/WebView/ConnectionErrorDetailsView.swift

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct ConnectionErrorDetailsView: View {
4848
}
4949
}
5050
}
51+
openSettingsButton
5152
CollapsibleView {
5253
Text("Advanced")
5354
.font(.body.bold())
@@ -73,8 +74,18 @@ struct ConnectionErrorDetailsView: View {
7374
.padding()
7475
}
7576
}
76-
.ignoresSafeArea()
77+
.ignoresSafeArea(edges: .top)
7778
.toolbar {
79+
ToolbarItem(placement: .topBarLeading) {
80+
Button(action: {
81+
openSettings()
82+
}, label: {
83+
Image(uiImage: MaterialDesignIcons.cogIcon.image(
84+
ofSize: .init(width: 28, height: 28),
85+
color: .white
86+
))
87+
})
88+
}
7889
ToolbarItem(placement: .topBarTrailing) {
7990
CloseButton(tint: .white) {
8091
dismiss()
@@ -84,6 +95,12 @@ struct ConnectionErrorDetailsView: View {
8495
}
8596
}
8697

98+
private func openSettings() {
99+
Current.sceneManager.webViewWindowControllerPromise.then(\.webViewControllerPromise).done { controller in
100+
controller.showSettingsViewController()
101+
}
102+
}
103+
87104
private var headerView: some View {
88105
VStack {
89106
ZStack(alignment: .topTrailing) {
@@ -151,6 +168,20 @@ struct ConnectionErrorDetailsView: View {
151168
}
152169
}
153170

171+
private var openSettingsButton: some View {
172+
ActionLinkButton(
173+
icon: Image(uiImage: MaterialDesignIcons.cogIcon.image(
174+
ofSize: .init(width: 28, height: 28),
175+
color: .label
176+
)),
177+
title: L10n.ConnectionError.OpenSettings.title,
178+
tint: .init(uiColor: Asset.Colors.haPrimary.color)
179+
) {
180+
openSettings()
181+
}
182+
.padding(.top)
183+
}
184+
154185
private var documentationLink: some View {
155186
ExternalLinkButton(
156187
icon: Image(systemSymbol: .docTextFill),

Sources/Shared/Resources/Swiftgen/Strings.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,13 @@ public enum L10n {
847847
}
848848
}
849849

850+
public enum ConnectionError {
851+
public enum OpenSettings {
852+
/// Open settings
853+
public static var title: String { return L10n.tr("Localizable", "connection_error.open_settings.title") }
854+
}
855+
}
856+
850857
public enum Database {
851858
public enum Problem {
852859
/// Delete Database & Quit App

0 commit comments

Comments
 (0)