forked from mirrors/linphone-iphone
Move enteredForeground variable to CoreContext and add a check before using prepareBottomSheetForDeliveryStatus
This commit is contained in:
parent
eaefc50626
commit
54f1c2a27d
8 changed files with 24 additions and 37 deletions
|
|
@ -41,6 +41,7 @@ final class CoreContext: ObservableObject {
|
|||
@Published var loggingInProgress: Bool = false
|
||||
@Published var coreIsStarted: Bool = false
|
||||
@Published var accounts: [AccountModel] = []
|
||||
@Published var enteredForeground = false
|
||||
|
||||
private var mCore: Core!
|
||||
private var mIterateSuscription: AnyCancellable?
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ struct CallView: View {
|
|||
|
||||
@State var buttonSize = 60.0
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
ZStack {
|
||||
|
|
@ -199,8 +197,7 @@ struct CallView: View {
|
|||
conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
conversationForwardMessageViewModel: conversationForwardMessageViewModel,
|
||||
isShowConversationFragment: $isShowConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
isShowConversationFragment: $isShowConversationFragment
|
||||
)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.gray100)
|
||||
|
|
@ -2788,8 +2785,7 @@ struct PressedButtonStyle: ButtonStyle {
|
|||
conversationForwardMessageViewModel: ConversationForwardMessageViewModel(),
|
||||
fullscreenVideo: .constant(false),
|
||||
isShowStartCallFragment: .constant(false),
|
||||
isShowConversationFragment: .constant(false),
|
||||
enteredForeground: .constant(false)
|
||||
isShowConversationFragment: .constant(false)
|
||||
)
|
||||
}
|
||||
// swiftlint:enable type_body_length
|
||||
|
|
|
|||
|
|
@ -75,8 +75,6 @@ struct ContentView: View {
|
|||
@State var isShowScheduleMeetingFragment = false
|
||||
@State private var isShowLoginFragment: Bool = false
|
||||
|
||||
@State private var enteredForeground: Bool = false
|
||||
|
||||
var body: some View {
|
||||
let pub = NotificationCenter.default
|
||||
.publisher(for: NSNotification.Name("ContactLoaded"))
|
||||
|
|
@ -599,8 +597,7 @@ struct ContentView: View {
|
|||
conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
text: $text,
|
||||
isShowStartConversationFragment: $isShowStartConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
isShowStartConversationFragment: $isShowStartConversationFragment
|
||||
)
|
||||
.roundedCorner(25, corners: [.topRight, .topLeft])
|
||||
.shadow(
|
||||
|
|
@ -864,8 +861,7 @@ struct ContentView: View {
|
|||
conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
conversationForwardMessageViewModel: conversationForwardMessageViewModel,
|
||||
isShowConversationFragment: $isShowConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
isShowConversationFragment: $isShowConversationFragment
|
||||
)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.gray100)
|
||||
|
|
@ -1180,8 +1176,7 @@ struct ContentView: View {
|
|||
conversationForwardMessageViewModel: conversationForwardMessageViewModel,
|
||||
fullscreenVideo: $fullscreenVideo,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
isShowConversationFragment: $isShowConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
isShowConversationFragment: $isShowConversationFragment
|
||||
)
|
||||
.zIndex(5)
|
||||
.transition(.scale.combined(with: .move(edge: .top)))
|
||||
|
|
@ -1235,7 +1230,7 @@ struct ContentView: View {
|
|||
orientation = newOrientation
|
||||
}
|
||||
.onChange(of: scenePhase) { newPhase in
|
||||
enteredForeground = newPhase == .active
|
||||
CoreContext.shared.enteredForeground = newPhase == .active
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,10 @@ struct ConversationsView: View {
|
|||
|
||||
@Binding var isShowStartConversationFragment: Bool
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
ConversationsFragment(conversationViewModel: conversationViewModel, conversationsListViewModel: conversationsListViewModel, text: $text, enteredForeground: $enteredForeground)
|
||||
ConversationsFragment(conversationViewModel: conversationViewModel, conversationsListViewModel: conversationsListViewModel, text: $text)
|
||||
|
||||
Button {
|
||||
withAnimation {
|
||||
|
|
@ -64,7 +62,6 @@ struct ConversationsView: View {
|
|||
conversationViewModel: ConversationViewModel(),
|
||||
conversationsListViewModel: ConversationsListViewModel(),
|
||||
showingSheet: .constant(false),
|
||||
text: .constant(""),
|
||||
enteredForeground: .constant(false)
|
||||
text: .constant("")
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import WebKit
|
|||
// swiftlint:disable cyclomatic_complexity
|
||||
struct ChatBubbleView: View {
|
||||
|
||||
@ObservedObject private var sharedMainViewModel = SharedMainViewModel.shared
|
||||
|
||||
@ObservedObject var conversationViewModel: ConversationViewModel
|
||||
|
||||
let eventLogMessage: EventLogMessage
|
||||
|
|
@ -255,8 +257,10 @@ struct ChatBubbleView: View {
|
|||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
conversationViewModel.selectedMessageToDisplayDetails = eventLogMessage
|
||||
conversationViewModel.prepareBottomSheetForDeliveryStatus()
|
||||
if !CoreContext.shared.enteredForeground {
|
||||
conversationViewModel.selectedMessageToDisplayDetails = eventLogMessage
|
||||
conversationViewModel.prepareBottomSheetForDeliveryStatus()
|
||||
}
|
||||
}
|
||||
.disabled(conversationViewModel.selectedMessage != nil)
|
||||
.padding(.top, -4)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ struct ConversationFragment: View {
|
|||
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
|
||||
|
||||
@ObservedObject var contactsManager = ContactsManager.shared
|
||||
@ObservedObject private var sharedMainViewModel = SharedMainViewModel.shared
|
||||
|
||||
@ObservedObject var conversationViewModel: ConversationViewModel
|
||||
@ObservedObject var conversationsListViewModel: ConversationsListViewModel
|
||||
|
|
@ -58,8 +59,6 @@ struct ConversationFragment: View {
|
|||
|
||||
@State private var selectedCategoryIndex = 0
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
GeometryReader { geometry in
|
||||
|
|
@ -575,7 +574,7 @@ struct ConversationFragment: View {
|
|||
.focused($isMessageTextFocused)
|
||||
.padding(.vertical, 5)
|
||||
.onChange(of: conversationViewModel.messageText) { text in
|
||||
if !text.isEmpty && !enteredForeground {
|
||||
if !text.isEmpty && !CoreContext.shared.enteredForeground {
|
||||
conversationViewModel.compose()
|
||||
}
|
||||
}
|
||||
|
|
@ -588,7 +587,7 @@ struct ConversationFragment: View {
|
|||
.default_text_style(styleSize: 15)
|
||||
.focused($isMessageTextFocused)
|
||||
.onChange(of: conversationViewModel.messageText) { text in
|
||||
if !text.isEmpty && !enteredForeground {
|
||||
if !text.isEmpty && !CoreContext.shared.enteredForeground {
|
||||
conversationViewModel.compose()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,11 @@ struct ConversationsFragment: View {
|
|||
@State var showingSheet: Bool = false
|
||||
@Binding var text: String
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
if #available(iOS 16.0, *), idiom != .pad {
|
||||
ConversationsListFragment(conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text, enteredForeground: $enteredForeground)
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text)
|
||||
.sheet(isPresented: $showingSheet) {
|
||||
ConversationsListBottomSheet(
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
|
|
@ -45,7 +43,7 @@ struct ConversationsFragment: View {
|
|||
}
|
||||
} else {
|
||||
ConversationsListFragment(conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text, enteredForeground: $enteredForeground)
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text)
|
||||
.halfSheet(showSheet: $showingSheet) {
|
||||
ConversationsListBottomSheet(
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
|
|
@ -58,5 +56,5 @@ struct ConversationsFragment: View {
|
|||
}
|
||||
|
||||
#Preview {
|
||||
ConversationsFragment(conversationViewModel: ConversationViewModel(), conversationsListViewModel: ConversationsListViewModel(), text: .constant(""), enteredForeground: .constant(false))
|
||||
ConversationsFragment(conversationViewModel: ConversationViewModel(), conversationsListViewModel: ConversationsListViewModel(), text: .constant(""))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ struct ConversationsListFragment: View {
|
|||
@Binding var showingSheet: Bool
|
||||
@Binding var text: String
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
let pub = NotificationCenter.default
|
||||
.publisher(for: NSNotification.Name("ChatRoomsComputed"))
|
||||
|
|
@ -143,14 +141,14 @@ struct ConversationsListFragment: View {
|
|||
.listRowSeparator(.hidden)
|
||||
.background(.white)
|
||||
.onReceive(pub) { _ in
|
||||
if enteredForeground && conversationViewModel.displayedConversation != nil
|
||||
if CoreContext.shared.enteredForeground && conversationViewModel.displayedConversation != nil
|
||||
&& (navigationManager.peerAddr == nil || navigationManager.peerAddr == conversationViewModel.displayedConversation!.remoteSipUri) {
|
||||
if conversationViewModel.displayedConversation != nil {
|
||||
conversationViewModel.resetDisplayedChatRoom(conversationsList: conversationsListViewModel.conversationsList)
|
||||
}
|
||||
}
|
||||
|
||||
enteredForeground = false
|
||||
CoreContext.shared.enteredForeground = false
|
||||
|
||||
if navigationManager.peerAddr != nil
|
||||
&& index < conversationsListViewModel.conversationsList.count
|
||||
|
|
@ -206,7 +204,6 @@ struct ConversationsListFragment: View {
|
|||
conversationViewModel: ConversationViewModel(),
|
||||
conversationsListViewModel: ConversationsListViewModel(),
|
||||
showingSheet: .constant(false),
|
||||
text: .constant(""),
|
||||
enteredForeground: .constant(false)
|
||||
text: .constant("")
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue