forked from shadowfacts/Tusker
48 lines
1.5 KiB
Swift
48 lines
1.5 KiB
Swift
//
|
|
// ComposeStatusReplyView.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 1/6/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
class ComposeStatusReplyView: UIView {
|
|
|
|
@IBOutlet weak var avatarImageView: UIImageView!
|
|
@IBOutlet weak var displayNameLabel: UILabel!
|
|
@IBOutlet weak var usernameLabel: UILabel!
|
|
@IBOutlet weak var contentLabel: StatusContentLabel!
|
|
|
|
static func create() -> ComposeStatusReplyView {
|
|
return UINib(nibName: "ComposeStatusReplyView", bundle: nil).instantiate(withOwner: nil, options: nil).first as! ComposeStatusReplyView
|
|
}
|
|
|
|
override func awakeFromNib() {
|
|
super.awakeFromNib()
|
|
|
|
updateUIForPreferences()
|
|
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
|
|
}
|
|
|
|
@objc func updateUIForPreferences() {
|
|
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
|
|
}
|
|
|
|
func updateUI(for status: Status) {
|
|
displayNameLabel.text = status.account.realDisplayName
|
|
usernameLabel.text = "@\(status.account.acct)"
|
|
contentLabel.statusID = status.id
|
|
|
|
ImageCache.avatars.get(status.account.avatar) { (data) in
|
|
guard let data = data else { return }
|
|
DispatchQueue.main.async {
|
|
self.avatarImageView.image = UIImage(data: data)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|