Skip to content

Commit

Permalink
Showing sitemap.label instead of sitemap.name for selection of sitema…
Browse files Browse the repository at this point in the history
…p for watch

Sync Preferences to sitemap for watch in DrawerView

Signed-off-by: Tim Bert <[email protected]>
  • Loading branch information
[email protected] authored and [email protected] committed Oct 29, 2024
1 parent 39c7694 commit 7c4b60c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions openHAB/DrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -276,6 +276,7 @@ struct DrawerView: View {
private func loadData() {
loadSitemaps()
loadUiTiles()
sitemapForWatch = Preferences.sitemapForWatch
}

private func loadSitemaps() {
Expand Down
2 changes: 1 addition & 1 deletion openHAB/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7c4b60c

Please sign in to comment.