I created a list to expand and collapse when the user taped on a row but as you can see the animation in collapse mode is not working properly. and the whole row getting closed before animation executed only on iOS 15 but on ios 14 it was working ok.
struct MyRow:View{
@State var isExpanded = false
var body: some View{
VStack{
VStack{
HStack{
Image("avatar")
.resizable()
.frame(width: 64, height: 64)
Text("Test Row with Long Title and really long Title ")
Spacer()
}
if isExpanded{
Button("Click on me"){
}
.foregroundColor(Color.blue)
}
}
.padding(16)
.background(Color.primary.opacity(0.08))
.cornerRadius(16)
}
.onTapGesture {
withAnimation {
isExpanded.toggle()
}
}
}
}
struct MyList_Previews: PreviewProvider {
static var previews: some View {
MyList()
.previewDevice("iPhone 12 Pro Max")
.environmentObject(AppState.shared)
}
}
struct MyList :View{
var body: some View{
List{
ForEach(1...5 , id:\.self){ content in
MyRow()
}
}
.animation(.default)
.listStyle(PlainListStyle())
}
}