Set placeholder-color for AvatarButton (IOS-238)

This commit is contained in:
Nathan Mattes 2024-05-21 17:43:53 +02:00
parent 16d6c9e823
commit 298886d3f5
4 changed files with 14 additions and 14 deletions

View File

@ -12,7 +12,7 @@ final class AccountListTableViewCell: UITableViewCell {
private var _disposeBag = Set<AnyCancellable>()
var disposeBag = Set<AnyCancellable>()
let avatarButton = CircleAvatarButton(frame: .zero)
let avatarButton = CircleAvatarButton()
let nameLabel = MetaLabel(style: .accountListName)
let usernameLabel = MetaLabel(style: .accountListUsername)
let badgeButton = BadgeButton()

View File

@ -17,17 +17,9 @@ open class AvatarButton: UIControl {
public var size = CGSize(width: 46, height: 46)
public let avatarImageView = AvatarImageView()
public override init(frame: CGRect) {
super.init(frame: frame)
_init()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
_init()
}
open func _init() {
public init(avatarPlaceholder: UIImage? = UIImage.placeholder(color: .systemFill)) {
super.init(frame: .zero)
avatarImageView.image = avatarPlaceholder
avatarImageView.frame = bounds
avatarImageView.translatesAutoresizingMaskIntoConstraints = false
addSubview(avatarImageView)
@ -37,7 +29,9 @@ open class AvatarButton: UIControl {
accessibilityLabel = L10n.Common.Controls.Status.showUserProfile
accessibilityTraits.insert(.image)
}
public required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented")}
public override func layoutSubviews() {
super.layoutSubviews()

View File

@ -14,6 +14,12 @@ public final class CircleAvatarButton: AvatarButton {
public var borderColor: UIColor = UIColor.systemFill
public var borderWidth: CGFloat = 2.0
public init() {
super.init(avatarPlaceholder: .placeholder(color: .systemFill))
}
public required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented")}
public override func updateAppearance() {
super.updateAppearance()

View File

@ -247,7 +247,7 @@ extension StatusView.ViewModel {
)
.sink { image, url in
let configuration: AvatarImageView.Configuration = {
if let image = image {
if let image {
return AvatarImageView.Configuration(image: image)
} else {
return AvatarImageView.Configuration(url: url)