mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Refactored AccountProfile
This commit is contained in:
parent
06847bc82e
commit
b4a19c9fd0
11 changed files with 346 additions and 352 deletions
|
|
@ -24,6 +24,7 @@ import SwiftUI
|
|||
struct RegisterFragment: View {
|
||||
|
||||
@ObservedObject var registerViewModel: RegisterViewModel
|
||||
@ObservedObject var sharedMainViewModel = SharedMainViewModel.shared
|
||||
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
|
|
@ -154,8 +155,8 @@ struct RegisterFragment: View {
|
|||
HStack {
|
||||
Menu {
|
||||
Picker("", selection: $registerViewModel.dialPlanValueSelected) {
|
||||
ForEach(Array(registerViewModel.dialPlansLabelList.enumerated()), id: \.offset) { index, dialPlan in
|
||||
Text(dialPlan).tag(registerViewModel.dialPlansShortLabelList[index])
|
||||
ForEach(Array(sharedMainViewModel.dialPlansLabelList.enumerated()), id: \.offset) { index, dialPlan in
|
||||
Text(dialPlan).tag(sharedMainViewModel.dialPlansShortLabelList[index])
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@ class RegisterViewModel: ObservableObject {
|
|||
@Published var transportType: String = "TLS"
|
||||
|
||||
@Published var dialPlanValueSelected: String = "🇫🇷 +33"
|
||||
@Published var dialPlansList: [DialPlan] = []
|
||||
@Published var dialPlansLabelList: [String] = []
|
||||
@Published var dialPlansShortLabelList: [String] = []
|
||||
|
||||
private let HASHALGORITHM = "SHA-256"
|
||||
|
||||
|
|
@ -95,7 +92,6 @@ class RegisterViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
init() {
|
||||
getDialPlansList()
|
||||
getAccountCreationToken()
|
||||
|
||||
self.usernameError = ""
|
||||
|
|
@ -205,31 +201,6 @@ class RegisterViewModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
func getDialPlansList() {
|
||||
coreContext.doOnCoreQueue { _ in
|
||||
let dialPlans = Factory.Instance.dialPlans
|
||||
var dialPlansListTmp: [DialPlan] = []
|
||||
var dialPlansLabelListTmp: [String] = []
|
||||
var dialPlansShortLabelListTmp: [String] = []
|
||||
|
||||
dialPlans.forEach { dialPlan in
|
||||
dialPlansListTmp.append(dialPlan)
|
||||
dialPlansLabelListTmp.append(
|
||||
"\(dialPlan.flag) \(dialPlan.country) | +\(dialPlan.countryCallingCode)"
|
||||
)
|
||||
dialPlansShortLabelListTmp.append(
|
||||
"\(dialPlan.flag) +\(dialPlan.countryCallingCode)"
|
||||
)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.dialPlansList = dialPlansListTmp
|
||||
self.dialPlansLabelList = dialPlansLabelListTmp
|
||||
self.dialPlansShortLabelList = dialPlansShortLabelListTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getAccountCreationToken() {
|
||||
coreContext.doOnCoreQueue { core in
|
||||
do {
|
||||
|
|
@ -281,7 +252,7 @@ class RegisterViewModel: ObservableObject {
|
|||
|
||||
var dialPlan: DialPlan?
|
||||
|
||||
dialPlansList.forEach { dial in
|
||||
SharedMainViewModel.shared.dialPlansList.forEach { dial in
|
||||
let countryCode = dialPlanValueSelected.components(separatedBy: "+")
|
||||
if dial.countryCallingCode == countryCode[1] {
|
||||
dialPlan = dial
|
||||
|
|
@ -432,7 +403,7 @@ class RegisterViewModel: ObservableObject {
|
|||
if self.accountManagerServices != nil {
|
||||
var dialPlan: DialPlan?
|
||||
|
||||
for dial in self.dialPlansList {
|
||||
for dial in SharedMainViewModel.shared.dialPlansList {
|
||||
let countryCode = self.dialPlanValueSelected.components(separatedBy: "+")
|
||||
if dial.countryCallingCode == countryCode[1] {
|
||||
dialPlan = dial
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import linphonesw
|
|||
struct ContentView: View {
|
||||
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
|
||||
|
||||
@EnvironmentObject var navigationManager: NavigationManager
|
||||
|
||||
|
|
@ -35,14 +34,14 @@ struct ContentView: View {
|
|||
@ObservedObject private var magicSearch = MagicSearchSingleton.shared
|
||||
@ObservedObject private var sharedMainViewModel = SharedMainViewModel.shared
|
||||
|
||||
@StateObject private var callViewModel = CallViewModel()
|
||||
@StateObject private var accountProfileViewModel = AccountProfileViewModel()
|
||||
|
||||
@State private var contactsListViewModel: ContactsListViewModel?
|
||||
@State private var historyListViewModel: HistoryListViewModel?
|
||||
|
||||
//@ObservedObject var startCallViewModel: StartCallViewModel
|
||||
//@ObservedObject var startConversationViewModel: StartConversationViewModel
|
||||
|
||||
//@ObservedObject var callViewModel: CallViewModel
|
||||
|
||||
//@ObservedObject var meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel
|
||||
|
||||
//@ObservedObject var conversationsListViewModel: ConversationsListViewModel
|
||||
|
|
@ -53,7 +52,6 @@ struct ContentView: View {
|
|||
|
||||
//@ObservedObject var conversationForwardMessageViewModel: ConversationForwardMessageViewModel
|
||||
|
||||
//@ObservedObject var accountProfileViewModel: AccountProfileViewModel
|
||||
|
||||
//@Binding var index: Int
|
||||
@State private var orientation = UIDevice.current.orientation
|
||||
|
|
@ -102,7 +100,6 @@ struct ContentView: View {
|
|||
.publisher(for: NSNotification.Name("CoreStarted"))
|
||||
GeometryReader { geometry in
|
||||
VStack(spacing: 0) {
|
||||
/*
|
||||
if (telecomManager.callInProgress && !fullscreenVideo && ((!telecomManager.callDisplayed && callViewModel.callsCounter == 1) || callViewModel.callsCounter > 1)) || isShowConversationFragment {
|
||||
HStack {
|
||||
Image("phone")
|
||||
|
|
@ -137,7 +134,7 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
ZStack {
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 0) {
|
||||
|
|
@ -326,7 +323,6 @@ struct ContentView: View {
|
|||
VStack(spacing: 0) {
|
||||
if searchIsActive == false {
|
||||
HStack {
|
||||
/*
|
||||
if let accountModelIndex = accountProfileViewModel.accountModelIndex,
|
||||
accountModelIndex < coreContext.accounts.count {
|
||||
AsyncImage(url: imagePath) { image in
|
||||
|
|
@ -395,7 +391,7 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Text(String(localized: sharedMainViewModel.indexView == 0 ? "bottom_navigation_contacts_label" : (sharedMainViewModel.indexView == 1 ? "bottom_navigation_calls_label" : (sharedMainViewModel.indexView == 2 ? "bottom_navigation_conversations_label" : "bottom_navigation_meetings_label"))))
|
||||
.default_text_style_white_800(styleSize: 20)
|
||||
.padding(.leading, 10)
|
||||
|
|
@ -1032,9 +1028,7 @@ struct ContentView: View {
|
|||
.zIndex(1)
|
||||
}
|
||||
|
||||
/*
|
||||
SideMenu(
|
||||
accountProfileViewModel: accountProfileViewModel,
|
||||
width: geometry.size.width / 5 * 4,
|
||||
isOpen: $sideMenuIsOpen,
|
||||
menuClose: self.openMenu,
|
||||
|
|
@ -1044,9 +1038,11 @@ struct ContentView: View {
|
|||
isShowSettingsFragment: $isShowSettingsFragment,
|
||||
isShowHelpFragment: $isShowHelpFragment
|
||||
)
|
||||
.environmentObject(accountProfileViewModel)
|
||||
.ignoresSafeArea(.all)
|
||||
.zIndex(2)
|
||||
|
||||
/*
|
||||
if isShowLoginFragment {
|
||||
LoginFragment(
|
||||
accountLoginViewModel: AccountLoginViewModel(),
|
||||
|
|
@ -1077,51 +1073,18 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if isShowStartCallFragment {
|
||||
if #available(iOS 16.4, *), idiom != .pad {
|
||||
StartCallFragment(
|
||||
callViewModel: callViewModel,
|
||||
startCallViewModel: startCallViewModel,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
resetCallView: {callViewModel.resetCallView()}
|
||||
)
|
||||
.zIndex(6)
|
||||
.transition(.opacity.combined(with: .move(edge: .bottom)))
|
||||
.sheet(isPresented: $showingDialer) {
|
||||
DialerBottomSheet(
|
||||
startCallViewModel: startCallViewModel,
|
||||
callViewModel: callViewModel,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
currentCall: nil
|
||||
)
|
||||
.presentationDetents([.medium])
|
||||
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
|
||||
}
|
||||
} else {
|
||||
StartCallFragment(
|
||||
callViewModel: callViewModel,
|
||||
startCallViewModel: startCallViewModel,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
resetCallView: {callViewModel.resetCallView()}
|
||||
)
|
||||
.zIndex(6)
|
||||
.transition(.opacity.combined(with: .move(edge: .bottom)))
|
||||
.halfSheet(showSheet: $showingDialer) {
|
||||
DialerBottomSheet(
|
||||
startCallViewModel: startCallViewModel,
|
||||
callViewModel: callViewModel,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
currentCall: nil
|
||||
)
|
||||
} onDismiss: {}
|
||||
}
|
||||
StartCallFragment(
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
resetCallView: {callViewModel.resetCallView()}
|
||||
)
|
||||
.environmentObject(callViewModel)
|
||||
.zIndex(6)
|
||||
.transition(.opacity.combined(with: .move(edge: .bottom)))
|
||||
}
|
||||
|
||||
/*
|
||||
if isShowStartConversationFragment {
|
||||
StartConversationFragment(
|
||||
startConversationViewModel: startConversationViewModel,
|
||||
|
|
@ -1258,17 +1221,18 @@ struct ContentView: View {
|
|||
.onAppear {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if isShowAccountProfileFragment {
|
||||
AccountProfileFragment(
|
||||
accountProfileViewModel: accountProfileViewModel,
|
||||
registerViewModel: RegisterViewModel(),
|
||||
isShowAccountProfileFragment: $isShowAccountProfileFragment
|
||||
)
|
||||
.environmentObject(accountProfileViewModel)
|
||||
.zIndex(3)
|
||||
.transition(.move(edge: .trailing))
|
||||
}
|
||||
|
||||
/*
|
||||
if isShowSettingsFragment {
|
||||
SettingsFragment(
|
||||
settingsViewModel: SettingsViewModel(),
|
||||
|
|
@ -1378,7 +1342,8 @@ struct ContentView: View {
|
|||
meetingWaitingRoomViewModel.resetMeetingRoomView()
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
if telecomManager.callDisplayed && ((telecomManager.callInProgress && telecomManager.outgoingCallStarted) || telecomManager.callConnected) && !telecomManager.meetingWaitingRoomDisplayed {
|
||||
CallView(
|
||||
callViewModel: callViewModel,
|
||||
|
|
@ -1432,7 +1397,7 @@ struct ContentView: View {
|
|||
//conversationsListViewModel.updateChatRoom(address: address)
|
||||
}
|
||||
.onReceive(coreStarted) { _ in
|
||||
//accountProfileViewModel.setAvatarModel()
|
||||
accountProfileViewModel.setAvatarModel()
|
||||
}
|
||||
}
|
||||
.overlay {
|
||||
|
|
@ -1482,9 +1447,6 @@ class NavigationManager: ObservableObject {
|
|||
|
||||
#Preview {
|
||||
ContentView(
|
||||
//startCallViewModel: StartCallViewModel(),
|
||||
//startConversationViewModel: StartConversationViewModel(),
|
||||
//callViewModel: CallViewModel(),
|
||||
//meetingWaitingRoomViewModel: MeetingWaitingRoomViewModel(),
|
||||
//conversationsListViewModel: ConversationsListViewModel(),
|
||||
//conversationViewModel: ConversationViewModel(),
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import UniformTypeIdentifiers
|
|||
|
||||
struct SideMenu: View {
|
||||
|
||||
@ObservedObject var accountProfileViewModel: AccountProfileViewModel
|
||||
@EnvironmentObject var accountProfileViewModel: AccountProfileViewModel
|
||||
|
||||
let width: CGFloat
|
||||
@Binding var isOpen: Bool
|
||||
|
|
@ -71,7 +71,7 @@ struct SideMenu: View {
|
|||
|
||||
List {
|
||||
ForEach(0..<CoreContext.shared.accounts.count, id: \.self) { index in
|
||||
SideMenuAccountRow( model: CoreContext.shared.accounts[index], accountProfileViewModel: accountProfileViewModel, isOpen: $isOpen, isShowAccountProfileFragment: $isShowAccountProfileFragment)
|
||||
SideMenuAccountRow(model: CoreContext.shared.accounts[index], isOpen: $isOpen, isShowAccountProfileFragment: $isShowAccountProfileFragment)
|
||||
.background()
|
||||
.listRowInsets(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
|
||||
.listRowSeparator(.hidden)
|
||||
|
|
@ -178,7 +178,6 @@ struct SideMenu: View {
|
|||
GeometryReader { geometry in
|
||||
@State var triggerNavigateToLogin: Bool = false
|
||||
SideMenu(
|
||||
accountProfileViewModel: AccountProfileViewModel(),
|
||||
width: geometry.size.width / 5 * 4,
|
||||
isOpen: .constant(true),
|
||||
menuClose: {},
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct SideMenuAccountRow: View {
|
|||
@ObservedObject var contactsManager = ContactsManager.shared
|
||||
|
||||
@ObservedObject var model: AccountModel
|
||||
@ObservedObject var accountProfileViewModel: AccountProfileViewModel
|
||||
@EnvironmentObject var accountProfileViewModel: AccountProfileViewModel
|
||||
|
||||
@State private var navigateToOption = false
|
||||
@Binding var isOpen: Bool
|
||||
|
|
|
|||
|
|
@ -82,9 +82,8 @@ struct HistoryRow: View {
|
|||
HStack {
|
||||
HStack {
|
||||
if !historyModel.isConf {
|
||||
//if historyModel.avatarModel != nil {
|
||||
if historyModel.avatarModel != nil {
|
||||
Avatar(contactAvatarModel: historyModel.avatarModel!, avatarSize: 50)
|
||||
/*
|
||||
} else {
|
||||
if !historyModel.addressName.isEmpty {
|
||||
Image(uiImage: contactsManager.textToImage(
|
||||
|
|
@ -108,7 +107,6 @@ struct HistoryRow: View {
|
|||
.clipShape(Circle())
|
||||
}
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
VStack {
|
||||
Image("users-three-square")
|
||||
|
|
|
|||
|
|
@ -22,13 +22,15 @@ import linphonesw
|
|||
|
||||
// swiftlint:disable type_body_length
|
||||
struct StartCallFragment: View {
|
||||
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
|
||||
|
||||
@ObservedObject var contactsManager = ContactsManager.shared
|
||||
@ObservedObject var magicSearch = MagicSearchSingleton.shared
|
||||
@ObservedObject private var telecomManager = TelecomManager.shared
|
||||
|
||||
@ObservedObject var callViewModel: CallViewModel
|
||||
@ObservedObject var startCallViewModel: StartCallViewModel
|
||||
@EnvironmentObject var callViewModel: CallViewModel
|
||||
|
||||
@StateObject private var startCallViewModel = StartCallViewModel()
|
||||
|
||||
@Binding var isShowStartCallFragment: Bool
|
||||
@Binding var showingDialer: Bool
|
||||
|
|
@ -42,25 +44,215 @@ struct StartCallFragment: View {
|
|||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
VStack(spacing: 1) {
|
||||
if #available(iOS 16.4, *), idiom != .pad {
|
||||
startCall
|
||||
.sheet(isPresented: $showingDialer) {
|
||||
DialerBottomSheet(
|
||||
startCallViewModel: startCallViewModel,
|
||||
callViewModel: callViewModel,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
currentCall: nil
|
||||
)
|
||||
.presentationDetents([.medium])
|
||||
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
|
||||
}
|
||||
} else {
|
||||
startCall
|
||||
.halfSheet(showSheet: $showingDialer) {
|
||||
DialerBottomSheet(
|
||||
startCallViewModel: startCallViewModel,
|
||||
callViewModel: callViewModel,
|
||||
isShowStartCallFragment: $isShowStartCallFragment,
|
||||
showingDialer: $showingDialer,
|
||||
currentCall: nil
|
||||
)
|
||||
} onDismiss: {}
|
||||
}
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
}
|
||||
|
||||
var startCall: some View {
|
||||
ZStack {
|
||||
VStack(spacing: 1) {
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(delayedColor)
|
||||
.edgesIgnoringSafeArea(.top)
|
||||
.frame(height: 0)
|
||||
.task(delayColor)
|
||||
|
||||
HStack {
|
||||
Image("caret-left")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
.padding(.top, 2)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
delayColorDismiss()
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(delayedColor)
|
||||
.edgesIgnoringSafeArea(.top)
|
||||
.frame(height: 0)
|
||||
.task(delayColor)
|
||||
Text(!callViewModel.isTransferInsteadCall ? "history_call_start_title" : "call_transfer_current_call_title")
|
||||
.multilineTextAlignment(.leading)
|
||||
.default_text_style_orange_800(styleSize: 16)
|
||||
|
||||
HStack {
|
||||
Image("caret-left")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
.padding(.top, 2)
|
||||
.padding(.leading, -10)
|
||||
.onTapGesture {
|
||||
Spacer()
|
||||
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 4)
|
||||
.background(.white)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
ZStack(alignment: .trailing) {
|
||||
TextField("history_call_start_search_bar_filter_hint", text: $startCallViewModel.searchField)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(height: 25)
|
||||
.focused($isSearchFieldFocused)
|
||||
.padding(.horizontal, 30)
|
||||
.onChange(of: startCallViewModel.searchField) { newValue in
|
||||
magicSearch.currentFilterSuggestions = newValue
|
||||
magicSearch.searchForSuggestions()
|
||||
}
|
||||
.simultaneousGesture(TapGesture().onEnded {
|
||||
showingDialer = false
|
||||
})
|
||||
|
||||
HStack {
|
||||
Button(action: {
|
||||
}, label: {
|
||||
Image("magnifying-glass")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25)
|
||||
})
|
||||
|
||||
Spacer()
|
||||
|
||||
if startCallViewModel.searchField.isEmpty {
|
||||
Button(action: {
|
||||
if !showingDialer {
|
||||
isSearchFieldFocused = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
showingDialer = true
|
||||
}
|
||||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
isSearchFieldFocused = true
|
||||
}
|
||||
}
|
||||
}, label: {
|
||||
Image(!showingDialer ? "dialer" : "keyboard")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25)
|
||||
})
|
||||
} else {
|
||||
Button(action: {
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.searchForSuggestions()
|
||||
}, label: {
|
||||
Image("x")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 15)
|
||||
.padding(.vertical, 10)
|
||||
.cornerRadius(60)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 60)
|
||||
.inset(by: 0.5)
|
||||
.stroke(isSearchFieldFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1)
|
||||
)
|
||||
.padding(.vertical)
|
||||
.padding(.horizontal)
|
||||
|
||||
NavigationLink(destination: {
|
||||
StartGroupCallFragment(startCallViewModel: startCallViewModel)
|
||||
}, label: {
|
||||
HStack {
|
||||
HStack(alignment: .center) {
|
||||
Image("meetings")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 20, height: 20, alignment: .leading)
|
||||
}
|
||||
.padding(16)
|
||||
.background(Color.orangeMain500)
|
||||
.cornerRadius(40)
|
||||
|
||||
Text("history_call_start_create_group_call")
|
||||
.foregroundStyle(.black)
|
||||
.default_text_style_800(styleSize: 16)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image("caret-right")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
}
|
||||
})
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 20)
|
||||
.background(
|
||||
LinearGradient(gradient: Gradient(colors: [.grayMain2c100, .white]), startPoint: .leading, endPoint: .trailing)
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 40)
|
||||
)
|
||||
|
||||
ScrollView {
|
||||
if !ContactsManager.shared.lastSearch.isEmpty {
|
||||
HStack(alignment: .center) {
|
||||
Text("contacts_list_all_contacts_title")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
||||
ContactsListFragment(showingSheet: .constant(false)
|
||||
, startCallFunc: { addr in
|
||||
if callViewModel.isTransferInsteadCall {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
|
@ -75,237 +267,75 @@ struct StartCallFragment: View {
|
|||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
callViewModel.blindTransferCallTo(toAddress: addr)
|
||||
}
|
||||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
telecomManager.doCallOrJoinConf(address: addr)
|
||||
}
|
||||
}
|
||||
})
|
||||
.padding(.horizontal, 16)
|
||||
|
||||
Text(!callViewModel.isTransferInsteadCall ? "history_call_start_title" : "call_transfer_current_call_title")
|
||||
.multilineTextAlignment(.leading)
|
||||
.default_text_style_orange_800(styleSize: 16)
|
||||
|
||||
Spacer()
|
||||
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 4)
|
||||
.background(.white)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
ZStack(alignment: .trailing) {
|
||||
TextField("history_call_start_search_bar_filter_hint", text: $startCallViewModel.searchField)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(height: 25)
|
||||
.focused($isSearchFieldFocused)
|
||||
.padding(.horizontal, 30)
|
||||
.onChange(of: startCallViewModel.searchField) { newValue in
|
||||
magicSearch.currentFilterSuggestions = newValue
|
||||
magicSearch.searchForSuggestions()
|
||||
}
|
||||
.simultaneousGesture(TapGesture().onEnded {
|
||||
showingDialer = false
|
||||
})
|
||||
|
||||
HStack {
|
||||
Button(action: {
|
||||
}, label: {
|
||||
Image("magnifying-glass")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25)
|
||||
})
|
||||
|
||||
Spacer()
|
||||
|
||||
if startCallViewModel.searchField.isEmpty {
|
||||
Button(action: {
|
||||
if !showingDialer {
|
||||
isSearchFieldFocused = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
showingDialer = true
|
||||
}
|
||||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
isSearchFieldFocused = true
|
||||
}
|
||||
}
|
||||
}, label: {
|
||||
Image(!showingDialer ? "dialer" : "keyboard")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25)
|
||||
})
|
||||
} else {
|
||||
Button(action: {
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
magicSearch.searchForSuggestions()
|
||||
}, label: {
|
||||
Image("x")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 15)
|
||||
.padding(.vertical, 10)
|
||||
.cornerRadius(60)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 60)
|
||||
.inset(by: 0.5)
|
||||
.stroke(isSearchFieldFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1)
|
||||
)
|
||||
.padding(.vertical)
|
||||
.padding(.horizontal)
|
||||
|
||||
NavigationLink(destination: {
|
||||
StartGroupCallFragment(startCallViewModel: startCallViewModel)
|
||||
}, label: {
|
||||
HStack {
|
||||
HStack(alignment: .center) {
|
||||
Image("meetings")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 20, height: 20, alignment: .leading)
|
||||
}
|
||||
.padding(16)
|
||||
.background(Color.orangeMain500)
|
||||
.cornerRadius(40)
|
||||
|
||||
Text("history_call_start_create_group_call")
|
||||
.foregroundStyle(.black)
|
||||
if !contactsManager.lastSearchSuggestions.isEmpty {
|
||||
HStack(alignment: .center) {
|
||||
Text("generic_address_picker_suggestions_list_title")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image("caret-right")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
}
|
||||
})
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 20)
|
||||
.background(
|
||||
LinearGradient(gradient: Gradient(colors: [.grayMain2c100, .white]), startPoint: .leading, endPoint: .trailing)
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 40)
|
||||
)
|
||||
|
||||
ScrollView {
|
||||
if !ContactsManager.shared.lastSearch.isEmpty {
|
||||
HStack(alignment: .center) {
|
||||
Text("contacts_list_all_contacts_title")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
||||
ContactsListFragment(showingSheet: .constant(false)
|
||||
, startCallFunc: { addr in
|
||||
if callViewModel.isTransferInsteadCall {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
callViewModel.blindTransferCallTo(toAddress: addr)
|
||||
}
|
||||
} else {
|
||||
showingDialer = false
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
magicSearch.searchForContacts(
|
||||
sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue)
|
||||
|
||||
if callViewModel.isTransferInsteadCall == true {
|
||||
callViewModel.isTransferInsteadCall = false
|
||||
}
|
||||
|
||||
resetCallView()
|
||||
}
|
||||
|
||||
startCallViewModel.searchField = ""
|
||||
magicSearch.currentFilterSuggestions = ""
|
||||
delayColorDismiss()
|
||||
|
||||
withAnimation {
|
||||
isShowStartCallFragment.toggle()
|
||||
telecomManager.doCallOrJoinConf(address: addr)
|
||||
}
|
||||
}
|
||||
})
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 16)
|
||||
|
||||
if !contactsManager.lastSearchSuggestions.isEmpty {
|
||||
HStack(alignment: .center) {
|
||||
Text("generic_address_picker_suggestions_list_title")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 10)
|
||||
.padding(.horizontal, 16)
|
||||
|
||||
suggestionsList
|
||||
}
|
||||
suggestionsList
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.background(.white)
|
||||
|
||||
if !startCallViewModel.participants.isEmpty {
|
||||
startCallPopup
|
||||
.background(.black.opacity(0.65))
|
||||
.onAppear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
|
||||
isMessageTextFocused = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if startCallViewModel.operationInProgress {
|
||||
PopupLoadingView()
|
||||
.background(.black.opacity(0.65))
|
||||
.onDisappear {
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.background(.white)
|
||||
|
||||
if !startCallViewModel.participants.isEmpty {
|
||||
startCallPopup
|
||||
.background(.black.opacity(0.65))
|
||||
.onAppear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
|
||||
isMessageTextFocused = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if startCallViewModel.operationInProgress {
|
||||
PopupLoadingView()
|
||||
.background(.black.opacity(0.65))
|
||||
.onDisappear {
|
||||
isShowStartCallFragment.toggle()
|
||||
}
|
||||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
.navigationViewStyle(StackNavigationViewStyle())
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
|
||||
@Sendable private func delayColor() async {
|
||||
|
|
@ -501,8 +531,6 @@ struct StartCallFragment: View {
|
|||
|
||||
#Preview {
|
||||
StartCallFragment(
|
||||
callViewModel: CallViewModel(),
|
||||
startCallViewModel: StartCallViewModel(),
|
||||
isShowStartCallFragment: .constant(true),
|
||||
showingDialer: .constant(false),
|
||||
resetCallView: {}
|
||||
|
|
|
|||
|
|
@ -69,13 +69,14 @@ class HistoryModel: ObservableObject, Identifiable {
|
|||
coreContext.doOnCoreQueue { _ in
|
||||
let callLogTmp = callLog
|
||||
let idTmp = callLog.callId ?? ""
|
||||
let subjectTmp = callLog.conferenceInfo != nil && callLog.conferenceInfo!.subject != nil ? callLog.conferenceInfo!.subject! : ""
|
||||
let isConfTmp = callLog.conferenceInfo != nil
|
||||
let confInfoTmp = callLog.conferenceInfo
|
||||
let subjectTmp = confInfoTmp != nil && confInfoTmp!.subject != nil ? confInfoTmp!.subject! : ""
|
||||
let isConfTmp = confInfoTmp != nil
|
||||
|
||||
let addressLinphoneTmp = callLog.dir == .Outgoing && callLog.toAddress != nil ? callLog.toAddress! : callLog.fromAddress!
|
||||
|
||||
let addressNameTmp = callLog.conferenceInfo != nil && callLog.conferenceInfo!.subject != nil
|
||||
? callLog.conferenceInfo!.subject!
|
||||
let addressNameTmp = confInfoTmp != nil && confInfoTmp!.subject != nil
|
||||
? confInfoTmp!.subject!
|
||||
: (addressLinphoneTmp.username != nil ? addressLinphoneTmp.username ?? "" : addressLinphoneTmp.displayName ?? "")
|
||||
|
||||
let addressTmp = addressLinphoneTmp.asStringUriOnly()
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ import UniformTypeIdentifiers
|
|||
struct AccountProfileFragment: View {
|
||||
|
||||
@ObservedObject var contactsManager = ContactsManager.shared
|
||||
@ObservedObject var sharedMainViewModel = SharedMainViewModel.shared
|
||||
|
||||
@ObservedObject var accountProfileViewModel: AccountProfileViewModel
|
||||
@ObservedObject var registerViewModel: RegisterViewModel
|
||||
@EnvironmentObject var accountProfileViewModel: AccountProfileViewModel
|
||||
|
||||
@Binding var isShowAccountProfileFragment: Bool
|
||||
@State var detailIsOpen: Bool = true
|
||||
|
|
@ -340,7 +340,7 @@ struct AccountProfileFragment: View {
|
|||
}
|
||||
Menu {
|
||||
Picker("", selection: $accountProfileViewModel.dialPlanValueSelected) {
|
||||
ForEach(registerViewModel.dialPlansLabelList, id: \.self) { dialPlan in
|
||||
ForEach(sharedMainViewModel.dialPlansLabelList, id: \.self) { dialPlan in
|
||||
Text(dialPlan).tag(dialPlan)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ class AccountProfileViewModel: ObservableObject {
|
|||
|
||||
var accountModelIndex: Int? = 0
|
||||
|
||||
init() {}
|
||||
init() {
|
||||
SharedMainViewModel.shared.getDialPlansList()
|
||||
}
|
||||
|
||||
func saveChangesWhenLeaving() {
|
||||
if accountModelIndex != nil {
|
||||
|
|
@ -95,14 +97,16 @@ class AccountProfileViewModel: ObservableObject {
|
|||
|
||||
let accountDisplayName = CoreContext.shared.accounts[self.accountModelIndex!].account.displayName()
|
||||
|
||||
CoreContext.shared.accounts[self.accountModelIndex!].avatarModel = ContactAvatarModel(
|
||||
friend: nil,
|
||||
name: displayNameTmp.isEmpty ? accountDisplayName : displayNameTmp,
|
||||
address: contactAddressTmp,
|
||||
withPresence: false
|
||||
)
|
||||
|
||||
self.dialPlanValueSelected = dialPlanValueSelectedTmp
|
||||
DispatchQueue.main.async {
|
||||
CoreContext.shared.accounts[self.accountModelIndex!].avatarModel = ContactAvatarModel(
|
||||
friend: nil,
|
||||
name: displayNameTmp.isEmpty ? accountDisplayName : displayNameTmp,
|
||||
address: contactAddressTmp,
|
||||
withPresence: false
|
||||
)
|
||||
|
||||
self.dialPlanValueSelected = dialPlanValueSelectedTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ class SharedMainViewModel: ObservableObject {
|
|||
@Published var displayedConversation: ConversationModel?
|
||||
@Published var displayedMeeting: MeetingModel?
|
||||
|
||||
|
||||
@Published var dialPlansList: [DialPlan] = []
|
||||
@Published var dialPlansLabelList: [String] = []
|
||||
@Published var dialPlansShortLabelList: [String] = []
|
||||
|
||||
let welcomeViewKey = "welcome_view"
|
||||
let generalTermsKey = "general_terms"
|
||||
let displayProfileModeKey = "display_profile_mode"
|
||||
|
|
@ -120,4 +125,29 @@ class SharedMainViewModel: ObservableObject {
|
|||
indexView = indexViewInt
|
||||
preferences.set(indexView, forKey: indexViewKey)
|
||||
}
|
||||
|
||||
func getDialPlansList() {
|
||||
CoreContext.shared.doOnCoreQueue { _ in
|
||||
let dialPlans = Factory.Instance.dialPlans
|
||||
var dialPlansListTmp: [DialPlan] = []
|
||||
var dialPlansLabelListTmp: [String] = []
|
||||
var dialPlansShortLabelListTmp: [String] = []
|
||||
|
||||
dialPlans.forEach { dialPlan in
|
||||
dialPlansListTmp.append(dialPlan)
|
||||
dialPlansLabelListTmp.append(
|
||||
"\(dialPlan.flag) \(dialPlan.country) | +\(dialPlan.countryCallingCode)"
|
||||
)
|
||||
dialPlansShortLabelListTmp.append(
|
||||
"\(dialPlan.flag) +\(dialPlan.countryCallingCode)"
|
||||
)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.dialPlansList = dialPlansListTmp
|
||||
self.dialPlansLabelList = dialPlansLabelListTmp
|
||||
self.dialPlansShortLabelList = dialPlansShortLabelListTmp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue