mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user