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-12-19 11:28:55 +00:00
|
|
|
import DesignSystem
|
2022-12-19 14:51:25 +00:00
|
|
|
import Network
|
2022-11-21 08:31:32 +00:00
|
|
|
|
2022-12-18 19:30:19 +00:00
|
|
|
public struct StatusRowView: View {
|
2022-12-17 12:37:46 +00:00
|
|
|
@Environment(\.redactionReasons) private var reasons
|
2022-12-19 14:51:25 +00:00
|
|
|
@EnvironmentObject private var client: Client
|
2022-11-29 10:46:02 +00:00
|
|
|
@EnvironmentObject private var routeurPath: RouterPath
|
|
|
|
|
2022-12-18 19:30:19 +00:00
|
|
|
private let status: Status
|
2022-12-19 11:28:55 +00:00
|
|
|
private let isEmbed: Bool
|
2022-12-18 19:30:19 +00:00
|
|
|
|
2022-12-19 11:28:55 +00:00
|
|
|
public init(status: Status, isEmbed: Bool = false) {
|
2022-12-18 19:30:19 +00:00
|
|
|
self.status = status
|
2022-12-19 11:28:55 +00:00
|
|
|
self.isEmbed = isEmbed
|
2022-12-18 19:30:19 +00:00
|
|
|
}
|
2022-11-21 08:31:32 +00:00
|
|
|
|
2022-12-18 19:30:19 +00:00
|
|
|
public var body: some View {
|
2022-11-21 08:31:32 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 12:16:48 +00:00
|
|
|
private var statusView: some View {
|
2022-12-20 08:37:07 +00:00
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
|
|
if let status: AnyStatus = status.reblog ?? status {
|
|
|
|
if !isEmbed {
|
|
|
|
Button {
|
|
|
|
routeurPath.navigate(to: .accountDetailWithAccount(account: status.account))
|
|
|
|
} label: {
|
|
|
|
makeAccountView(status: status)
|
|
|
|
}.buttonStyle(.plain)
|
|
|
|
}
|
|
|
|
|
|
|
|
Text(status.content.asSafeAttributedString)
|
|
|
|
.font(.body)
|
|
|
|
.onTapGesture {
|
|
|
|
routeurPath.navigate(to: .statusDetail(id: status.id))
|
|
|
|
}
|
|
|
|
.environment(\.openURL, OpenURLAction { url in
|
|
|
|
routeurPath.handleStatus(status: status, url: url)
|
|
|
|
})
|
|
|
|
|
|
|
|
if !status.mediaAttachments.isEmpty {
|
|
|
|
StatusMediaPreviewView(attachements: status.mediaAttachments)
|
|
|
|
.padding(.vertical, 4)
|
2022-12-16 12:16:48 +00:00
|
|
|
}
|
2022-12-20 08:37:07 +00:00
|
|
|
StatusCardView(status: status)
|
2022-12-17 12:37:46 +00:00
|
|
|
}
|
2022-12-16 12:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@ViewBuilder
|
|
|
|
private func makeAccountView(status: AnyStatus) -> some View {
|
2022-12-19 11:28:55 +00:00
|
|
|
AvatarView(url: status.account.avatar)
|
2022-11-29 10:46:02 +00:00
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text(status.account.displayName)
|
2022-12-20 08:37:07 +00:00
|
|
|
.font(.subheadline)
|
|
|
|
.fontWeight(.semibold)
|
|
|
|
Group {
|
|
|
|
Text("@\(status.account.acct)") +
|
|
|
|
Text(" ⸱ ") +
|
2022-12-17 12:37:46 +00:00
|
|
|
Text(status.createdAt.formatted)
|
2022-12-16 12:16:48 +00:00
|
|
|
}
|
2022-12-20 08:37:07 +00:00
|
|
|
.font(.footnote)
|
|
|
|
.foregroundColor(.gray)
|
2022-11-21 08:31:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|