diff --git a/Localizations/Localizable.strings b/Localizations/Localizable.strings index 0739814..4dde9a7 100644 --- a/Localizations/Localizable.strings +++ b/Localizations/Localizable.strings @@ -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"; diff --git a/Localizations/Localizable.stringsdict b/Localizations/Localizable.stringsdict index 02775f5..1f0ca01 100644 --- a/Localizations/Localizable.stringsdict +++ b/Localizations/Localizable.stringsdict @@ -82,6 +82,38 @@ %ld Replies + statuses.count.post-%ld + + NSStringLocalizedFormatKey + %#@posts@ + posts + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + one + %ld Post + other + %ld Posts + + + statuses.count.toot-%ld + + NSStringLocalizedFormatKey + %#@toots@ + toots + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + ld + one + %ld Toot + other + %ld Toots + + account.followers-count NSStringLocalizedFormatKey diff --git a/ViewModels/Sources/ViewModels/View Models/AccountViewModel.swift b/ViewModels/Sources/ViewModels/View Models/AccountViewModel.swift index 73f477a..b48903b 100644 --- a/ViewModels/Sources/ViewModels/View Models/AccountViewModel.swift +++ b/ViewModels/Sources/ViewModels/View Models/AccountViewModel.swift @@ -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 } diff --git a/Views/UIKit/AccountHeaderView.swift b/Views/UIKit/AccountHeaderView.swift index 40983b2..8714619 100644 --- a/Views/UIKit/AccountHeaderView.swift +++ b/Views/UIKit/AccountHeaderView.swift @@ -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