Hi,
I have a problem (not for the first time) with GeometryReader. When I have ForEach inside it it works fine - my elements have proper height and are displayed correctly. However when I wrap ForEach in List, elements are no longer displayed. What I found out is that List has 0 height (I need to add frame with height to see it - and I would prefer to have height calculated dynamically).
The following code works fine, but I would like to add "Delete" on swipe.
GeometryReader { geo in
ScrollView(.vertical, showsIndicators: false) {
ForEach(alarmVM.alarms, id:\.id) { alarm in
AlarmItem(alarm: alarm)
} // FOREACH
} // SCROLLVIEW
} // GEOREADER
.frame(maxWidth: 700, alignment: .center)
I need to wrap ForEach with List. But then List has 0px height - it's not set dynamically and in result not visible:
GeometryReader { geo in
ScrollView(.vertical, showsIndicators: false) {
List {
ForEach(alarmVM.alarms, id:\.id) { alarm in
AlarmItem(alarm: alarm)
} // FOREACH
.onDelete(perform: { indexSet in
print(indexSet)
}) // ONDELETE
} // LIST
} // SCROLL VIEW
} // GEOREADER
Is any way to have height of List set dynamically?
EDIT: Looks like it has nothing to do with GeometryReader. When I removed GeometryReader the problem persists.