I want to display a simple message while waiting for a list to be populated. Something like Loading...
and when the list starts being populated with even one item, remove the message, via a transition, and display the list.
My current attempt, that does not work, looks like:
struct JoinChannelView: View {
@Binding var rooms: [ChannelInfo]
@State var selectedRoom: String?
var body: some View {
VStack {
if $rooms.isEmpty {
Text("Loading...")
.transition(.slide)
} else {
List(selection: $selectedRoom) {
ForEach(rooms, id: \.title) { room in
Text(room.title)
.font(.title)
Text(room.description)
.font(.subheadline)
}
.padding(.bottom)
}
}
}
.frame(width: 150, height: 300)
}
}