0

I have made a list in SwiftUI and I want to make the element views of list able to resize to show more information. Currently when I change the height they just start overlapping each other though. How can I make it so that when the view's height changes it updates the padding between list elements to keep it consistent. Below I have a screen shot of the overlap I am talking about and the relevant code:

enter image description here

here is where I create the list:

List{
      //loop through task cards
      ForEach(self.tasks, id: \.id) { task in
          task
      }
} 

and here is the body code for the task cards that are shown in the list:


var height : CGFloat = 105

var body: some View {
            RoundedRectangle(cornerRadius: 10)
                .foregroundColor(Color.white)
                .frame(height: self.completedLongPress ? self.height + 50 : self.height) // here is where height is changed
                .overlay(
                      //content added in here (I don't think it's particularly important for the problem, but will edit if it's needed)
                    )
            .gesture(self.longPress)

        }
Ethan Hardacre
  • 125
  • 2
  • 12
  • Does this answer your question https://stackoverflow.com/a/62482773/12299030 or https://stackoverflow.com/a/61913880/12299030? – Asperi Sep 17 '20 at 17:14
  • @Asperi interesting, in both of those examples the cell height is being changed automatically it seems (even in the question). That is the effect I want. In my situation the space for the cell in the list isn't changing when I change the height, so the cells end up overlapping – Ethan Hardacre Sep 17 '20 at 17:47
  • 1
    Overlay does not change the frame of parent view. – Asperi Sep 17 '20 at 17:56

0 Answers0