Display timer on outgoing call view

This commit is contained in:
Christophe Deschamps 2022-06-14 22:18:59 +02:00
parent be80f0d342
commit 95449cc7c5
2 changed files with 11 additions and 3 deletions

View file

@ -43,7 +43,7 @@ import linphonesw
var callData: CallData? = nil {
didSet {
duration.call = callData?.call
duration.call = callData?.call.dir == .Incoming ? callData?.call : nil
callData?.call.remoteAddress.map {
avatar.fillFromAddress(address: $0)
displayName.text = $0.addressBookEnhancedDisplayName()

View file

@ -35,7 +35,7 @@ class CallTimer : StyledLabel {
var conference:Conference? = nil {
didSet {
if (self.call != nil) {
if (self.conference != nil) {
self.format()
}
}
@ -51,8 +51,16 @@ class CallTimer : StyledLabel {
formatter.unitsStyle = .positional
formatter.allowedUnits = [.minute, .second ]
formatter.zeroFormattingBehavior = [ .pad ]
let startDate = Date()
Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
self.format()
if (self.call != nil || self.conference != nil) {
self.format()
} else {
let elapsedTime = Date().timeIntervalSince(startDate)
self.formatter.string(from: elapsedTime).map {
self.text = $0.hasPrefix("0:") ? "0" + $0 : $0
}
}
}
minWidth(min_width).done()