message button to open chat

This commit is contained in:
spaced4ndy
2024-05-07 19:07:42 +04:00
parent 24a78782f7
commit 692680d1e9
3 changed files with 9 additions and 3 deletions
@@ -103,6 +103,7 @@ enum ContactDeleteMode {
struct ChatInfoView: View {
@EnvironmentObject var chatModel: ChatModel
@Environment(\.dismiss) var dismiss: DismissAction
var openedFromChatView: Bool
@ObservedObject var chat: Chat
@State var contact: Contact
@State var localAlias: String
@@ -401,8 +402,11 @@ struct ChatInfoView: View {
private func messageButton() -> some View {
Button {
dismiss()
chatModel.chatId = chat.id
if openedFromChatView {
dismiss()
} else {
chatModel.chatId = chat.id
}
} label: {
actionButton("message.fill", "message")
}
@@ -689,6 +693,7 @@ func syncConnectionForceAlert(_ syncConnectionForce: @escaping () -> Void) -> Al
struct ChatInfoView_Previews: PreviewProvider {
static var previews: some View {
ChatInfoView(
openedFromChatView: true,
chat: Chat(chatInfo: ChatInfo.sampleData.direct, chatItems: []),
contact: Contact.sampleData,
localAlias: ""
+1 -1
View File
@@ -113,7 +113,7 @@ struct ChatView: View {
ChatInfoToolbar(chat: chat)
}
.sheet(isPresented: $showChatInfoSheet) {
ChatInfoView(chat: chat, contact: contact, localAlias: chat.chatInfo.localAlias)
ChatInfoView(openedFromChatView: true, chat: chat, contact: contact, localAlias: chat.chatInfo.localAlias)
}
} else if case let .group(groupInfo) = cInfo {
Button {
@@ -31,6 +31,7 @@ struct ContactListNavLink: View {
case let .direct(contact):
NavigationLink {
ChatInfoView(
openedFromChatView: false,
chat: chat,
contact: contact,
localAlias: chat.chatInfo.localAlias