mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
53040dbe1d
* iOS: chats and messages layout * model update for updated API * improve chat list view * chat view layouts * delete contacts * larger headers, clean up, move message reception loop to ContentView * settings: user profile
56 lines
1.5 KiB
Swift
56 lines
1.5 KiB
Swift
//
|
|
// ChatHeaderView.swift
|
|
// SimpleX
|
|
//
|
|
// Created by Evgeny Poberezkin on 29/01/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ChatHeaderView: View {
|
|
@Binding var chatId: String?
|
|
@EnvironmentObject var chatModel: ChatModel
|
|
|
|
var body: some View {
|
|
HStack {
|
|
if let cId = chatId {
|
|
Button { chatId = nil } label: { Image(systemName: "chevron.backward") }
|
|
Spacer()
|
|
Text(chatModel.chats[cId]?.chatInfo.localDisplayName ?? "")
|
|
.font(.title3)
|
|
Spacer()
|
|
EmptyView()
|
|
} else {
|
|
SettingsButton()
|
|
Spacer()
|
|
Text("Your chats")
|
|
.font(.title3)
|
|
Spacer()
|
|
NewChatButton()
|
|
}
|
|
}
|
|
.padding([.horizontal, .top])
|
|
}
|
|
}
|
|
|
|
struct ChatHeaderView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
@State var chatId1: String? = "@1"
|
|
@State var chatId2: String?
|
|
let chatModel = ChatModel()
|
|
chatModel.chats = [
|
|
"@1": Chat(
|
|
chatInfo: sampleDirectChatInfo,
|
|
chatItems: [chatItemSample(1, .directSnd, Date.now, "hello")]
|
|
)
|
|
]
|
|
return Group {
|
|
ChatHeaderView(chatId: $chatId1)
|
|
ChatHeaderView(chatId: $chatId2)
|
|
}
|
|
.previewLayout(.fixed(width: 300, height: 70))
|
|
.environmentObject(chatModel)
|
|
}
|
|
}
|