Avatar icon colour fixes

This commit is contained in:
Christophe Deschamps 2022-11-03 08:39:02 +01:00
parent 44cf121007
commit df53cc73e9
2 changed files with 18 additions and 10 deletions

View file

@ -88,7 +88,7 @@ import UIKit
static let call_header_subtitle = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: false, align: .center, font: fontName+"-Regular", size: 14.0)
static let call_generated_avatar_large = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Regular", size: 53.0)
static let call_generated_avatar_medium = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Regular", size: 27.0)
static let call_generated_avatar_small = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Regular", size: 16.0)
static let call_generated_avatar_small = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: true, align: .center, font: fontName+"-Bold", size: 25.0)
static let dtmf_label = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: false, align: .center, font: fontName+"-Regular", size: 30.0)
static let call_remote_name = TextStyle(fgColor: LightDarkColor(.white,.white), bgColor: LightDarkColor(.clear,.clear), allCaps: false, align: .left, font: fontName+"-Regular", size: 18.0)

View file

@ -21,12 +21,12 @@ import Foundation
import linphonesw
import SnapKit
class Avatar : UIImageView {
class Avatar : UIView {
static let diameter_for_call_views = 191
static let diameter_for_call_views_land = 130
static let groupAvatar = UIImage(named:"voip_multiple_contacts_avatar")
static let singleAvatar = UIImage(named:"avatar")?.tinted(with: .white)
static let singleAvatar = UIImage(named:"avatar")
required init?(coder: NSCoder) {
initialsLabel = StyledLabel(VoipTheme.call_generated_avatar_large)
@ -34,39 +34,47 @@ class Avatar : UIImageView {
}
let initialsLabel: StyledLabel
let iconImageView = UIImageView()
init (color:LightDarkColor,textStyle:TextStyle) {
initialsLabel = StyledLabel(textStyle)
super.init(frame: .zero)
clipsToBounds = true
self.backgroundColor = color.get()
addSubview(initialsLabel)
_ = initialsLabel.matchParentSideBorders().matchParentHeight()
addSubview(iconImageView)
iconImageView.backgroundColor = .white
initialsLabel.matchParentSideBorders().matchParentHeight().done()
iconImageView.matchParentDimmensions().done()
}
func fillFromAddress(address:Address, isGroup:Bool = false) {
if (isGroup) {
self.image = Avatar.groupAvatar
iconImageView.image = Avatar.groupAvatar
iconImageView.isHidden = false
initialsLabel.isHidden = true
} else if let image = address.contact()?.avatar() {
self.image = image
iconImageView.image = image
initialsLabel.isHidden = true
iconImageView.isHidden = false
} else {
if (Core.get().defaultAccount?.isPhoneNumber(username: address.username) == true) {
self.image = Avatar.singleAvatar
iconImageView.image = Avatar.singleAvatar
initialsLabel.isHidden = true
iconImageView.isHidden = false
} else {
self.image = nil
initialsLabel.text = address.initials()
initialsLabel.isHidden = false
iconImageView.isHidden = true
}
}
}
func showAsAvatarIcon() {
self.image = Avatar.singleAvatar
iconImageView.image = Avatar.singleAvatar
initialsLabel.isHidden = true
iconImageView.isHidden = false
}
override func layoutSubviews() {