Show status count and join date

This commit is contained in:
Justin Mazzocchi 2021-02-10 21:20:42 -08:00
parent 8fdbfaf01e
commit 0c951f3c4d
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 92 additions and 0 deletions

View file

@ -24,6 +24,7 @@
"account.header.accessibility-label-%@" = "Header image: %@";
"account.hide-reblogs" = "Hide boosts";
"account.hide-reblogs.confirm-%@" = "Hide boosts from %@?";
"account.joined-%@" = "Joined %@";
"account.locked.accessibility-label" = "Locked account";
"account.mute" = "Mute";
"account.mute.indefinite" = "Indefnite";

View file

@ -82,6 +82,38 @@
<string>%ld Replies</string>
</dict>
</dict>
<key>statuses.count.post-%ld</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@posts@</string>
<key>posts</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>one</key>
<string>%ld Post</string>
<key>other</key>
<string>%ld Posts</string>
</dict>
</dict>
<key>statuses.count.toot-%ld</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@toots@</string>
<key>toots</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>one</key>
<string>%ld Toot</string>
<key>other</key>
<string>%ld Toots</string>
</dict>
</dict>
<key>account.followers-count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>

View file

@ -47,6 +47,10 @@ public extension AccountViewModel {
var isLocked: Bool { accountService.account.locked }
var statusesCount: Int { accountService.account.statusesCount }
var joined: Date { accountService.account.createdAt }
var fields: [Account.Field] { accountService.account.fields }
var note: NSAttributedString { accountService.account.note.attributed }

View file

@ -22,6 +22,10 @@ final class AccountHeaderView: UIView {
let followsYouLabel = CapsuleLabel()
let mutedLabel = CapsuleLabel()
let blockedLabel = CapsuleLabel()
let statusCountJoinedStackView = UIStackView()
let statusCountLabel = UILabel()
let statusCountJoinedSeparatorLabel = UILabel()
let joinedLabel = UILabel()
let fieldsStackView = UIStackView()
let noteTextView = TouchFallthroughTextView()
let followStackView = UIStackView()
@ -98,6 +102,22 @@ final class AccountHeaderView: UIView {
accountStackView.accessibilityLabel = accountStackViewAccessibilityLabel
let statusCountFormat: String
switch viewModel.identityContext.appPreferences.statusWord {
case .toot:
statusCountFormat = NSLocalizedString("statuses.count.toot-%ld", comment: "")
case .post:
statusCountFormat = NSLocalizedString("statuses.count.post-%ld", comment: "")
}
statusCountLabel.text = String.localizedStringWithFormat(
statusCountFormat,
accountViewModel.statusesCount)
joinedLabel.text = String.localizedStringWithFormat(
NSLocalizedString("account.joined-%@", comment: ""),
Self.joinedDateFormatter.string(from: accountViewModel.joined))
for view in fieldsStackView.arrangedSubviews {
fieldsStackView.removeArrangedSubview(view)
view.removeFromSuperview()
@ -204,6 +224,13 @@ extension AccountHeaderView: UITextViewDelegate {
private extension AccountHeaderView {
static let avatarDimension = CGFloat.avatarDimension * 2
static let missingHeaderImageSize = CGSize(width: 1, height: 1)
static let joinedDateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .short
return formatter
}()
// swiftlint:disable:next function_body_length
func initialSetup() {
@ -320,6 +347,34 @@ private extension AccountHeaderView {
accountStackView.addArrangedSubview(UIView())
baseStackView.addArrangedSubview(statusCountJoinedStackView)
statusCountJoinedStackView.spacing = .compactSpacing
statusCountJoinedStackView.addArrangedSubview(statusCountLabel)
statusCountLabel.font = .preferredFont(forTextStyle: .footnote)
statusCountLabel.adjustsFontForContentSizeCategory = true
statusCountLabel.textColor = .tertiaryLabel
statusCountLabel.setContentHuggingPriority(.required, for: .horizontal)
statusCountLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
statusCountJoinedStackView.addArrangedSubview(statusCountJoinedSeparatorLabel)
statusCountJoinedSeparatorLabel.font = .preferredFont(forTextStyle: .footnote)
statusCountJoinedSeparatorLabel.adjustsFontForContentSizeCategory = true
statusCountJoinedSeparatorLabel.textColor = .tertiaryLabel
statusCountJoinedSeparatorLabel.setContentHuggingPriority(.required, for: .horizontal)
statusCountJoinedSeparatorLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
statusCountJoinedSeparatorLabel.text = ""
statusCountJoinedSeparatorLabel.isAccessibilityElement = false
statusCountJoinedStackView.addArrangedSubview(joinedLabel)
joinedLabel.font = .preferredFont(forTextStyle: .footnote)
joinedLabel.adjustsFontForContentSizeCategory = true
joinedLabel.textColor = .tertiaryLabel
joinedLabel.setContentHuggingPriority(.required, for: .horizontal)
joinedLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
statusCountJoinedStackView.addArrangedSubview(UIView())
baseStackView.addArrangedSubview(fieldsStackView)
fieldsStackView.axis = .vertical
fieldsStackView.spacing = .hairline