ChatListView.swift 717 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // ChatListView.swift
  3. // Chat
  4. //
  5. // Created by Sergey Tarasov on 24.07.2022.
  6. //
  7. import SwiftUI
  8. import XMPPFramework
  9. import XMPPFrameworkSwift
  10. struct ChatListView: View {
  11. @StateObject var store: ChatListStore = ChatListStore()
  12. var body: some View {
  13. Group {
  14. if store.users.isEmpty {
  15. ProgressView()
  16. } else {
  17. List(store.users.indices, id: \.self) { index in
  18. ChatListCellView(
  19. nickname: store.nicknames[index],
  20. jid: store.users[index].id
  21. )
  22. }
  23. .listStyle(.plain)
  24. }
  25. }
  26. .onAppear {
  27. store.fetchChatList()
  28. }
  29. }
  30. }
  31. struct ChatListView_Previews: PreviewProvider {
  32. static var previews: some View {
  33. NavigationView {
  34. ChatListView()
  35. }
  36. }
  37. }