2022-11-21 08:31:32 +00:00
|
|
|
import SwiftUI
|
2022-11-29 08:28:17 +00:00
|
|
|
import Models
|
2022-11-29 10:46:02 +00:00
|
|
|
import Routeur
|
2022-11-21 08:31:32 +00:00
|
|
|
|
|
|
|
struct StatusRowView: View {
|
2022-11-29 10:46:02 +00:00
|
|
|
@EnvironmentObject private var routeurPath: RouterPath
|
|
|
|
|
2022-11-21 08:31:32 +00:00
|
|
|
let status: Status
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
VStack(alignment: .leading) {
|
2022-12-16 12:16:48 +00:00
|
|
|
reblogView
|
|
|
|
statusView
|
|
|
|
StatusActionsView(status: status)
|
|
|
|
.padding(.vertical, 8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
private var reblogView: some View {
|
|
|
|
if status.reblog != nil {
|
|
|
|
HStack(spacing: 2) {
|
|
|
|
Image(systemName:"arrow.left.arrow.right.circle")
|
|
|
|
Text("\(status.account.displayName) reblogged")
|
2022-11-29 10:46:02 +00:00
|
|
|
}
|
2022-12-16 12:16:48 +00:00
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
.fontWeight(.semibold)
|
2022-11-29 10:46:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
2022-12-16 12:16:48 +00:00
|
|
|
private var statusView: some View {
|
|
|
|
if let status: AnyStatus = status.reblog ?? status {
|
|
|
|
Button {
|
|
|
|
routeurPath.navigate(to: .accountDetail(id: status.account.id))
|
|
|
|
} label: {
|
|
|
|
makeAccountView(status: status)
|
|
|
|
}.buttonStyle(.plain)
|
|
|
|
|
|
|
|
Text(try! AttributedString(markdown: status.contentAsMarkdown))
|
|
|
|
.font(.body)
|
|
|
|
.onTapGesture {
|
|
|
|
routeurPath.navigate(to: .statusDetail(id: status.id))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
private func makeAccountView(status: AnyStatus) -> some View {
|
2022-11-29 10:46:02 +00:00
|
|
|
AsyncImage(
|
|
|
|
url: status.account.avatar,
|
|
|
|
content: { image in
|
|
|
|
image.resizable()
|
|
|
|
.aspectRatio(contentMode: .fit)
|
|
|
|
.cornerRadius(4)
|
|
|
|
.frame(maxWidth: 40, maxHeight: 40)
|
|
|
|
},
|
|
|
|
placeholder: {
|
|
|
|
ProgressView()
|
|
|
|
.frame(maxWidth: 40, maxHeight: 40)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text(status.account.displayName)
|
|
|
|
.font(.headline)
|
2022-12-16 12:16:48 +00:00
|
|
|
HStack {
|
|
|
|
Text("@\(status.account.acct)")
|
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
Spacer()
|
|
|
|
Text(status.createdAtFormatted)
|
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
}
|
2022-11-21 08:31:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|