From 5ab64968e3a7a0774128edf9dd6d425c854ba394 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Thu, 25 Jan 2024 12:14:14 +0100 Subject: [PATCH] Add a badge counter for call list in call view --- Linphone/Localizable.xcstrings | 9 ++ Linphone/UI/Call/CallView.swift | 91 ++++++++++++++----- .../UI/Call/ViewModel/CallViewModel.swift | 2 + 3 files changed, 78 insertions(+), 24 deletions(-) diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index 4701df22a..7b60b114f 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -48,6 +48,9 @@ }, "#" : { + }, + "%lld" : { + }, "%lld Book (Example)" : { "extractionState" : "manual", @@ -226,6 +229,9 @@ }, "Contacts" : { + }, + "Content" : { + }, "Continue" : { @@ -549,6 +555,9 @@ }, "This contact will be deleted definitively." : { + }, + "Title" : { + }, "TLS" : { diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index 17ade1bfe..ddf800f88 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -783,21 +783,43 @@ struct CallView: View { .frame(width: geo.size.width * 0.25, height: geo.size.width * 0.25) VStack { - Button { - callViewModel.getCallsList() - withAnimation { - isShowCallsListFragment.toggle() + ZStack { + Button { + callViewModel.getCallsList() + withAnimation { + isShowCallsListFragment.toggle() + } + } label: { + Image("phone-list") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 32, height: 32) + } + .frame(width: 60, height: 60) + .background(Color.gray500) + .cornerRadius(40) + + if callViewModel.calls.count > 1 { + VStack { + HStack { + Spacer() + + VStack { + Text("\(callViewModel.calls.count)") + .foregroundStyle(.white) + .default_text_style(styleSize: 15) + } + .frame(width: 20, height: 20) + .background(Color.redDanger500) + .cornerRadius(10) + } + + Spacer() + } + .frame(width: 60, height: 60) } - } label: { - Image("phone-list") - .renderingMode(.template) - .resizable() - .foregroundStyle(.white) - .frame(width: 32, height: 32) } - .frame(width: 60, height: 60) - .background(Color.gray500) - .cornerRadius(40) Text("Call list") .foregroundStyle(.white) @@ -962,18 +984,39 @@ struct CallView: View { .frame(width: geo.size.width * 0.125, height: geo.size.width * 0.125) VStack { - Button { - } label: { - Image("phone-list") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.gray500) - .frame(width: 32, height: 32) + ZStack { + Button { + } label: { + Image("phone-list") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 32, height: 32) + } + .frame(width: 60, height: 60) + .background(Color.gray500) + .cornerRadius(40) + + if callViewModel.calls.count > 1 { + VStack { + HStack { + Spacer() + + VStack { + Text("\(callViewModel.calls.count)") + .foregroundStyle(.white) + .default_text_style(styleSize: 15) + } + .frame(width: 20, height: 20) + .background(Color.redDanger500) + .cornerRadius(10) + } + + Spacer() + } + .frame(width: 60, height: 60) + } } - .frame(width: 60, height: 60) - .background(Color.gray600) - .cornerRadius(40) - .disabled(true) Text("Call list") .foregroundStyle(.white) diff --git a/Linphone/UI/Call/ViewModel/CallViewModel.swift b/Linphone/UI/Call/ViewModel/CallViewModel.swift index 997f70f45..cb6ebb2cf 100644 --- a/Linphone/UI/Call/ViewModel/CallViewModel.swift +++ b/Linphone/UI/Call/ViewModel/CallViewModel.swift @@ -107,6 +107,8 @@ class CallViewModel: ObservableObject { let authToken = self.currentCall!.authenticationToken let isDeviceTrusted = self.currentCall!.authenticationTokenVerified && authToken != nil self.isRemoteDeviceTrusted = self.telecomManager.callInProgress ? isDeviceTrusted : false + + self.getCallsList() } self.callSuscriptions.insert(self.currentCall!.publisher?.onEncryptionChanged?.postOnMainQueue {(cbVal: (call: Call, on: Bool, authenticationToken: String?)) in