You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! First of all, I'm sorry if it's a stupid question or if it has nothing to do with these package.
I'm trying to animate a List where the order of elements depends on a variable in Defaults.
If I'm using a @State, it's working as expected.
If I'm using a @Default, animation doesn't work.
These works:
enumOrderBy:String,Codable,Defaults.Serializable{case index, name
}structElement:Identifiable{letid:Stringletindex:Intletname:String}letallElements:[Element]=[.init(id:"1", index:5, name:"Element 1"),.init(id:"2", index:4, name:"Element 2"),.init(id:"3", index:1, name:"Element 3"),.init(id:"4", index:3, name:"Element 4"),.init(id:"5", index:2, name:"Element 5"),]structMyView:View{@Statevarorder:OrderBy=.index
func toggleOrder(){withAnimation{
order = order ==.index ?.name : .index
}}varelements:[Element]{
allElements.sorted(by:{ order ==.index ? $0.index < $1.index : $0.name < $1.name })}varbody:someView{Picker("Order by", selection: $order){Text("index").tag(OrderBy.index)Text("name").tag(OrderBy.name)}List{ForEach(elements, id: \.id){ element inText("Element \(element.name)")}}}}
Is there any way we can bypass the issue without an intermediate variables somewhere?
Will it be fixed in the package or when the SwiftUI bug will be fixed?
Thanks!
Hi! First of all, I'm sorry if it's a stupid question or if it has nothing to do with these package.
I'm trying to animate a
List
where the order of elements depends on a variable inDefaults
.If I'm using a
@State
, it's working as expected.If I'm using a
@Default
, animation doesn't work.These works:
These doesn't work:
Is these a limitation of the package or is it completely something else?
Thanks
The text was updated successfully, but these errors were encountered: