mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Fix dial plan selector and dial plan default
This commit is contained in:
parent
4cf1dbd8b5
commit
3b2ce2ed4b
7 changed files with 36 additions and 34 deletions
|
|
@ -216,12 +216,6 @@ class CoreContext: ObservableObject {
|
|||
newParams?.pushNotificationConfig?.provider = "apns" + pushEnvironment
|
||||
}
|
||||
|
||||
if account.params?.internationalPrefix == nil {
|
||||
Log.info("Account \(account.displayName()): no international prefix set, adding 33 FRA by default: \(account.params?.internationalPrefix ?? "NIL")")
|
||||
newParams?.internationalPrefix = "33"
|
||||
newParams?.internationalPrefixIsoCountryCode = "FRA"
|
||||
newParams?.useInternationalPrefixForCallsAndChats = true
|
||||
}
|
||||
account.params = newParams
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ struct LoginFragment: View {
|
|||
.foregroundStyle(Color.grayMain2c700)
|
||||
.padding(.horizontal, 10)
|
||||
|
||||
NavigationLink(destination: RegisterFragment(registerViewModel: RegisterViewModel()), isActive: $isLinkREGActive, label: { Text("assistant_account_register")
|
||||
NavigationLink(destination: RegisterFragment(), isActive: $isLinkREGActive, label: { Text("assistant_account_register")
|
||||
.default_text_style_white_600(styleSize: 20)
|
||||
.frame(height: 35)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
import SwiftUI
|
||||
|
||||
struct RegisterFragment: View {
|
||||
|
||||
@ObservedObject var registerViewModel: RegisterViewModel
|
||||
@ObservedObject var sharedMainViewModel = SharedMainViewModel.shared
|
||||
|
||||
@StateObject private var registerViewModel = RegisterViewModel()
|
||||
|
||||
@StateObject private var keyboard = KeyboardResponder()
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
|
@ -271,13 +271,13 @@ struct RegisterFragment: View {
|
|||
})
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 10)
|
||||
.background((registerViewModel.username.isEmpty || registerViewModel.phoneNumber.isEmpty || registerViewModel.passwd.isEmpty) ? Color.orangeMain100 : Color.orangeMain500)
|
||||
.background((registerViewModel.username.isEmpty || registerViewModel.dialPlanValueSelected == "---" || registerViewModel.phoneNumber.isEmpty || registerViewModel.passwd.isEmpty) ? Color.orangeMain100 : Color.orangeMain500)
|
||||
.cornerRadius(60)
|
||||
.disabled(!registerViewModel.isLinkActive)
|
||||
.padding(.bottom)
|
||||
.simultaneousGesture(
|
||||
TapGesture().onEnded {
|
||||
if !(registerViewModel.username.isEmpty || registerViewModel.phoneNumber.isEmpty || registerViewModel.passwd.isEmpty) {
|
||||
if !(registerViewModel.username.isEmpty || registerViewModel.dialPlanValueSelected == "---" || registerViewModel.phoneNumber.isEmpty || registerViewModel.passwd.isEmpty) {
|
||||
withAnimation {
|
||||
self.isShowPopup = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,10 +129,6 @@ class AccountLoginViewModel: ObservableObject {
|
|||
#endif
|
||||
accountParams.pushNotificationConfig?.provider = "apns" + pushEnvironment
|
||||
|
||||
accountParams.internationalPrefix = "33"
|
||||
accountParams.internationalPrefixIsoCountryCode = "FRA"
|
||||
accountParams.useInternationalPrefixForCallsAndChats = true
|
||||
|
||||
self.mCoreDelegate = CoreDelegateStub(onAccountRegistrationStateChanged: { (core: Core, account: Account, state: RegistrationState, message: String) in
|
||||
|
||||
Log.info("New registration state is \(state) for user id " +
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class RegisterViewModel: ObservableObject {
|
|||
@Published var displayName: String = ""
|
||||
@Published var transportType: String = "TLS"
|
||||
|
||||
@Published var dialPlanValueSelected: String = "🇫🇷 +33"
|
||||
@Published var dialPlanValueSelected: String = "---"
|
||||
|
||||
private let HASHALGORITHM = "SHA-256"
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ class RegisterViewModel: ObservableObject {
|
|||
|
||||
SharedMainViewModel.shared.dialPlansList.forEach { dial in
|
||||
let countryCode = dialPlanValueSelected.components(separatedBy: "+")
|
||||
if dial.countryCallingCode == countryCode[1] {
|
||||
if dial?.countryCallingCode == countryCode[1] {
|
||||
dialPlan = dial
|
||||
}
|
||||
}
|
||||
|
|
@ -412,7 +412,7 @@ class RegisterViewModel: ObservableObject {
|
|||
|
||||
for dial in SharedMainViewModel.shared.dialPlansList {
|
||||
let countryCode = self.dialPlanValueSelected.components(separatedBy: "+")
|
||||
if dial.countryCallingCode == countryCode[1] {
|
||||
if dial?.countryCallingCode == countryCode[1] {
|
||||
dialPlan = dial
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@ class AccountProfileViewModel: ObservableObject {
|
|||
|
||||
static let TAG = "[AccountProfileViewModel]"
|
||||
|
||||
@Published var dialPlanValueSelected: String = "🇫🇷 France | +33"
|
||||
@Published var dialPlanValueSelected: String = ""
|
||||
var dialPlanSelected: DialPlan?
|
||||
var dialPlansList: [DialPlan] = []
|
||||
|
||||
@Published var accountModelIndex: Int? = 0
|
||||
@Published var defaultAccountModelIndex: Int? = 0
|
||||
|
|
@ -65,6 +64,10 @@ class AccountProfileViewModel: ObservableObject {
|
|||
newParams?.internationalPrefix = self.dialPlanSelected?.countryCallingCode
|
||||
newParams?.internationalPrefixIsoCountryCode = self.dialPlanSelected?.isoCountryCode
|
||||
newParams?.useInternationalPrefixForCallsAndChats = true
|
||||
} else if newParams?.useInternationalPrefixForCallsAndChats == true {
|
||||
newParams?.internationalPrefix = nil
|
||||
newParams?.internationalPrefixIsoCountryCode = nil
|
||||
newParams?.useInternationalPrefixForCallsAndChats = false
|
||||
}
|
||||
|
||||
CoreContext.shared.accounts[self.accountModelIndex!].account.params = newParams
|
||||
|
|
@ -84,16 +87,20 @@ class AccountProfileViewModel: ObservableObject {
|
|||
|
||||
var dialPlanValueSelectedTmp = ""
|
||||
if !prefix.isEmpty || !isoCountryCode.isEmpty {
|
||||
Log.info(
|
||||
"\(AccountProfileViewModel.TAG) Account \(accountTmp.account.params?.identityAddress?.asStringUriOnly() ?? "") prefix is \(prefix) \(isoCountryCode)"
|
||||
)
|
||||
Log.info(
|
||||
"\(AccountProfileViewModel.TAG) Account \(accountTmp.account.params?.identityAddress?.asStringUriOnly() ?? "") prefix is \(prefix) \(isoCountryCode)"
|
||||
)
|
||||
|
||||
self.dialPlansList = Factory.Instance.dialPlans
|
||||
if let dialPlan = self.dialPlansList.first(where: { $0.isoCountryCode == isoCountryCode }) ??
|
||||
self.dialPlansList.first(where: { $0.countryCallingCode == prefix }) {
|
||||
dialPlanValueSelectedTmp = "\(dialPlan.flag) \(dialPlan.country) | +\(dialPlan.countryCallingCode)"
|
||||
}
|
||||
}
|
||||
let dialPlansList = SharedMainViewModel.shared.dialPlansList
|
||||
if let dialPlan = dialPlansList.first(where: { $0?.isoCountryCode == isoCountryCode }) ??
|
||||
dialPlansList.first(where: { $0?.countryCallingCode == prefix }) {
|
||||
dialPlanValueSelectedTmp = "\(dialPlan?.flag ?? "") \(dialPlan?.country ?? "") | +\(dialPlan?.countryCallingCode ?? "")"
|
||||
} else {
|
||||
dialPlanValueSelectedTmp = "No country code"
|
||||
}
|
||||
} else {
|
||||
dialPlanValueSelectedTmp = "No country code"
|
||||
}
|
||||
|
||||
let accountDisplayName = accountTmp.account.displayName()
|
||||
|
||||
|
|
@ -116,8 +123,9 @@ class AccountProfileViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
func updateDialPlan(newDialPlan: String) {
|
||||
if let dialPlan = self.dialPlansList.first(where: { newDialPlan.contains($0.isoCountryCode) }) ??
|
||||
self.dialPlansList.first(where: { newDialPlan.contains($0.countryCallingCode) }) {
|
||||
let dialPlansList = SharedMainViewModel.shared.dialPlansList
|
||||
if let dialPlan = dialPlansList.first(where: { newDialPlan.contains($0?.isoCountryCode ?? "") }) ??
|
||||
dialPlansList.first(where: { newDialPlan.contains($0?.countryCallingCode ?? "") }) {
|
||||
self.dialPlanSelected = dialPlan
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class SharedMainViewModel: ObservableObject {
|
|||
@Published var displayedConversation: ConversationModel?
|
||||
@Published var displayedMeeting: MeetingModel?
|
||||
|
||||
@Published var dialPlansList: [DialPlan] = []
|
||||
@Published var dialPlansList: [DialPlan?] = []
|
||||
@Published var dialPlansLabelList: [String] = []
|
||||
@Published var dialPlansShortLabelList: [String] = []
|
||||
|
||||
|
|
@ -143,10 +143,14 @@ class SharedMainViewModel: ObservableObject {
|
|||
func getDialPlansList() {
|
||||
CoreContext.shared.doOnCoreQueue { _ in
|
||||
let dialPlans = Factory.Instance.dialPlans
|
||||
var dialPlansListTmp: [DialPlan] = []
|
||||
var dialPlansListTmp: [DialPlan?] = []
|
||||
var dialPlansLabelListTmp: [String] = []
|
||||
var dialPlansShortLabelListTmp: [String] = []
|
||||
|
||||
dialPlansListTmp.append(nil)
|
||||
dialPlansLabelListTmp.append("No country code")
|
||||
dialPlansShortLabelListTmp.append("---")
|
||||
|
||||
dialPlans.forEach { dialPlan in
|
||||
dialPlansListTmp.append(dialPlan)
|
||||
dialPlansLabelListTmp.append(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue