If I take out the reindexing loop, it works fine, except, of course, the position isn't always right when its index collides with another one.
Post
Replies
Boosts
Views
Activity
Okay, well, ahem.
I got this to work with a List. I always understood that would not work, that I would have to use ForEach to access the hierarchical sidebar list I need by using a list.
The issue was my Model data class (Sidebar) gave it indigestion. There were NO error messages; there was NO crash. It simply hung. No memory leaks, and I could find nowhere to place a breakpoint - it was basically contemplating its the navel.
I finally fixed it by dragging only the sidebar.id (a uuidString) and then doing an "if let sidebar = sidebars. first(where: {$0.id == items[0]}) { print(sidebar.title) }" in the destination.
Here is my List for those who might be struggling with doing this:
List(sidebars.sorted{$0.index < $1.index}[0].children!, id:\.id, children: \.children, selection: $selected) { sidebar in
NavigationLink {
SidebarDetailSelectorView(sidebar: sidebar)
} label: {
rowLabel(sidebar: sidebar)
//.background(Color.random())
}
.onChange(of: selected) {
current.sidebar = sidebars.first{ $0.id == selected }
}
.draggable(sidebar.id)
.dropDestination(for: UUID.self) { items, location in
if let sidebar = sidebars.first(where: {$0.id == items[0]}) {
print(sidebar.title)
// do magic here...
}
return true
} isTargeted: { isTargeted in
sidebar.isTargeted = isTargeted
}
}
Thank you. That works; my main problem was that Sidebar was not Codabale - sigh...
I gave up on finding how to get update to work. I use Apple Configurator to install the latest Dev Beta using my MacBook Pro and that worked fine. That at least gets my SwiftUI work moving again.
Same here using NavigationSplitView instead of stack.
To clarify, regardless of what color I select in the FontPanel it returns
["NSForegroundColorAttributeName": Catalog color: System textColor, "NSColor": Catalog color: System textColor]
Catalog color: System textColor
["NSForegroundColorAttributeName": Catalog color: System textColor, "NSColor": Catalog color: System textColor]
Catalog color: System textColor
Oops! My mistake. DUH.
I had a data structure to hold the settings - it was called Settings, so duplicate name.
Change the name of the data structure and it works fine now.
The absolutely best documentation I have found (IMHO) is an app called SwiftUI Companion. Pretty complete, and has working examples of almost everything.
It has vastly improved my learning by showing me now only syntax but HOW to use it in real examples.
It is available in both the App Store and on the creators site - which also has a lot of useful blog posts that do deep dives into SwiftUI.
It does cost - but you will not regret the purchase.
Here is a link to my Gibhub of the project, if that will help understand my question.
Hermes - https://github.com/jfranknichols/Hermes.git
I have the same issue with 12.2 beta 2.
Reverting to any v12 doesn't help.
Creating a new project doesn't help.
Running a clean install of Big Sur current beta doesn't help.
Deleting all references to Xcode in System and User folders doesn't help.