Added disclosure groups for rooms and people.

This commit is contained in:
Stefan Ceriu 2022-02-22 14:35:25 +02:00
parent bea929a2ae
commit 1fbdff55fc
2 changed files with 34 additions and 6 deletions

View File

@ -35,12 +35,20 @@ struct HomeScreenViewState: BindableState {
var rooms: [HomeScreenRoom] = []
var isLoadingRooms: Bool = false
var directRooms: [HomeScreenRoom] {
rooms.filter { $0.isDirect }
var firstDirectRooms: [HomeScreenRoom] {
Array(rooms.filter { $0.isDirect }.prefix(upTo: 5))
}
var nondirectRooms: [HomeScreenRoom] {
rooms.filter { !$0.isDirect }
var otherDirectRooms: [HomeScreenRoom] {
Array(rooms.filter { $0.isDirect }.suffix(from: 5))
}
var firstNondirectRooms: [HomeScreenRoom] {
Array(rooms.filter { !$0.isDirect }.prefix(upTo: 5))
}
var otherNondirectRooms: [HomeScreenRoom] {
Array(rooms.filter { !$0.isDirect }.suffix(from: 5))
}
}

View File

@ -50,15 +50,35 @@ struct HomeScreen: View {
} else {
List {
Section("People") {
ForEach(context.viewState.directRooms) { room in
ForEach(context.viewState.firstDirectRooms) { room in
RoomCell(room: room, context: context)
}
let other = context.viewState.otherDirectRooms
if other.count > 0 {
DisclosureGroup("See more") {
ForEach(other) { room in
RoomCell(room: room, context: context)
}
}
}
}
Section("Rooms") {
ForEach(context.viewState.nondirectRooms) { room in
ForEach(context.viewState.firstNondirectRooms) { room in
RoomCell(room: room, context: context)
}
let other = context.viewState.otherNondirectRooms
if other.count > 0 {
DisclosureGroup("See more") {
ForEach(other) { room in
RoomCell(room: room, context: context)
}
}
}
}
}
.headerProminence(.increased)