wip
This commit is contained in:
parent
9909611674
commit
d6f08ca691
|
@ -211,6 +211,13 @@ private extension ClientsStore {
|
|||
.catch { _ in Just([]) }
|
||||
.sink { [weak self] rosters in
|
||||
self?.actualRosters = rosters
|
||||
.sorted {
|
||||
if $0.bareJid != $1.bareJid {
|
||||
return $0.bareJid < $1.bareJid
|
||||
} else {
|
||||
return $0.contactBareJid < $1.contactBareJid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,20 +26,46 @@ struct ContactsScreen: View {
|
|||
)
|
||||
|
||||
// Contacts list
|
||||
if !clientsStore.actualRosters.isEmpty {
|
||||
List {
|
||||
ForEach(clientsStore.actualRosters) { roster in
|
||||
ContactsScreenRow(
|
||||
roster: roster
|
||||
)
|
||||
}
|
||||
contactsList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder private var contactsList: some View {
|
||||
if !clientsStore.actualRosters.isEmpty {
|
||||
List {
|
||||
ForEach(elements.indices, id: \.self) { index in
|
||||
let element = elements[index]
|
||||
if let roster = element as? Roster {
|
||||
ContactsScreenRow(
|
||||
roster: roster
|
||||
)
|
||||
} else if let bareJid = element as? String {
|
||||
SharedSectionTitle(text: bareJid)
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.background(Color.Material.Background.light)
|
||||
} else {
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.background(Color.Material.Background.light)
|
||||
} else {
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
private var elements: [Any] {
|
||||
if clientsStore.clients.filter({ $0.credentials.isActive }).count == 1 {
|
||||
return clientsStore.actualRosters
|
||||
} else {
|
||||
var result: [Any] = []
|
||||
for roster in clientsStore.actualRosters {
|
||||
if result.isEmpty {
|
||||
result.append(roster.bareJid)
|
||||
} else if let last = result.last as? Roster, last.bareJid != roster.bareJid {
|
||||
result.append(roster.bareJid)
|
||||
}
|
||||
result.append(roster)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue