Add transfer call feature

This commit is contained in:
Benoit Martins 2024-01-25 13:57:57 +01:00 committed by benoit.martins
parent d91aa94c9a
commit 4048fa3075
5 changed files with 48 additions and 11 deletions

View file

@ -187,6 +187,9 @@
}
}
}
},
"Attended transfer" : {
},
"Block the address" : {
@ -567,6 +570,9 @@
},
"Transfer" : {
},
"Transfer call to" : {
},
"Transport" : {

View file

@ -741,19 +741,23 @@ struct CallView: View {
HStack(spacing: 0) {
VStack {
Button {
withAnimation {
callViewModel.isTransferInsteadCall = true
MagicSearchSingleton.shared.searchForSuggestions()
isShowStartCallFragment.toggle()
}
} label: {
Image("phone-transfer")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.gray500)
.foregroundStyle(.white)
.frame(width: 32, height: 32)
}
.frame(width: 60, height: 60)
.background(Color.gray600)
.background(Color.gray500)
.cornerRadius(40)
.disabled(true)
Text("Transfer")
Text(callViewModel.calls.count < 2 ? "Transfer" : "Attended transfer")
.foregroundStyle(.white)
.default_text_style(styleSize: 15)
}
@ -942,19 +946,23 @@ struct CallView: View {
HStack {
VStack {
Button {
withAnimation {
callViewModel.isTransferInsteadCall = true
MagicSearchSingleton.shared.searchForSuggestions()
isShowStartCallFragment.toggle()
}
} label: {
Image("phone-transfer")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.gray500)
.foregroundStyle(.white)
.frame(width: 32, height: 32)
}
.frame(width: 60, height: 60)
.background(Color.gray600)
.background(Color.gray500)
.cornerRadius(40)
.disabled(true)
Text("Transfer")
Text(callViewModel.calls.count < 2 ? "Transfer" : "Attended transfer")
.foregroundStyle(.white)
.default_text_style(styleSize: 15)
}

View file

@ -44,6 +44,7 @@ class CallViewModel: ObservableObject {
@Published var isZrtpPq: Bool = false
@Published var isRemoteDeviceTrusted: Bool = false
@Published var selectedCall: Call? = nil
@Published var isTransferInsteadCall: Bool = false
var calls: [Call] = []

View file

@ -524,6 +524,7 @@ struct ContentView: View {
if isShowStartCallFragment {
if #available(iOS 16.4, *), idiom != .pad {
StartCallFragment(
callViewModel: callViewModel,
startCallViewModel: startCallViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,
@ -538,11 +539,11 @@ struct ContentView: View {
currentCall: nil
)
.presentationDetents([.medium])
// .interactiveDismissDisabled()
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
}
} else {
StartCallFragment(
callViewModel: callViewModel,
startCallViewModel: startCallViewModel,
isShowStartCallFragment: $isShowStartCallFragment,
showingDialer: $showingDialer,

View file

@ -26,6 +26,7 @@ struct StartCallFragment: View {
@ObservedObject var magicSearch = MagicSearchSingleton.shared
@ObservedObject private var telecomManager = TelecomManager.shared
@ObservedObject var callViewModel: CallViewModel
@ObservedObject var startCallViewModel: StartCallViewModel
@Binding var isShowStartCallFragment: Bool
@ -59,6 +60,12 @@ struct StartCallFragment: View {
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
}
resetCallView()
}
startCallViewModel.searchField = ""
@ -69,7 +76,7 @@ struct StartCallFragment: View {
}
}
Text("New call")
Text(!callViewModel.isTransferInsteadCall ? "New call" : "Transfer call to")
.multilineTextAlignment(.leading)
.default_text_style_orange_800(styleSize: 16)
@ -176,6 +183,10 @@ struct StartCallFragment: View {
magicSearch.searchForContacts(
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
if callViewModel.isTransferInsteadCall == true {
callViewModel.isTransferInsteadCall = false
}
resetCallView()
}
@ -230,6 +241,10 @@ struct StartCallFragment: View {
magicSearch.searchForContacts(
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
if callViewModel.isTransferInsteadCall == true {
callViewModel.isTransferInsteadCall = false
}
resetCallView()
}
@ -283,5 +298,11 @@ struct StartCallFragment: View {
}
#Preview {
StartCallFragment(startCallViewModel: StartCallViewModel(), isShowStartCallFragment: .constant(true), showingDialer: .constant(false), resetCallView: {})
StartCallFragment(
callViewModel: CallViewModel(),
startCallViewModel: StartCallViewModel(),
isShowStartCallFragment: .constant(true),
showingDialer: .constant(false),
resetCallView: {}
)
}