62 lines
1.8 KiB
Swift
62 lines
1.8 KiB
Swift
import SwiftUI
|
|
|
|
struct ChatsListScreen: View {
|
|
@EnvironmentObject var store: AppStore
|
|
|
|
@State private var isCretePanelPresented = false
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
// Background color
|
|
Color.Material.Background.light
|
|
.ignoresSafeArea()
|
|
|
|
// Content
|
|
VStack(spacing: 0) {
|
|
// Header
|
|
SharedNavigationBar(
|
|
centerText: .init(text: L10n.Chats.title),
|
|
rightButton: .init(
|
|
image: Image(systemName: "square.and.pencil"),
|
|
action: {
|
|
isCretePanelPresented = true
|
|
}
|
|
)
|
|
)
|
|
|
|
// Chats list
|
|
if !store.state.chatsState.chats.isEmpty {
|
|
List {
|
|
ForEach(store.state.chatsState.chats) { chat in
|
|
ChatsRow(chat: chat)
|
|
}
|
|
}
|
|
.listStyle(.plain)
|
|
.background(Color.Material.Background.light)
|
|
} else {
|
|
Spacer()
|
|
}
|
|
|
|
// Tab bar
|
|
SharedTabBar()
|
|
}
|
|
}
|
|
.fullScreenCover(isPresented: $isCretePanelPresented) {
|
|
ChatsCreateMainScreen(isPresented: $isCretePanelPresented)
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct ChatsRow: View {
|
|
@EnvironmentObject var store: AppStore
|
|
|
|
var chat: Chat
|
|
|
|
var body: some View {
|
|
SharedListRow(iconType: .charCircle(chat.participant), text: chat.participant)
|
|
.onTapGesture {
|
|
store.dispatch(.chatsAction(.startChat(accountJid: chat.account, participantJid: chat.participant)))
|
|
}
|
|
}
|
|
}
|