Editor: Add response context

This commit is contained in:
Thomas Ricouard 2023-01-05 18:54:18 +01:00
parent 6a162471f5
commit 039eab0d06
4 changed files with 16 additions and 6 deletions

View File

@ -33,11 +33,18 @@ public struct StatusEditorView: View {
TextView($viewModel.statusText, $viewModel.selectedRange)
.placeholder("What's on your mind")
.padding(.horizontal, .layoutPadding)
StatusEditorMediaView(viewModel: viewModel)
if let status = viewModel.embededStatus {
StatusEmbededView(status: status)
.padding(.horizontal, .layoutPadding)
.disabled(true)
} else if let status = viewModel.replyToStatus {
Divider()
.padding(.top, 20)
StatusEmbededView(status: status)
.padding(.horizontal, .layoutPadding)
.disabled(true)
}
StatusEditorMediaView(viewModel: viewModel)
Spacer()
}
.padding(.top, 8)

View File

@ -31,9 +31,9 @@ extension StatusEditorViewModel {
case .new, .mention:
return "New Post"
case .edit:
return "Edit your post"
return "Editing your post"
case let .replyTo(status):
return "Reply to \(status.reblog?.account.displayName ?? status.account.displayName)"
return "Replying to \(status.reblog?.account.displayName ?? status.account.displayName)"
case let .quote(status):
return "Quote of \(status.reblog?.account.displayName ?? status.account.displayName)"
}

View File

@ -39,10 +39,10 @@ public struct StatusRowView: View {
VStack(alignment: .leading) {
if !viewModel.isCompact {
reblogView
replyView
replyView
}
statusView
if !viewModel.isCompact {
if !viewModel.isCompact && viewModel.showActions {
StatusActionsView(viewModel: viewModel)
.padding(.vertical, 8)
.tint(viewModel.isFocused ? theme.tintColor : .gray)

View File

@ -7,6 +7,7 @@ public class StatusRowViewModel: ObservableObject {
let status: Status
let isCompact: Bool
let isFocused: Bool
let showActions: Bool
@Published var favouritesCount: Int
@Published var isFavourited: Bool
@ -27,10 +28,12 @@ public class StatusRowViewModel: ObservableObject {
public init(status: Status,
isCompact: Bool = false,
isFocused: Bool = false) {
isFocused: Bool = false,
showActions: Bool = true) {
self.status = status
self.isCompact = isCompact
self.isFocused = isFocused
self.showActions = showActions
if let reblog = status.reblog {
self.isFavourited = reblog.favourited == true
self.isReblogged = reblog.reblogged == true