From 791e575907b7c8a6071a44463a099460cdc3fc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Pantale=C3=A3o=20Gon=C3=A7alves?= <5808343+bgoncal@users.noreply.github.com> Date: Thu, 20 Feb 2025 12:53:48 +0100 Subject: [PATCH 1/2] Add settings entry point from connection error screen (#3449) --- .../Resources/en.lproj/Localizable.strings | 3 +- .../WebView/ConnectionErrorDetailsView.swift | 33 ++++++++++++++++++- .../Shared/Resources/Swiftgen/Strings.swift | 7 ++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Sources/App/Resources/en.lproj/Localizable.strings b/Sources/App/Resources/en.lproj/Localizable.strings index a9cfed193..33939509d 100644 --- a/Sources/App/Resources/en.lproj/Localizable.strings +++ b/Sources/App/Resources/en.lproj/Localizable.strings @@ -1170,4 +1170,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 +"connection_error.open_settings.title" = "Open settings"; +"yes_label" = "Yes"; diff --git a/Sources/App/WebView/ConnectionErrorDetailsView.swift b/Sources/App/WebView/ConnectionErrorDetailsView.swift index a6f6294b4..8b3623298 100644 --- a/Sources/App/WebView/ConnectionErrorDetailsView.swift +++ b/Sources/App/WebView/ConnectionErrorDetailsView.swift @@ -48,6 +48,7 @@ struct ConnectionErrorDetailsView: View { } } } + openSettingsButton CollapsibleView { Text("Advanced") .font(.body.bold()) @@ -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() @@ -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) { @@ -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), diff --git a/Sources/Shared/Resources/Swiftgen/Strings.swift b/Sources/Shared/Resources/Swiftgen/Strings.swift index 357584621..c0dbbd4e9 100644 --- a/Sources/Shared/Resources/Swiftgen/Strings.swift +++ b/Sources/Shared/Resources/Swiftgen/Strings.swift @@ -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 From d90a4f79689b8abda051887083563e9597f19195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Pantale=C3=A3o=20Gon=C3=A7alves?= <5808343+bgoncal@users.noreply.github.com> Date: Thu, 20 Feb 2025 13:22:43 +0100 Subject: [PATCH 2/2] Add missing localization for custom widgets picker (#3451) ## Summary ## Screenshots ## Link to pull request in Documentation repository Documentation: home-assistant/companion.home-assistant# ## Any other notes --- Sources/App/Resources/en.lproj/Localizable.strings | 2 ++ .../Widgets/Custom/WidgetCustomTimelineProvider.swift | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/App/Resources/en.lproj/Localizable.strings b/Sources/App/Resources/en.lproj/Localizable.strings index 33939509d..ee1a4adf5 100644 --- a/Sources/App/Resources/en.lproj/Localizable.strings +++ b/Sources/App/Resources/en.lproj/Localizable.strings @@ -1170,5 +1170,7 @@ 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"; +"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"; diff --git a/Sources/Extensions/Widgets/Custom/WidgetCustomTimelineProvider.swift b/Sources/Extensions/Widgets/Custom/WidgetCustomTimelineProvider.swift index cdbbfb1cc..372aadcb9 100644 --- a/Sources/Extensions/Widgets/Custom/WidgetCustomTimelineProvider.swift +++ b/Sources/Extensions/Widgets/Custom/WidgetCustomTimelineProvider.swift @@ -220,14 +220,14 @@ struct WidgetCustomAppIntent: AppIntent, WidgetConfigurationIntent { var widget: CustomWidgetEntity? @Parameter( - title: "Show last update time", + title: .init("widgets.custom.show_last_update_time.param.title", defaultValue: "Show last update time"), default: true ) var showLastUpdateTime: Bool @Parameter( - title: "Show states (BETA)", - default: false + title: .init("widgets.custom.show_states.param.title", defaultValue: "Show states (BETA)"), + default: true ) var showStates: Bool