Refactoring
This commit is contained in:
parent
f99b74dd98
commit
cb74fd42be
|
@ -6,10 +6,9 @@ import Mastodon
|
||||||
import ServiceLayer
|
import ServiceLayer
|
||||||
|
|
||||||
public final class StatusViewModel: AttachmentsRenderingViewModel, ObservableObject {
|
public final class StatusViewModel: AttachmentsRenderingViewModel, ObservableObject {
|
||||||
|
public let accountViewModel: AccountViewModel
|
||||||
public let content: NSAttributedString
|
public let content: NSAttributedString
|
||||||
public let contentEmojis: [Emoji]
|
public let contentEmojis: [Emoji]
|
||||||
public let displayName: String
|
|
||||||
public let displayNameEmojis: [Emoji]
|
|
||||||
public let spoilerText: String
|
public let spoilerText: String
|
||||||
public let isReblog: Bool
|
public let isReblog: Bool
|
||||||
public let rebloggedByDisplayName: String
|
public let rebloggedByDisplayName: String
|
||||||
|
@ -29,12 +28,13 @@ public final class StatusViewModel: AttachmentsRenderingViewModel, ObservableObj
|
||||||
self.statusService = statusService
|
self.statusService = statusService
|
||||||
self.identityContext = identityContext
|
self.identityContext = identityContext
|
||||||
self.eventsSubject = eventsSubject
|
self.eventsSubject = eventsSubject
|
||||||
|
accountViewModel = AccountViewModel(
|
||||||
|
accountService: statusService.navigationService
|
||||||
|
.accountService(account: statusService.status.displayStatus.account),
|
||||||
|
identityContext: identityContext,
|
||||||
|
eventsSubject: eventsSubject)
|
||||||
content = statusService.status.displayStatus.content.attributed
|
content = statusService.status.displayStatus.content.attributed
|
||||||
contentEmojis = statusService.status.displayStatus.emojis
|
contentEmojis = statusService.status.displayStatus.emojis
|
||||||
displayName = statusService.status.displayStatus.account.displayName.isEmpty
|
|
||||||
? statusService.status.displayStatus.account.username
|
|
||||||
: statusService.status.displayStatus.account.displayName
|
|
||||||
displayNameEmojis = statusService.status.displayStatus.account.emojis
|
|
||||||
spoilerText = statusService.status.displayStatus.spoilerText
|
spoilerText = statusService.status.displayStatus.spoilerText
|
||||||
isReblog = statusService.status.reblog != nil
|
isReblog = statusService.status.reblog != nil
|
||||||
rebloggedByDisplayName = statusService.status.account.displayName.isEmpty
|
rebloggedByDisplayName = statusService.status.account.displayName.isEmpty
|
||||||
|
|
|
@ -341,7 +341,7 @@ private extension StatusView {
|
||||||
func applyStatusConfiguration() {
|
func applyStatusConfiguration() {
|
||||||
let viewModel = statusConfiguration.viewModel
|
let viewModel = statusConfiguration.viewModel
|
||||||
let isContextParent = viewModel.configuration.isContextParent
|
let isContextParent = viewModel.configuration.isContextParent
|
||||||
let mutableDisplayName = NSMutableAttributedString(string: viewModel.displayName)
|
let mutableDisplayName = NSMutableAttributedString(string: viewModel.accountViewModel.displayName)
|
||||||
let isAuthenticated = viewModel.identityContext.identity.authenticated
|
let isAuthenticated = viewModel.identityContext.identity.authenticated
|
||||||
&& !viewModel.identityContext.identity.pending
|
&& !viewModel.identityContext.identity.pending
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ private extension StatusView {
|
||||||
avatarImageView.kf.setImage(with: viewModel.avatarURL)
|
avatarImageView.kf.setImage(with: viewModel.avatarURL)
|
||||||
avatarButton.accessibilityLabel = String.localizedStringWithFormat(
|
avatarButton.accessibilityLabel = String.localizedStringWithFormat(
|
||||||
NSLocalizedString("account.avatar.accessibility-label-%@", comment: ""),
|
NSLocalizedString("account.avatar.accessibility-label-%@", comment: ""),
|
||||||
viewModel.displayName)
|
viewModel.accountViewModel.displayName)
|
||||||
|
|
||||||
sideStackView.isHidden = isContextParent
|
sideStackView.isHidden = isContextParent
|
||||||
avatarImageView.removeFromSuperview()
|
avatarImageView.removeFromSuperview()
|
||||||
|
@ -406,7 +406,7 @@ private extension StatusView {
|
||||||
infoIcon.isHidden = true
|
infoIcon.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
mutableDisplayName.insert(emojis: viewModel.displayNameEmojis, view: displayNameLabel)
|
mutableDisplayName.insert(emojis: viewModel.accountViewModel.emojis, view: displayNameLabel)
|
||||||
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
|
mutableDisplayName.resizeAttachments(toLineHeight: displayNameLabel.font.lineHeight)
|
||||||
displayNameLabel.attributedText = mutableDisplayName
|
displayNameLabel.attributedText = mutableDisplayName
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue