another.im-ios/ConversationsClassic/View/Screens/Chats/ChatsListScreen.swift

62 lines
1.8 KiB
Swift
Raw Normal View History

2024-06-19 15:15:27 +00:00
import SwiftUI
struct ChatsListScreen: View {
@EnvironmentObject var store: AppStore
2024-08-07 15:13:43 +00:00
@State private var isCretePanelPresented = false
2024-06-19 15:15:27 +00:00
var body: some View {
ZStack {
// Background color
2024-07-04 08:21:12 +00:00
Color.Material.Background.light
2024-06-19 15:15:27 +00:00
.ignoresSafeArea()
// Content
VStack(spacing: 0) {
// Header
2024-08-07 08:36:33 +00:00
SharedNavigationBar(
2024-08-07 09:19:53 +00:00
centerText: .init(text: L10n.Chats.title),
rightButton: .init(
2024-08-07 08:36:33 +00:00
image: Image(systemName: "square.and.pencil"),
action: {
2024-08-07 15:13:43 +00:00
isCretePanelPresented = true
2024-08-07 08:36:33 +00:00
}
)
)
2024-06-19 15:15:27 +00:00
// Chats list
if !store.state.chatsState.chats.isEmpty {
List {
ForEach(store.state.chatsState.chats) { chat in
ChatsRow(chat: chat)
}
}
.listStyle(.plain)
2024-07-04 08:21:12 +00:00
.background(Color.Material.Background.light)
2024-06-19 15:15:27 +00:00
} else {
Spacer()
}
// Tab bar
SharedTabBar()
}
}
2024-08-07 15:13:43 +00:00
.fullScreenCover(isPresented: $isCretePanelPresented) {
ChatsCreateMainScreen(isPresented: $isCretePanelPresented)
}
2024-06-19 15:15:27 +00:00
}
}
private struct ChatsRow: View {
@EnvironmentObject var store: AppStore
var chat: Chat
var body: some View {
2024-08-07 19:07:39 +00:00
SharedListRow(iconType: .charCircle(chat.participant), text: chat.participant)
.onTapGesture {
store.dispatch(.chatsAction(.startChat(accountJid: chat.account, participantJid: chat.participant)))
2024-06-19 15:15:27 +00:00
}
}
}