Move Home shortcut style picker to its own page with live preview

Replace the inline Plain/Accent/Colorful picker in Home customization with
a navigation row that opens a dedicated page. The new page keeps the style
selector and renders a non-interactive preview of every shortcut type so
the chosen style is visible before committing.

- Add an optional styleOverride to HomeShortcutCardView so the preview can
  reflect the not-yet-saved selection.
- On macOS, navigate via navigationDestination(isPresented:) instead of a
  List-embedded NavigationLink, which otherwise stays stuck in its selected
  state after popping back and can't be reopened.
This commit is contained in:
Arkadiusz Fal
2026-05-28 20:34:38 +02:00
parent ef213307dc
commit bcd4206c55
4 changed files with 152 additions and 6 deletions

View File

@@ -29,6 +29,13 @@ struct HomeSettingsView: View {
// Edit mode for delete functionality
@State private var isEditMode = false
#if os(macOS)
// macOS: drive the style page programmatically. A List-embedded NavigationLink
// gets stuck in the selected (blue) state after popping back and can't be
// re-activated, so navigate via navigationDestination(isPresented:) instead.
@State private var showingStyleSettings = false
#endif
private var settingsManager: SettingsManager? { appEnvironment?.settingsManager }
var body: some View {
@@ -46,6 +53,9 @@ struct HomeSettingsView: View {
#endif
#if os(macOS)
.listStyle(.inset)
.navigationDestination(isPresented: $showingStyleSettings) {
HomeShortcutStyleView(style: $shortcutCardStyle)
}
#endif
#if !os(tvOS)
.navigationTitle(String(localized: "home.settings.title"))
@@ -75,13 +85,35 @@ struct HomeSettingsView: View {
}
.pickerStyle(.segmented)
// Card style picker (Plain / Accent / Colorful) only for cards layout
// Card style (Plain / Accent / Colorful) navigates to a page with
// a selector and a live preview. Only for cards layout.
if shortcutLayout == .cards {
Picker(String(localized: "home.settings.shortcuts.style"), selection: $shortcutCardStyle) {
ForEach(HomeShortcutCardStyle.allCases, id: \.self) { style in
Text(style.displayName).tag(style)
#if os(macOS)
Button {
showingStyleSettings = true
} label: {
HStack(spacing: 8) {
Label(String(localized: "home.settings.shortcuts.style"), systemImage: "paintpalette")
Spacer()
Text(shortcutCardStyle.displayName)
.foregroundStyle(.secondary)
Image(systemName: "chevron.right")
.font(.caption)
.foregroundStyle(.tertiary)
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
#else
SettingsNavigationRow(
"home.settings.shortcuts.style",
systemImage: "paintpalette",
trailing: { Text(shortcutCardStyle.displayName) }
) {
HomeShortcutStyleView(style: $shortcutCardStyle)
}
#endif
}
#endif