From 7c4b60cdec21634f059e89c4984795b2cb62f55b Mon Sep 17 00:00:00 2001 From: "5411131+timbms@users.noreply.github.com" Date: Tue, 29 Oct 2024 19:20:40 +0100 Subject: [PATCH] Showing sitemap.label instead of sitemap.name for selection of sitemap for watch Sync Preferences to sitemap for watch in DrawerView Signed-off-by: Tim Bert <5411131+timbms@users.noreply.github.com> --- openHAB/DrawerView.swift | 11 ++++++----- openHAB/SettingsView.swift | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openHAB/DrawerView.swift b/openHAB/DrawerView.swift index 27c0df0b..0801ca3b 100644 --- a/openHAB/DrawerView.swift +++ b/openHAB/DrawerView.swift @@ -137,7 +137,7 @@ struct DrawerView: View { var sitemaps: [OpenHABSitemap] var sitemapIconwidth: CGFloat var appData: OpenHABDataObject? - @Binding var sitemapForWatch: OpenHABSitemap? + @Binding var sitemapForWatch: String? var onDismiss: (TargetController) -> Void var dismiss: DismissAction @@ -148,16 +148,16 @@ struct DrawerView: View { sitemap: sitemap, sitemapIconwidth: sitemapIconwidth, appData: appData, - isWatchSitemap: sitemap.name == sitemapForWatch?.name, + isWatchSitemap: sitemap.name == sitemapForWatch, onDismiss: onDismiss, dismiss: dismiss ) .onTapGesture(count: 2) { - if sitemap.name == sitemapForWatch?.name { + if sitemap.name == sitemapForWatch { sitemapForWatch = nil Preferences.sitemapForWatch = "" } else { - sitemapForWatch = sitemap + sitemapForWatch = sitemap.name Preferences.sitemapForWatch = sitemap.name } } @@ -251,7 +251,7 @@ struct DrawerView: View { @ScaledMetric var tilesIconwidth = 20.0 @ScaledMetric var sitemapIconwidth = 20.0 - @State private var sitemapForWatch: OpenHABSitemap? + @State private var sitemapForWatch: String? var body: some View { VStack { @@ -276,6 +276,7 @@ struct DrawerView: View { private func loadData() { loadSitemaps() loadUiTiles() + sitemapForWatch = Preferences.sitemapForWatch } private func loadSitemaps() { diff --git a/openHAB/SettingsView.swift b/openHAB/SettingsView.swift index 4dcdf269..cd728014 100644 --- a/openHAB/SettingsView.swift +++ b/openHAB/SettingsView.swift @@ -280,7 +280,7 @@ struct SettingsView: View { Picker(selection: $settingsSitemapForWatch) { ForEach(sitemaps, id: \.name) { sitemap in - Text(sitemap.name).tag(sitemap as OpenHABSitemap?) + Text(sitemap.label) } } label: { Text("Sitemap For Apple Watch")