Post

Replies

Boosts

Views

Activity

SwiftUI NavigationSplitView Bug?
Hi All! I am working on a Multiplatform SwiftUI app and I've encountered an issue with NavigationSplitView. My app's ContentView is a NavigationSplitView sidebar and detail. The sidebar is a list with several NavigationLinks. (I haven't adopted programmatic navigation because of the simplicity this sidebar.) One of the NavigationLinks brings the user to a Table with several rows and columns. Then, when I go to select an item on the table, a row shows selected for a split second, before deselecting itself again. Then, I can use the table as normal. This happens every time the view is opened. The reason I think that this is an issue with NavigationSplitView is because when I use the legacy NavigationView, everything is fine. Is this normal behavior for NavigationSplitView, and if it is, how to I make it so that my table receives focus when the NavigationLink is open?
1
0
986
Jan ’23
How to use the .onMove SwiftUI modifier to reorder SwiftData elements?
I am new to SwiftData and I'm trying to use the .onMove modifier to rearrange "ChecklistItems" List { ForEach(items) { item in ChecklistItemsListRowView(item: item, checklist: checklist) .onTapGesture { item.completed.toggle() save() } // onTapGesture } .onDelete(perform: { indexes in for index in indexes { modelContext.delete(checklist.items[index]) } // *for* }) // onDelete .onMove { IndexSet, int in // TODO: Rearrange Elements } // onMove } // LIST This is my ChecklistItem class: @Model final class ChecklistItem { @Attribute(.unique) var creationDate: Date var name: String var priority: Int var notes: String var completed: Bool var checklist: Checklist? init(creationDate: Date, name: String, priority: Int, notes: String, completed: Bool) { self.creationDate = creationDate self.name = name self.priority = priority self.notes = notes self.completed = completed } } extension ChecklistItem { @Transient static var preview = ChecklistItem(creationDate: Date(), name: "Item", priority: 2, notes: "This is a note.", completed: true) }
3
1
2.7k
Aug ’23