mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Set placeholder-color for AvatarButton (IOS-238)
This commit is contained in:
parent
16d6c9e823
commit
298886d3f5
@ -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()
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user