mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-28 19:11:30 +00:00
Show status count and join date
This commit is contained in:
parent
8fdbfaf01e
commit
0c951f3c4d
4 changed files with 92 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
||||||
"account.header.accessibility-label-%@" = "Header image: %@";
|
"account.header.accessibility-label-%@" = "Header image: %@";
|
||||||
"account.hide-reblogs" = "Hide boosts";
|
"account.hide-reblogs" = "Hide boosts";
|
||||||
"account.hide-reblogs.confirm-%@" = "Hide boosts from %@?";
|
"account.hide-reblogs.confirm-%@" = "Hide boosts from %@?";
|
||||||
|
"account.joined-%@" = "Joined %@";
|
||||||
"account.locked.accessibility-label" = "Locked account";
|
"account.locked.accessibility-label" = "Locked account";
|
||||||
"account.mute" = "Mute";
|
"account.mute" = "Mute";
|
||||||
"account.mute.indefinite" = "Indefnite";
|
"account.mute.indefinite" = "Indefnite";
|
||||||
|
|
|
@ -82,6 +82,38 @@
|
||||||
<string>%ld Replies</string>
|
<string>%ld Replies</string>
|
||||||
</dict>
|
</dict>
|
||||||
</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>
|
<key>account.followers-count</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSStringLocalizedFormatKey</key>
|
<key>NSStringLocalizedFormatKey</key>
|
||||||
|
|
|
@ -47,6 +47,10 @@ public extension AccountViewModel {
|
||||||
|
|
||||||
var isLocked: Bool { accountService.account.locked }
|
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 fields: [Account.Field] { accountService.account.fields }
|
||||||
|
|
||||||
var note: NSAttributedString { accountService.account.note.attributed }
|
var note: NSAttributedString { accountService.account.note.attributed }
|
||||||
|
|
|
@ -22,6 +22,10 @@ final class AccountHeaderView: UIView {
|
||||||
let followsYouLabel = CapsuleLabel()
|
let followsYouLabel = CapsuleLabel()
|
||||||
let mutedLabel = CapsuleLabel()
|
let mutedLabel = CapsuleLabel()
|
||||||
let blockedLabel = CapsuleLabel()
|
let blockedLabel = CapsuleLabel()
|
||||||
|
let statusCountJoinedStackView = UIStackView()
|
||||||
|
let statusCountLabel = UILabel()
|
||||||
|
let statusCountJoinedSeparatorLabel = UILabel()
|
||||||
|
let joinedLabel = UILabel()
|
||||||
let fieldsStackView = UIStackView()
|
let fieldsStackView = UIStackView()
|
||||||
let noteTextView = TouchFallthroughTextView()
|
let noteTextView = TouchFallthroughTextView()
|
||||||
let followStackView = UIStackView()
|
let followStackView = UIStackView()
|
||||||
|
@ -98,6 +102,22 @@ final class AccountHeaderView: UIView {
|
||||||
|
|
||||||
accountStackView.accessibilityLabel = accountStackViewAccessibilityLabel
|
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 {
|
for view in fieldsStackView.arrangedSubviews {
|
||||||
fieldsStackView.removeArrangedSubview(view)
|
fieldsStackView.removeArrangedSubview(view)
|
||||||
view.removeFromSuperview()
|
view.removeFromSuperview()
|
||||||
|
@ -204,6 +224,13 @@ extension AccountHeaderView: UITextViewDelegate {
|
||||||
private extension AccountHeaderView {
|
private extension AccountHeaderView {
|
||||||
static let avatarDimension = CGFloat.avatarDimension * 2
|
static let avatarDimension = CGFloat.avatarDimension * 2
|
||||||
static let missingHeaderImageSize = CGSize(width: 1, height: 1)
|
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
|
// swiftlint:disable:next function_body_length
|
||||||
func initialSetup() {
|
func initialSetup() {
|
||||||
|
@ -320,6 +347,34 @@ private extension AccountHeaderView {
|
||||||
|
|
||||||
accountStackView.addArrangedSubview(UIView())
|
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)
|
baseStackView.addArrangedSubview(fieldsStackView)
|
||||||
fieldsStackView.axis = .vertical
|
fieldsStackView.axis = .vertical
|
||||||
fieldsStackView.spacing = .hairline
|
fieldsStackView.spacing = .hairline
|
||||||
|
|
Loading…
Reference in a new issue