ios – Animating an HStack turning into VStack

[ad_1]

I’ve an HStack consisting of subviews like this:

enter image description here

Right here, the left and proper subviews are grayed out copies of the “Day 2” subview, however they’re minimize off display screen by design. I need the consumer to have the ability to “reorder” these subviews through drag and drop, however since just one subview is totally seen, I need to animate these subviews to be vertically organized when a drag gesture is initiated. For instance, if the consumer begins dragging the “Day 2” subview, I need all of the subviews within the HStack to reorganize and animate such that they are vertically aligned, like this:

enter image description here

I’ve achieved the identical final result by doing the next:

@State isDragging = false 

if isDragging {
   VStack {
      // subviews right here
   }
} else {
   HStack {
      //subviews right here
   }
}

...

.onDrag(...) // set isDragging to true right here with withAnimation

Nevertheless, due to the character of the if/else I am utilizing, I don’t accomplish the “trickle down” animation that I am in search of, or any animation in any respect for that matter. Can anybody give any concepts on how I can restructure this to perform the sort of animation?

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *