mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Allow add-contact UI when disableAddContact is disabled
This commit is contained in:
parent
d4b10d38ae
commit
4cd63b53b2
7 changed files with 148 additions and 120 deletions
|
|
@ -141,6 +141,15 @@ class CorePreferences {
|
|||
}
|
||||
}
|
||||
|
||||
static var disableAddContact: Bool {
|
||||
get {
|
||||
return Config.get().getBool(section: "ui", key: "disable_add_contact", defaultValue: false)
|
||||
}
|
||||
set {
|
||||
Config.get().setBool(section: "ui", key: "disable_add_contact", value: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var showFavoriteContacts: Bool {
|
||||
get {
|
||||
return Config.get().getBool(section: "ui", key: "show_favorites_contacts", defaultValue: true)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ import Foundation
|
|||
|
||||
public enum AppGitInfo {
|
||||
public static let branch = "master"
|
||||
public static let commit = "6827bdc1d"
|
||||
public static let commit = "d4b10d38a"
|
||||
public static let tag = "6.1.0-alpha"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,22 +32,24 @@ struct ContactsView: View {
|
|||
ZStack(alignment: .bottomTrailing) {
|
||||
ContactsFragment(isShowDeletePopup: $isShowDeletePopup, text: $text)
|
||||
|
||||
Button {
|
||||
withAnimation {
|
||||
contactsListViewModel.selectedEditFriend = nil
|
||||
isShowEditContactFragment.toggle()
|
||||
if !CorePreferences.disableAddContact {
|
||||
Button {
|
||||
withAnimation {
|
||||
contactsListViewModel.selectedEditFriend = nil
|
||||
isShowEditContactFragment.toggle()
|
||||
}
|
||||
} label: {
|
||||
Image("user-plus")
|
||||
.renderingMode(.template)
|
||||
.foregroundStyle(.white)
|
||||
.padding()
|
||||
.background(Color.orangeMain500)
|
||||
.clipShape(Circle())
|
||||
.shadow(color: .black.opacity(0.2), radius: 4)
|
||||
|
||||
}
|
||||
} label: {
|
||||
Image("user-plus")
|
||||
.renderingMode(.template)
|
||||
.foregroundStyle(.white)
|
||||
.padding()
|
||||
.background(Color.orangeMain500)
|
||||
.clipShape(Circle())
|
||||
.shadow(color: .black.opacity(0.2), radius: 4)
|
||||
|
||||
.padding()
|
||||
}
|
||||
.padding()
|
||||
|
||||
// For testing crashlytics
|
||||
/*Button(action: CoreContext.shared.crashForCrashlytics, label: {
|
||||
|
|
|
|||
|
|
@ -353,59 +353,64 @@ struct ConversationInfoFragment: View {
|
|||
|
||||
if conversationViewModel.myParticipantConversationModel != nil && conversationViewModel.myParticipantConversationModel!.address != participantConversationModel.address {
|
||||
Menu {
|
||||
Button(
|
||||
action: {
|
||||
let addressConv = participantConversationModel.address
|
||||
|
||||
let friendIndex = contactsManager.avatarListModel.first(
|
||||
where: {$0.addresses.contains(where: {$0 == addressConv})})
|
||||
|
||||
SharedMainViewModel.shared.displayedCall = nil
|
||||
SharedMainViewModel.shared.changeIndexView(indexViewInt: 0)
|
||||
|
||||
if friendIndex != nil {
|
||||
withAnimation {
|
||||
SharedMainViewModel.shared.displayedFriend = friendIndex
|
||||
}
|
||||
} else {
|
||||
withAnimation {
|
||||
isShowEditContactFragment.toggle()
|
||||
isShowEditContactFragmentAddress = String(participantConversationModel.address.dropFirst(4))
|
||||
}
|
||||
}
|
||||
},
|
||||
label: {
|
||||
HStack {
|
||||
let addressConv = participantConversationModel.address
|
||||
|
||||
let friendIndex = contactsManager.lastSearch.firstIndex(
|
||||
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
|
||||
|
||||
let disableAddContact = CorePreferences.disableAddContact
|
||||
|
||||
if (!disableAddContact || (disableAddContact && friendIndex != nil)) {
|
||||
Button(
|
||||
action: {
|
||||
let addressConv = participantConversationModel.address
|
||||
|
||||
let friendIndex = contactsManager.lastSearch.firstIndex(
|
||||
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
|
||||
let friendIndex = contactsManager.avatarListModel.first(
|
||||
where: {$0.addresses.contains(where: {$0 == addressConv})})
|
||||
|
||||
SharedMainViewModel.shared.displayedCall = nil
|
||||
SharedMainViewModel.shared.changeIndexView(indexViewInt: 0)
|
||||
|
||||
if friendIndex != nil {
|
||||
Image("address-book")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
|
||||
Text("conversation_info_menu_go_to_contact")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
withAnimation {
|
||||
SharedMainViewModel.shared.displayedFriend = friendIndex
|
||||
}
|
||||
} else {
|
||||
Image("user-plus")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
|
||||
Text("conversation_info_menu_add_to_contacts")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
withAnimation {
|
||||
isShowEditContactFragment.toggle()
|
||||
isShowEditContactFragmentAddress = String(participantConversationModel.address.dropFirst(4))
|
||||
}
|
||||
}
|
||||
},
|
||||
label: {
|
||||
HStack {
|
||||
if friendIndex != nil {
|
||||
Image("address-book")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
|
||||
Text("conversation_info_menu_go_to_contact")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
} else {
|
||||
Image("user-plus")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
|
||||
Text("conversation_info_menu_add_to_contacts")
|
||||
.default_text_style(styleSize: 16)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if conversationViewModel.isUserAdmin {
|
||||
let participantConversationModelIsAdmin = conversationViewModel.participantConversationModelAdmin.first(
|
||||
|
|
@ -527,7 +532,14 @@ struct ConversationInfoFragment: View {
|
|||
|
||||
VStack(spacing: 0) {
|
||||
if !SharedMainViewModel.shared.displayedConversation!.isReadOnly {
|
||||
if !SharedMainViewModel.shared.displayedConversation!.isGroup {
|
||||
let addressConv = conversationViewModel.participantConversationModel.first?.address ?? ""
|
||||
|
||||
let friendIndex = contactsManager.lastSearch.firstIndex(
|
||||
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
|
||||
|
||||
let disableAddContact = CorePreferences.disableAddContact
|
||||
|
||||
if !SharedMainViewModel.shared.displayedConversation!.isGroup && (!disableAddContact || (disableAddContact && friendIndex != nil)) {
|
||||
Button(
|
||||
action: {
|
||||
if SharedMainViewModel.shared.displayedConversation != nil {
|
||||
|
|
@ -555,10 +567,6 @@ struct ConversationInfoFragment: View {
|
|||
},
|
||||
label: {
|
||||
HStack {
|
||||
let addressConv = conversationViewModel.participantConversationModel.first?.address ?? ""
|
||||
|
||||
let friendIndex = contactsManager.lastSearch.firstIndex(
|
||||
where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})})
|
||||
if friendIndex != nil {
|
||||
Image("address-book")
|
||||
.renderingMode(.template)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ struct HistoryContactFragment: View {
|
|||
Spacer()
|
||||
|
||||
Menu {
|
||||
if !historyModel.isConf {
|
||||
let disableAddContact = CorePreferences.disableAddContact
|
||||
let isFriend = historyModel.isFriend == true
|
||||
|
||||
if !historyModel.isConf && (!disableAddContact || (disableAddContact && isFriend)) {
|
||||
Button {
|
||||
isMenuOpen = false
|
||||
|
||||
|
|
|
|||
|
|
@ -58,68 +58,74 @@ struct HistoryListBottomSheet: View {
|
|||
}
|
||||
|
||||
Spacer()
|
||||
Button {
|
||||
|
||||
if #available(iOS 16.0, *) {
|
||||
if idiom != .pad {
|
||||
showingSheet.toggle()
|
||||
|
||||
let disableAddContact = CorePreferences.disableAddContact
|
||||
let isFriend = historyListViewModel.selectedCall?.isFriend == true
|
||||
|
||||
if !disableAddContact || (disableAddContact && isFriend) {
|
||||
Button {
|
||||
|
||||
if #available(iOS 16.0, *) {
|
||||
if idiom != .pad {
|
||||
showingSheet.toggle()
|
||||
} else {
|
||||
showingSheet.toggle()
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
showingSheet.toggle()
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
showingSheet.toggle()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
sharedMainViewModel.changeIndexView(indexViewInt: 0)
|
||||
|
||||
if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend {
|
||||
let friendIndex = contactsManager.avatarListModel.first(where: {$0.addresses.contains(where: {$0 == selectedCall.address})})
|
||||
if friendIndex != nil {
|
||||
|
||||
sharedMainViewModel.changeIndexView(indexViewInt: 0)
|
||||
|
||||
if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend {
|
||||
let friendIndex = contactsManager.avatarListModel.first(where: {$0.addresses.contains(where: {$0 == selectedCall.address})})
|
||||
if friendIndex != nil {
|
||||
withAnimation {
|
||||
SharedMainViewModel.shared.displayedFriend = friendIndex
|
||||
}
|
||||
}
|
||||
} else if let selectedCall = historyListViewModel.selectedCall {
|
||||
withAnimation {
|
||||
SharedMainViewModel.shared.displayedFriend = friendIndex
|
||||
isShowEditContactFragment.toggle()
|
||||
isShowEditContactFragmentAddress = String(selectedCall.address.dropFirst(4))
|
||||
}
|
||||
}
|
||||
} else if let selectedCall = historyListViewModel.selectedCall {
|
||||
withAnimation {
|
||||
isShowEditContactFragment.toggle()
|
||||
isShowEditContactFragmentAddress = String(selectedCall.address.dropFirst(4))
|
||||
} label: {
|
||||
HStack {
|
||||
if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend {
|
||||
Image("user-circle")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
Text("menu_see_existing_contact")
|
||||
.default_text_style(styleSize: 16)
|
||||
Spacer()
|
||||
} else {
|
||||
Image("plus-circle")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
Text("menu_add_address_to_contacts")
|
||||
.default_text_style(styleSize: 16)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
} label: {
|
||||
HStack {
|
||||
if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend {
|
||||
Image("user-circle")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
Text("menu_see_existing_contact")
|
||||
.default_text_style(styleSize: 16)
|
||||
Spacer()
|
||||
} else {
|
||||
Image("plus-circle")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c500)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
Text("menu_add_address_to_contacts")
|
||||
.default_text_style(styleSize: 16)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 30)
|
||||
.background(Color.gray100)
|
||||
|
||||
VStack {
|
||||
Divider()
|
||||
}
|
||||
.frame(maxHeight: .infinity)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.padding(.horizontal, 30)
|
||||
.background(Color.gray100)
|
||||
|
||||
VStack {
|
||||
Divider()
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Button {
|
||||
if historyListViewModel.selectedCall != nil && historyListViewModel.selectedCall!.isOutgoing {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@
|
|||
"location" : "https://gitlab.linphone.org/BC/public/linphone-sdk-swift-ios.git",
|
||||
"state" : {
|
||||
"branch" : "alpha",
|
||||
"revision" : "0dc2d9ef5b2e1e1868e3e6143a89a7ba9d983ea6"
|
||||
"revision" : "1e266452f9e464d8d6ea8359722d9038c5f46b9d"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue