forked from mirrors/linphone-iphone
Made "enteredForeground" variable accessible to all conversation views and added a check for its value before performing chatroom.compose
This commit is contained in:
parent
764b8f860c
commit
1957fa7b15
6 changed files with 35 additions and 18 deletions
|
|
@ -68,6 +68,8 @@ struct CallView: View {
|
|||
|
||||
@State var buttonSize = 60.0
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
ZStack {
|
||||
|
|
@ -197,7 +199,8 @@ struct CallView: View {
|
|||
conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
conversationForwardMessageViewModel: conversationForwardMessageViewModel,
|
||||
isShowConversationFragment: $isShowConversationFragment
|
||||
isShowConversationFragment: $isShowConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.gray100)
|
||||
|
|
@ -2785,7 +2788,8 @@ struct PressedButtonStyle: ButtonStyle {
|
|||
conversationForwardMessageViewModel: ConversationForwardMessageViewModel(),
|
||||
fullscreenVideo: .constant(false),
|
||||
isShowStartCallFragment: .constant(false),
|
||||
isShowConversationFragment: .constant(false)
|
||||
isShowConversationFragment: .constant(false),
|
||||
enteredForeground: .constant(false)
|
||||
)
|
||||
}
|
||||
// swiftlint:enable type_body_length
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ 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"))
|
||||
|
|
@ -597,7 +599,8 @@ struct ContentView: View {
|
|||
conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
text: $text,
|
||||
isShowStartConversationFragment: $isShowStartConversationFragment
|
||||
isShowStartConversationFragment: $isShowStartConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
)
|
||||
.roundedCorner(25, corners: [.topRight, .topLeft])
|
||||
.shadow(
|
||||
|
|
@ -861,7 +864,8 @@ struct ContentView: View {
|
|||
conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
conversationForwardMessageViewModel: conversationForwardMessageViewModel,
|
||||
isShowConversationFragment: $isShowConversationFragment
|
||||
isShowConversationFragment: $isShowConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color.gray100)
|
||||
|
|
@ -1176,7 +1180,8 @@ struct ContentView: View {
|
|||
conversationForwardMessageViewModel: conversationForwardMessageViewModel,
|
||||
fullscreenVideo: $fullscreenVideo,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
isShowConversationFragment: $isShowConversationFragment
|
||||
isShowConversationFragment: $isShowConversationFragment,
|
||||
enteredForeground: $enteredForeground
|
||||
)
|
||||
.zIndex(5)
|
||||
.transition(.scale.combined(with: .move(edge: .top)))
|
||||
|
|
@ -1229,6 +1234,9 @@ struct ContentView: View {
|
|||
}
|
||||
orientation = newOrientation
|
||||
}
|
||||
.onChange(of: scenePhase) { newPhase in
|
||||
enteredForeground = newPhase == .active
|
||||
}
|
||||
}
|
||||
|
||||
func openMenu() {
|
||||
|
|
|
|||
|
|
@ -27,10 +27,12 @@ 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)
|
||||
ConversationsFragment(conversationViewModel: conversationViewModel, conversationsListViewModel: conversationsListViewModel, text: $text, enteredForeground: $enteredForeground)
|
||||
|
||||
Button {
|
||||
withAnimation {
|
||||
|
|
@ -62,6 +64,7 @@ struct ConversationsView: View {
|
|||
conversationViewModel: ConversationViewModel(),
|
||||
conversationsListViewModel: ConversationsListViewModel(),
|
||||
showingSheet: .constant(false),
|
||||
text: .constant("")
|
||||
text: .constant(""),
|
||||
enteredForeground: .constant(false)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ struct ConversationFragment: View {
|
|||
|
||||
@State private var selectedCategoryIndex = 0
|
||||
|
||||
@Binding var enteredForeground: Bool
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
GeometryReader { geometry in
|
||||
|
|
@ -573,7 +575,7 @@ struct ConversationFragment: View {
|
|||
.focused($isMessageTextFocused)
|
||||
.padding(.vertical, 5)
|
||||
.onChange(of: conversationViewModel.messageText) { text in
|
||||
if !text.isEmpty {
|
||||
if !text.isEmpty && !enteredForeground {
|
||||
conversationViewModel.compose()
|
||||
}
|
||||
}
|
||||
|
|
@ -586,7 +588,7 @@ struct ConversationFragment: View {
|
|||
.default_text_style(styleSize: 15)
|
||||
.focused($isMessageTextFocused)
|
||||
.onChange(of: conversationViewModel.messageText) { text in
|
||||
if !text.isEmpty {
|
||||
if !text.isEmpty && !enteredForeground {
|
||||
conversationViewModel.compose()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ 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)
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text, enteredForeground: $enteredForeground)
|
||||
.sheet(isPresented: $showingSheet) {
|
||||
ConversationsListBottomSheet(
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
|
|
@ -43,7 +45,7 @@ struct ConversationsFragment: View {
|
|||
}
|
||||
} else {
|
||||
ConversationsListFragment(conversationViewModel: conversationViewModel,
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text)
|
||||
conversationsListViewModel: conversationsListViewModel, showingSheet: $showingSheet, text: $text, enteredForeground: $enteredForeground)
|
||||
.halfSheet(showSheet: $showingSheet) {
|
||||
ConversationsListBottomSheet(
|
||||
conversationsListViewModel: conversationsListViewModel,
|
||||
|
|
@ -56,5 +58,5 @@ struct ConversationsFragment: View {
|
|||
}
|
||||
|
||||
#Preview {
|
||||
ConversationsFragment(conversationViewModel: ConversationViewModel(), conversationsListViewModel: ConversationsListViewModel(), text: .constant(""))
|
||||
ConversationsFragment(conversationViewModel: ConversationViewModel(), conversationsListViewModel: ConversationsListViewModel(), text: .constant(""), enteredForeground: .constant(false))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ import linphonesw
|
|||
struct ConversationsListFragment: View {
|
||||
|
||||
@EnvironmentObject var navigationManager: NavigationManager
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
@State private var enteredForeground: Bool = false
|
||||
|
||||
@ObservedObject var conversationViewModel: ConversationViewModel
|
||||
@ObservedObject var conversationsListViewModel: ConversationsListViewModel
|
||||
|
|
@ -32,6 +30,8 @@ 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"))
|
||||
|
|
@ -198,9 +198,6 @@ struct ConversationsListFragment: View {
|
|||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.onChange(of: scenePhase) { newPhase in
|
||||
enteredForeground = newPhase == .active
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +206,7 @@ struct ConversationsListFragment: View {
|
|||
conversationViewModel: ConversationViewModel(),
|
||||
conversationsListViewModel: ConversationsListViewModel(),
|
||||
showingSheet: .constant(false),
|
||||
text: .constant("")
|
||||
text: .constant(""),
|
||||
enteredForeground: .constant(false)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue