I am wondering how I can animate the content size of a ViewBuilder view. I have this:
struct CardView<Content>: View where Content: View {
    
    private let content: Content
    
    init(@ViewBuilder content: () -> Content) {
        self.content = content()
    }
    
    var body: some View {
        VStack(spacing: 0) {
            content
                .padding(16)
        }
        .background(.white)
        .cornerRadius(14)
        .shadow(color: .black.opacity(0.07), radius: 12, x: 0, y: 2)
    }
}
I would like to animate any size changes to content,  but I can't find a nice way of doing this. I found two ways that work:
- Using animation(.linear)inCardViewworks, but is deprecated and discouraged since I have novalueto attach the animation to.
- Using withAnimationinsidecontentwhen changing the content works, too, but I would like to encapsulate this behaviour inCardView.CardViewis heavily reused and doing it incontentis easy to forget and also not where this behaviour belongs in my opinion.
I also tried using GeometryReader but could not find a good way of doing it.
 
     
    