mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-04 01:41:43 +00:00
call buttons work from sheet
This commit is contained in:
@@ -107,6 +107,7 @@ struct ChatInfoView: View {
|
||||
@ObservedObject var chat: Chat
|
||||
@State var contact: Contact
|
||||
@State var localAlias: String
|
||||
@Binding var makeCall: CallMediaType?
|
||||
@State private var connectionStats: ConnectionStats? = nil
|
||||
@State private var customUserProfile: Profile? = nil
|
||||
@State private var connectionCode: String? = nil
|
||||
@@ -415,7 +416,13 @@ struct ChatInfoView: View {
|
||||
|
||||
private func callButton() -> some View {
|
||||
Button {
|
||||
|
||||
if openedFromChatView {
|
||||
dismiss()
|
||||
makeCall = .audio
|
||||
} else {
|
||||
chatModel.chatId = chat.id
|
||||
}
|
||||
// CallController.shared.startCall(contact, .audio)
|
||||
} label: {
|
||||
actionButton("phone.fill", "call")
|
||||
}
|
||||
@@ -424,7 +431,13 @@ struct ChatInfoView: View {
|
||||
|
||||
private func videoButton() -> some View {
|
||||
Button {
|
||||
|
||||
if openedFromChatView {
|
||||
dismiss()
|
||||
makeCall = .video
|
||||
} else {
|
||||
chatModel.chatId = chat.id
|
||||
}
|
||||
// CallController.shared.startCall(contact, .video)
|
||||
} label: {
|
||||
actionButton("video.fill", "video")
|
||||
}
|
||||
@@ -699,7 +712,8 @@ struct ChatInfoView_Previews: PreviewProvider {
|
||||
openedFromChatView: true,
|
||||
chat: Chat(chatInfo: ChatInfo.sampleData.direct, chatItems: []),
|
||||
contact: Contact.sampleData,
|
||||
localAlias: ""
|
||||
localAlias: "",
|
||||
makeCall: Binding.constant(nil)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ struct ChatView: View {
|
||||
@State private var showAddMembersSheet: Bool = false
|
||||
@State private var composeState = ComposeState()
|
||||
@State private var keyboardVisible = false
|
||||
@State private var makeCall: CallMediaType? = nil
|
||||
@State private var tableView: UITableView?
|
||||
@State private var loadingItems = false
|
||||
@State private var firstPage = false
|
||||
@@ -90,6 +91,15 @@ struct ChatView: View {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
.onChange(of: makeCall) { callMedia in
|
||||
if let callMedia = callMedia {
|
||||
switch cInfo {
|
||||
case let .direct(contact): CallController.shared.startCall(contact, callMedia)
|
||||
default: ()
|
||||
}
|
||||
}
|
||||
makeCall = nil
|
||||
}
|
||||
.onDisappear {
|
||||
VideoPlayerView.players.removeAll()
|
||||
if chatModel.chatId == cInfo.id && !presentationMode.wrappedValue.isPresented {
|
||||
@@ -113,7 +123,13 @@ struct ChatView: View {
|
||||
ChatInfoToolbar(chat: chat)
|
||||
}
|
||||
.sheet(isPresented: $showChatInfoSheet) {
|
||||
ChatInfoView(openedFromChatView: true, chat: chat, contact: contact, localAlias: chat.chatInfo.localAlias)
|
||||
ChatInfoView(
|
||||
openedFromChatView: true,
|
||||
chat: chat,
|
||||
contact: contact,
|
||||
localAlias: chat.chatInfo.localAlias,
|
||||
makeCall: $makeCall
|
||||
)
|
||||
}
|
||||
} else if case let .group(groupInfo) = cInfo {
|
||||
Button {
|
||||
|
||||
@@ -34,7 +34,8 @@ struct ContactListNavLink: View {
|
||||
openedFromChatView: false,
|
||||
chat: chat,
|
||||
contact: contact,
|
||||
localAlias: chat.chatInfo.localAlias
|
||||
localAlias: chat.chatInfo.localAlias,
|
||||
makeCall: Binding.constant(nil)
|
||||
)
|
||||
} label: {
|
||||
HStack{
|
||||
|
||||
Reference in New Issue
Block a user