mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-17 11:48:27 +00:00
Add pending notifications banner
This commit is contained in:
parent
d39e4a0e34
commit
0f6d8b1296
6 changed files with 80 additions and 2 deletions
|
|
@ -2,6 +2,6 @@ import Foundation
|
|||
|
||||
public enum AppGitInfo {
|
||||
public static let branch = "master"
|
||||
public static let commit = "23f521113"
|
||||
public static let commit = "d39e4a0e3"
|
||||
public static let tag = "6.1.0-alpha"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,6 +461,8 @@
|
|||
"operation_in_progress_overlay" = "Operation in progress, please wait";
|
||||
"or" = "or";
|
||||
"password" = "Password";
|
||||
"pending_notification_for_other_accounts_single" = "1 notification for other account(s)";
|
||||
"pending_notification_for_other_accounts_multiple" = "%@ notifications for other account(s)";
|
||||
"Personnalize your profil mode" ="Personnalize your profil mode";
|
||||
"phone_number" = "Phone number";
|
||||
"picker_categories" = "Categories";
|
||||
|
|
|
|||
|
|
@ -461,6 +461,8 @@
|
|||
"operation_in_progress_overlay" = "Opération en cours, merci de patienter...";
|
||||
"or" = "ou";
|
||||
"password" = "Mot de passe";
|
||||
"pending_notification_for_other_accounts_single" = "1 notification en attente";
|
||||
"pending_notification_for_other_accounts_multiple" = "%@ notifications en attente";
|
||||
"Personnalize your profil mode" = "Personnalize your profil mode";
|
||||
"phone_number" = "Numéro de téléphone";
|
||||
"picker_categories" = "Catégories";
|
||||
|
|
|
|||
|
|
@ -143,6 +143,47 @@ struct ContentView: View {
|
|||
.background(Color.redDanger500)
|
||||
}
|
||||
|
||||
if accountProfileViewModel.nonDefaultAccountNotificationsCount > 0 && (!telecomManager.callInProgress || (telecomManager.callInProgress && !telecomManager.callDisplayed)) {
|
||||
HStack {
|
||||
Image("bell-simple")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 26, height: 26)
|
||||
.padding(.leading, 10)
|
||||
|
||||
if accountProfileViewModel.nonDefaultAccountNotificationsCount > 1 {
|
||||
Text(String(format: String(localized: "pending_notification_for_other_accounts_multiple"), accountProfileViewModel.nonDefaultAccountNotificationsCount.description))
|
||||
.default_text_style_white(styleSize: 16)
|
||||
} else {
|
||||
Text(String(localized: "pending_notification_for_other_accounts_single"))
|
||||
.default_text_style_white(styleSize: 16)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(
|
||||
action: {
|
||||
withAnimation {
|
||||
accountProfileViewModel.nonDefaultAccountNotificationsCount = 0
|
||||
}
|
||||
}, label: {
|
||||
Image("x")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 26, height: 26)
|
||||
.padding(.trailing, 10)
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 40)
|
||||
.padding(.horizontal, 10)
|
||||
.background(Color.gray)
|
||||
}
|
||||
|
||||
if sharedMainViewModel.waitingMessageCount > 0 && (!telecomManager.callInProgress || (telecomManager.callInProgress && !telecomManager.callDisplayed)) {
|
||||
HStack {
|
||||
Image("voicemail")
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ struct SideMenu: View {
|
|||
.onTapGesture {
|
||||
self.menuClose()
|
||||
}
|
||||
|
||||
VStack {
|
||||
VStack {
|
||||
HStack {
|
||||
|
|
@ -173,7 +174,16 @@ struct SideMenu: View {
|
|||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.leading, safeAreaInsets.leading)
|
||||
.padding(.top, TelecomManager.shared.callInProgress ? 0 : safeAreaInsets.top)
|
||||
.padding(
|
||||
.top,
|
||||
TelecomManager.shared.callInProgress
|
||||
|| accountProfileViewModel.accountError
|
||||
|| accountProfileViewModel.nonDefaultAccountNotificationsCount > 0
|
||||
|| SharedMainViewModel.shared.waitingMessageCount > 0
|
||||
|| !SharedMainViewModel.shared.fileUrlsToShare.isEmpty
|
||||
? 0
|
||||
: safeAreaInsets.top
|
||||
)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,11 @@ class AccountProfileViewModel: ObservableObject {
|
|||
@Published var accountModelIndex: Int? = 0
|
||||
@Published var defaultAccountModelIndex: Int? = 0
|
||||
@Published var accountError: Bool = false
|
||||
@Published var nonDefaultAccountNotificationsCount: Int = 0
|
||||
|
||||
init() {
|
||||
SharedMainViewModel.shared.getDialPlansList()
|
||||
computeNonDefaultAccountNotificationsCount()
|
||||
}
|
||||
|
||||
func saveChangesWhenLeaving() {
|
||||
|
|
@ -180,4 +182,25 @@ class AccountProfileViewModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func computeNonDefaultAccountNotificationsCount() {
|
||||
CoreContext.shared.doOnCoreQueue { core in
|
||||
var count = 0
|
||||
core.accountList.forEach { accountTmp in
|
||||
if let defaultAccount = core.defaultAccount?.params?.identityAddress, let accountAddress = accountTmp.params?.identityAddress, !defaultAccount.equal(address2: accountAddress) {
|
||||
count += accountTmp.unreadChatMessageCount + accountTmp.missedCallsCount
|
||||
}
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
Log.info("\(AccountProfileViewModel.TAG) Found \(count) pending notifications for other account(s)")
|
||||
} else {
|
||||
Log.info("\(AccountProfileViewModel.TAG) No pending notification found for other account(s)")
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.nonDefaultAccountNotificationsCount = count
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue