Fix dialer in startcallview

This commit is contained in:
Benoit Martins 2024-07-03 09:38:17 +02:00
parent b5e3f72cf6
commit 4884997db6
5 changed files with 78 additions and 5 deletions

View file

@ -850,6 +850,9 @@
},
"Delete this contact" : {
},
"Delete this meeting" : {
},
"Demande dautorisations" : {
@ -1424,6 +1427,9 @@
},
"Send Logs" : {
},
"Send notification to participants ?" : {
},
"settings_title" : {
"extractionState" : "manual",
@ -1471,6 +1477,9 @@
},
"subscribe.linphone.org" : {
},
"Successfully removed meeting" : {
},
"Suggestions" : {
@ -1486,6 +1495,9 @@
},
"Temp Help" : {
},
"The meeting has been cancelled" : {
},
"The user name or password is incorrects" : {

View file

@ -93,6 +93,8 @@ struct CallView: View {
.sheet(isPresented: $showingDialer) {
DialerBottomSheet(
startCallViewModel: StartCallViewModel(),
callViewModel: callViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,
currentCall: callViewModel.currentCall
)
@ -128,6 +130,8 @@ struct CallView: View {
.sheet(isPresented: $showingDialer) {
DialerBottomSheet(
startCallViewModel: StartCallViewModel(),
callViewModel: callViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,
currentCall: callViewModel.currentCall
)
@ -158,6 +162,8 @@ struct CallView: View {
.halfSheet(showSheet: $showingDialer) {
DialerBottomSheet(
startCallViewModel: StartCallViewModel(),
callViewModel: callViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,
currentCall: callViewModel.currentCall
)

View file

@ -852,6 +852,8 @@ struct ContentView: View {
.sheet(isPresented: $showingDialer) {
DialerBottomSheet(
startCallViewModel: startCallViewModel,
callViewModel: callViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,
currentCall: nil
)
@ -871,6 +873,8 @@ struct ContentView: View {
.halfSheet(showSheet: $showingDialer) {
DialerBottomSheet(
startCallViewModel: startCallViewModel,
callViewModel: callViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,
currentCall: nil
)

View file

@ -33,10 +33,13 @@ struct DialerBottomSheet: View {
@ObservedObject private var telecomManager = TelecomManager.shared
@ObservedObject var startCallViewModel: StartCallViewModel
@ObservedObject var callViewModel: CallViewModel
@State private var orientation = UIDevice.current.orientation
@State var dialerField = ""
@Binding var isShowStartCallFragment: Bool
@Binding var showingDialer: Bool
let currentCall: Call?
@ -449,11 +452,50 @@ struct DialerBottomSheet: View {
Button {
if !startCallViewModel.searchField.isEmpty {
do {
let address = try Factory.Instance.createAddress(addr: String("sip:" + startCallViewModel.searchField + "@" + startCallViewModel.domain))
telecomManager.doCallOrJoinConf(address: address)
} catch {
if callViewModel.isTransferInsteadCall {
showingDialer = false
DispatchQueue.global().asyncAfter(deadline: .now() + 0.2) {
magicSearch.searchForContacts(
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
if callViewModel.isTransferInsteadCall == true {
callViewModel.isTransferInsteadCall = false
}
callViewModel.resetCallView()
}
magicSearch.currentFilterSuggestions = ""
withAnimation {
isShowStartCallFragment.toggle()
startCallViewModel.interpretAndStartCall()
}
startCallViewModel.searchField = ""
} else {
showingDialer = false
DispatchQueue.global().asyncAfter(deadline: .now() + 0.2) {
magicSearch.searchForContacts(
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
if callViewModel.isTransferInsteadCall == true {
callViewModel.isTransferInsteadCall = false
}
callViewModel.resetCallView()
}
magicSearch.currentFilterSuggestions = ""
withAnimation {
isShowStartCallFragment.toggle()
startCallViewModel.interpretAndStartCall()
}
startCallViewModel.searchField = ""
}
}
} label: {
@ -502,6 +544,6 @@ struct DialerBottomSheet: View {
#Preview {
DialerBottomSheet(
startCallViewModel: StartCallViewModel(), showingDialer: .constant(false), currentCall: nil
startCallViewModel: StartCallViewModel(), callViewModel: CallViewModel(), isShowStartCallFragment: .constant(false), showingDialer: .constant(false), currentCall: nil
)
}

View file

@ -161,4 +161,13 @@ class StartCallViewModel: ObservableObject {
)
}
}
func interpretAndStartCall() {
CoreContext.shared.doOnCoreQueue { core in
let address = core.interpretUrl(url: self.searchField, applyInternationalPrefix: true)
if address != nil {
TelecomManager.shared.doCallOrJoinConf(address: address!)
}
}
}
}