chore: adapt notification title label to i18n string
This commit is contained in:
parent
0e9165f9e8
commit
65ac4c4b2b
|
@ -5715,7 +5715,7 @@
|
||||||
repositoryURL = "https://github.com/TwidereProject/MetaTextKit.git";
|
repositoryURL = "https://github.com/TwidereProject/MetaTextKit.git";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = 2.1.0;
|
version = 2.1.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = {
|
DB0E2D2C26833FF600865C3C /* XCRemoteSwiftPackageReference "Nuke-FLAnimatedImage-Plugin" */ = {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
<key>CoreDataStack.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>33</integer>
|
<integer>32</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
|
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>32</integer>
|
<integer>34</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>34</integer>
|
<integer>33</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
|
|
@ -96,8 +96,8 @@
|
||||||
"repositoryURL": "https://github.com/TwidereProject/MetaTextKit.git",
|
"repositoryURL": "https://github.com/TwidereProject/MetaTextKit.git",
|
||||||
"state": {
|
"state": {
|
||||||
"branch": null,
|
"branch": null,
|
||||||
"revision": "ccb54189b31d13868d979c33d43566912b765bbd",
|
"revision": "a5f412b72fc08cd1348e2388fc7ec326365e1823",
|
||||||
"version": "2.1.0"
|
"version": "2.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,23 +68,37 @@ extension NotificationSection {
|
||||||
.store(in: &cell.disposeBag)
|
.store(in: &cell.disposeBag)
|
||||||
|
|
||||||
// configure author name, notification description, timestamp
|
// configure author name, notification description, timestamp
|
||||||
|
let nameText = notification.account.displayNameWithFallback
|
||||||
|
let titleLabelText = "\(nameText) \(notification.notificationType.actionText)"
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let mastodonContent = MastodonContent(content: notification.account.displayNameWithFallback, emojis: notification.account.emojiMeta)
|
let nameContent = MastodonContent(content: nameText, emojis: notification.account.emojiMeta)
|
||||||
|
let nameMetaContent = try MastodonMetaContent.convert(document: nameContent)
|
||||||
|
|
||||||
|
let mastodonContent = MastodonContent(content: titleLabelText, emojis: notification.account.emojiMeta)
|
||||||
let metaContent = try MastodonMetaContent.convert(document: mastodonContent)
|
let metaContent = try MastodonMetaContent.convert(document: mastodonContent)
|
||||||
cell.nameLabel.configure(content: metaContent)
|
|
||||||
|
cell.titleLabel.configure(content: metaContent)
|
||||||
|
|
||||||
|
if let nameRange = metaContent.string.range(of: nameMetaContent.string) {
|
||||||
|
let nsRange = NSRange(nameRange, in: metaContent.string)
|
||||||
|
cell.titleLabel.textStorage.addAttributes([
|
||||||
|
.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold), maximumPointSize: 20),
|
||||||
|
.foregroundColor: Asset.Colors.brandBlue.color,
|
||||||
|
], range: nsRange)
|
||||||
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
let metaContent = PlaintextMetaContent(string: notification.account.displayNameWithFallback)
|
let metaContent = PlaintextMetaContent(string: titleLabelText)
|
||||||
cell.nameLabel.configure(content: metaContent)
|
cell.titleLabel.configure(content: metaContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
let createAt = notification.createAt
|
let createAt = notification.createAt
|
||||||
let actionText = notification.notificationType.actionText
|
|
||||||
cell.actionLabel.text = actionText
|
|
||||||
cell.timestampLabel.text = createAt.localizedTimeAgoSinceNow
|
cell.timestampLabel.text = createAt.localizedTimeAgoSinceNow
|
||||||
AppContext.shared.timestampUpdatePublisher
|
AppContext.shared.timestampUpdatePublisher
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak cell] _ in
|
.sink { [weak cell] _ in
|
||||||
guard let cell = cell else { return }
|
guard let cell = cell else { return }
|
||||||
cell.actionLabel.text = actionText
|
|
||||||
cell.timestampLabel.text = createAt.localizedTimeAgoSinceNow
|
cell.timestampLabel.text = createAt.localizedTimeAgoSinceNow
|
||||||
}
|
}
|
||||||
.store(in: &cell.disposeBag)
|
.store(in: &cell.disposeBag)
|
||||||
|
|
|
@ -13,7 +13,7 @@ extension MetaLabel {
|
||||||
enum Style {
|
enum Style {
|
||||||
case statusHeader
|
case statusHeader
|
||||||
case statusName
|
case statusName
|
||||||
case notificationName
|
case notificationTitle
|
||||||
case profileFieldName
|
case profileFieldName
|
||||||
case profileFieldValue
|
case profileFieldValue
|
||||||
case recommendAccountName
|
case recommendAccountName
|
||||||
|
@ -26,6 +26,7 @@ extension MetaLabel {
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
layer.masksToBounds = true
|
layer.masksToBounds = true
|
||||||
|
lineBreakMode = .byTruncatingTail
|
||||||
textContainer.lineBreakMode = .byTruncatingTail
|
textContainer.lineBreakMode = .byTruncatingTail
|
||||||
textContainer.lineFragmentPadding = 0
|
textContainer.lineFragmentPadding = 0
|
||||||
|
|
||||||
|
@ -41,9 +42,9 @@ extension MetaLabel {
|
||||||
font = .systemFont(ofSize: 17, weight: .semibold)
|
font = .systemFont(ofSize: 17, weight: .semibold)
|
||||||
textColor = Asset.Colors.Label.primary.color
|
textColor = Asset.Colors.Label.primary.color
|
||||||
|
|
||||||
case .notificationName:
|
case .notificationTitle:
|
||||||
font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold), maximumPointSize: 20)
|
font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
|
||||||
textColor = Asset.Colors.brandBlue.color
|
textColor = Asset.Colors.Label.secondary.color
|
||||||
|
|
||||||
case .profileFieldName:
|
case .profileFieldName:
|
||||||
font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 20)
|
font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 20)
|
||||||
|
@ -54,7 +55,6 @@ extension MetaLabel {
|
||||||
textColor = Asset.Colors.Label.primary.color
|
textColor = Asset.Colors.Label.primary.color
|
||||||
textAlignment = .right
|
textAlignment = .right
|
||||||
|
|
||||||
|
|
||||||
case .titleView:
|
case .titleView:
|
||||||
font = .systemFont(ofSize: 17, weight: .semibold)
|
font = .systemFont(ofSize: 17, weight: .semibold)
|
||||||
textColor = Asset.Colors.Label.primary.color
|
textColor = Asset.Colors.Label.primary.color
|
||||||
|
|
|
@ -49,13 +49,8 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
|
||||||
|
|
||||||
let contentStackView = UIStackView()
|
let contentStackView = UIStackView()
|
||||||
|
|
||||||
let actionLabel: UILabel = {
|
let titleLabel = MetaLabel(style: .notificationTitle)
|
||||||
let label = UILabel()
|
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
|
||||||
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
|
|
||||||
label.lineBreakMode = .byTruncatingTail
|
|
||||||
return label
|
|
||||||
}()
|
|
||||||
let dotLabel: UILabel = {
|
let dotLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
label.textColor = Asset.Colors.Label.secondary.color
|
||||||
|
@ -70,7 +65,6 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
let nameLabel = MetaLabel(style: .notificationName)
|
|
||||||
|
|
||||||
let buttonStackView = UIStackView()
|
let buttonStackView = UIStackView()
|
||||||
|
|
||||||
|
@ -181,17 +175,15 @@ extension NotificationStatusTableViewCell {
|
||||||
actionStackView.distribution = .fill
|
actionStackView.distribution = .fill
|
||||||
actionStackView.spacing = 4
|
actionStackView.spacing = 4
|
||||||
|
|
||||||
actionStackView.addArrangedSubview(nameLabel)
|
actionStackView.addArrangedSubview(titleLabel)
|
||||||
actionStackView.addArrangedSubview(actionLabel)
|
|
||||||
actionStackView.addArrangedSubview(dotLabel)
|
actionStackView.addArrangedSubview(dotLabel)
|
||||||
actionStackView.addArrangedSubview(timestampLabel)
|
actionStackView.addArrangedSubview(timestampLabel)
|
||||||
let timestampPaddingView = UIView()
|
let timestampPaddingView = UIView()
|
||||||
actionStackView.addArrangedSubview(timestampPaddingView)
|
actionStackView.addArrangedSubview(timestampPaddingView)
|
||||||
nameLabel.setContentHuggingPriority(.required - 3, for: .horizontal)
|
titleLabel.setContentHuggingPriority(.required - 3, for: .horizontal)
|
||||||
nameLabel.setContentHuggingPriority(.required - 1, for: .vertical)
|
titleLabel.setContentHuggingPriority(.required - 1, for: .vertical)
|
||||||
nameLabel.setContentCompressionResistancePriority(.required - 3, for: .horizontal)
|
titleLabel.setContentCompressionResistancePriority(.required - 3, for: .horizontal)
|
||||||
nameLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
|
titleLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical)
|
||||||
actionLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
||||||
dotLabel.setContentHuggingPriority(.required - 2, for: .horizontal)
|
dotLabel.setContentHuggingPriority(.required - 2, for: .horizontal)
|
||||||
dotLabel.setContentCompressionResistancePriority(.required - 2, for: .horizontal)
|
dotLabel.setContentCompressionResistancePriority(.required - 2, for: .horizontal)
|
||||||
timestampLabel.setContentHuggingPriority(.required - 1, for: .horizontal)
|
timestampLabel.setContentHuggingPriority(.required - 1, for: .horizontal)
|
||||||
|
@ -255,7 +247,7 @@ extension NotificationStatusTableViewCell {
|
||||||
avatarButton.addTarget(self, action: #selector(NotificationStatusTableViewCell.avatarButtonDidPressed(_:)), for: .touchUpInside)
|
avatarButton.addTarget(self, action: #selector(NotificationStatusTableViewCell.avatarButtonDidPressed(_:)), for: .touchUpInside)
|
||||||
let authorNameLabelTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
let authorNameLabelTapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
|
||||||
authorNameLabelTapGestureRecognizer.addTarget(self, action: #selector(NotificationStatusTableViewCell.authorNameLabelTapGestureRecognizerHandler(_:)))
|
authorNameLabelTapGestureRecognizer.addTarget(self, action: #selector(NotificationStatusTableViewCell.authorNameLabelTapGestureRecognizerHandler(_:)))
|
||||||
nameLabel.addGestureRecognizer(authorNameLabelTapGestureRecognizer)
|
titleLabel.addGestureRecognizer(authorNameLabelTapGestureRecognizer)
|
||||||
|
|
||||||
resetSeparatorLineLayout()
|
resetSeparatorLineLayout()
|
||||||
|
|
||||||
|
@ -303,7 +295,7 @@ extension NotificationStatusTableViewCell {
|
||||||
|
|
||||||
@objc private func authorNameLabelTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
@objc private func authorNameLabelTapGestureRecognizerHandler(_ sender: UITapGestureRecognizer) {
|
||||||
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
||||||
delegate?.notificationStatusTableViewCell(self, authorNameLabelDidPressed: nameLabel)
|
delegate?.notificationStatusTableViewCell(self, authorNameLabelDidPressed: titleLabel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue