From 22de79505c19fd89c593610d04067ff0c8e1e622 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Mon, 23 Jan 2023 14:02:31 +0300 Subject: [PATCH] enable swipe to go back from ChatView --- apps/ios/Shared/Views/Chat/ChatView.swift | 28 ++++++++----------- .../Shared/Views/ChatList/ChatListView.swift | 4 ++- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 68ab7c191d..062e41f3ea 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -63,7 +63,6 @@ struct ChatView: View { .padding(.top, 1) .navigationTitle(cInfo.chatViewName) .navigationBarTitleDisplayMode(.inline) - .navigationBarBackButtonHidden(true) .onAppear { if chat.chatStats.unreadChat { Task { @@ -71,25 +70,20 @@ struct ChatView: View { } } } - .onChange(of: chatModel.chatId) { _ in - if chatModel.chatId == nil { dismiss() } - } - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - Button { - chatModel.chatId = nil - DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) { - if chatModel.chatId == nil { - chatModel.reversedChatItems = [] - } - } - } label: { - HStack(spacing: 0) { - Image(systemName: "chevron.backward") - Text("Chats") + .onChange(of: chatModel.chatId) { _ in + if chatModel.chatId == nil { dismiss() } + } + .onDisappear { + if chatModel.chatId == cInfo.id { + chatModel.chatId = nil + DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) { + if chatModel.chatId == nil { + chatModel.reversedChatItems = [] } } } + } + .toolbar { ToolbarItem(placement: .principal) { if case let .direct(contact) = cInfo { Button { diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 8b3c9dadf0..485b7fb5fd 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -49,7 +49,7 @@ struct ChatListView: View { .onAppear() { connectViaUrl() } .offset(x: -8) .listStyle(.plain) - .navigationTitle("Your chats") + .navigationTitle("Chats") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { @@ -64,6 +64,8 @@ struct ChatListView: View { } Image(systemName: "theatermasks").frame(maxWidth: 24, maxHeight: 24, alignment: .center).foregroundColor(.indigo) } + } else { + Text("Your chats").font(.headline) } } ToolbarItem(placement: .navigationBarTrailing) {