From 0d8c179861bfde461725e3f493c40c310dfde84d Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Fri, 11 Oct 2024 01:08:03 +0700 Subject: [PATCH] ios: fix not showing link creation and add group members pages (#5020) --- apps/ios/Shared/Views/Chat/ChatView.swift | 11 ++++++++--- apps/ios/Shared/Views/NewChat/NewChatMenuButton.swift | 5 +++-- apps/ios/Shared/Views/NewChat/NewChatView.swift | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 7f6b61c1ea..3e056fa581 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -137,6 +137,14 @@ struct ChatView: View { } } } + // it should be presented on top level in order to prevent a bug in SwiftUI on iOS 16 related to .focused() modifier in AddGroupMembersView's search field + .appSheet(isPresented: $showAddMembersSheet) { + Group { + if case let .group(groupInfo) = cInfo { + AddGroupMembersView(chat: chat, groupInfo: groupInfo) + } + } + } .sheet(isPresented: Binding( get: { !forwardedChatItems.isEmpty }, set: { isPresented in @@ -304,9 +312,6 @@ struct ChatView: View { } } else { addMembersButton() - .appSheet(isPresented: $showAddMembersSheet) { - AddGroupMembersView(chat: chat, groupInfo: groupInfo) - } } } Menu { diff --git a/apps/ios/Shared/Views/NewChat/NewChatMenuButton.swift b/apps/ios/Shared/Views/NewChat/NewChatMenuButton.swift index 051b1158ec..3ca3e0e4d8 100644 --- a/apps/ios/Shared/Views/NewChat/NewChatMenuButton.swift +++ b/apps/ios/Shared/Views/NewChat/NewChatMenuButton.swift @@ -14,7 +14,8 @@ enum ContactType: Int { } struct NewChatMenuButton: View { - @EnvironmentObject var chatModel: ChatModel + // do not use chatModel here because it prevents showing AddGroupMembersView after group creation and QR code after link creation on iOS 16 +// @EnvironmentObject var chatModel: ChatModel @State private var showNewChatSheet = false @State private var alert: SomeAlert? = nil @State private var pendingConnection: PendingContactConnection? = nil @@ -32,7 +33,7 @@ struct NewChatMenuButton: View { NewChatSheet(pendingConnection: $pendingConnection) .environment(\EnvironmentValues.refresh as! WritableKeyPath, nil) .onDisappear { - alert = cleanupPendingConnection(chatModel: chatModel, contactConnection: pendingConnection) + alert = cleanupPendingConnection(contactConnection: pendingConnection) pendingConnection = nil } } diff --git a/apps/ios/Shared/Views/NewChat/NewChatView.swift b/apps/ios/Shared/Views/NewChat/NewChatView.swift index 5ff680d5f3..4ca33e674d 100644 --- a/apps/ios/Shared/Views/NewChat/NewChatView.swift +++ b/apps/ios/Shared/Views/NewChat/NewChatView.swift @@ -45,10 +45,10 @@ enum NewChatOption: Identifiable { var id: Self { self } } -func cleanupPendingConnection(chatModel: ChatModel, contactConnection: PendingContactConnection?) -> SomeAlert? { +func cleanupPendingConnection(contactConnection: PendingContactConnection?) -> SomeAlert? { var alert: SomeAlert? = nil - if !(chatModel.showingInvitation?.connChatUsed ?? true), + if !(ChatModel.shared.showingInvitation?.connChatUsed ?? true), let conn = contactConnection { alert = SomeAlert( alert: Alert( @@ -68,7 +68,7 @@ func cleanupPendingConnection(chatModel: ChatModel, contactConnection: PendingCo ) } - chatModel.showingInvitation = nil + ChatModel.shared.showingInvitation = nil return alert } @@ -157,7 +157,7 @@ struct NewChatView: View { } .onDisappear { if !choosingProfile { - parentAlert = cleanupPendingConnection(chatModel: m, contactConnection: contactConnection) + parentAlert = cleanupPendingConnection(contactConnection: contactConnection) contactConnection = nil } }