mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
Fix Home card style selection not persisting
The Home settings screen copies settings into local @State on appear and saves on disappear. Pushing the card style page fired onDisappear (saving pre-edit values), and popping back re-ran loadSettings, clobbering the style just edited through the bindings — so the selection reverted. Load settings only once per presentation, and persist style, palette, and custom colors immediately from the style page via an onSave callback. The owning view sits covered in the navigation stack where its own onChange never fires, and swipe-dismissing the settings sheet from the style page skips its lifecycle entirely, so saving must happen from the visible child.
This commit is contained in:
@@ -14,6 +14,11 @@ struct HomeShortcutStyleView: View {
|
||||
@Binding var palette: HomeShortcutColorfulPalette
|
||||
@Binding var customColors: [String]
|
||||
|
||||
/// Called after any value changes so the owner persists immediately. The
|
||||
/// owner sits covered in the navigation stack where its own onChange never
|
||||
/// fires, and swipe-dismissing the sheet from here skips its lifecycle.
|
||||
var onSave: (() -> Void)? = nil
|
||||
|
||||
/// Editing mode for the custom palette.
|
||||
private enum CustomEditMode: String, CaseIterable {
|
||||
case list
|
||||
@@ -87,6 +92,9 @@ struct HomeShortcutStyleView: View {
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.onChange(of: style) { onSave?() }
|
||||
.onChange(of: palette) { onSave?() }
|
||||
.onChange(of: customColors) { onSave?() }
|
||||
}
|
||||
|
||||
// MARK: - Palette
|
||||
|
||||
Reference in New Issue
Block a user