2023-02-10 11:12:22 +00:00
|
|
|
import DesignSystem
|
2023-02-12 15:29:41 +00:00
|
|
|
import Env
|
2023-02-10 11:12:22 +00:00
|
|
|
import Models
|
2023-02-12 15:29:41 +00:00
|
|
|
import SwiftUI
|
2023-02-10 11:12:22 +00:00
|
|
|
|
|
|
|
struct StatusRowDetailView: View {
|
|
|
|
@Environment(\.openURL) private var openURL
|
2023-03-13 12:38:28 +00:00
|
|
|
|
2023-02-28 05:58:52 +00:00
|
|
|
@EnvironmentObject private var statusDataController: StatusDataController
|
2023-02-12 15:29:41 +00:00
|
|
|
|
2023-02-10 11:12:22 +00:00
|
|
|
@ObservedObject var viewModel: StatusRowViewModel
|
2023-02-12 15:29:41 +00:00
|
|
|
|
2023-02-10 11:12:22 +00:00
|
|
|
var body: some View {
|
|
|
|
Group {
|
|
|
|
Divider()
|
|
|
|
HStack {
|
|
|
|
Text(viewModel.status.createdAt.asDate, style: .date) +
|
|
|
|
Text("status.summary.at-time") +
|
|
|
|
Text(viewModel.status.createdAt.asDate, style: .time) +
|
|
|
|
Text(" ·")
|
|
|
|
Image(systemName: viewModel.status.visibility.iconName)
|
|
|
|
Spacer()
|
|
|
|
Text(viewModel.status.application?.name ?? "")
|
|
|
|
.underline()
|
|
|
|
.onTapGesture {
|
|
|
|
if let url = viewModel.status.application?.website {
|
|
|
|
openURL(url)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.font(.scaledCaption)
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
|
|
|
|
if let editedAt = viewModel.status.editedAt {
|
|
|
|
Divider()
|
|
|
|
HStack {
|
|
|
|
Text("status.summary.edited-time") +
|
|
|
|
Text(editedAt.asDate, style: .date) +
|
|
|
|
Text("status.summary.at-time") +
|
|
|
|
Text(editedAt.asDate, style: .time)
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
.onTapGesture {
|
2023-02-15 07:46:14 +00:00
|
|
|
viewModel.routerPath.presentedSheet = .statusEditHistory(status: viewModel.status.id)
|
2023-02-10 11:12:22 +00:00
|
|
|
}
|
|
|
|
.underline()
|
|
|
|
.font(.scaledCaption)
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
}
|
|
|
|
|
2023-02-28 05:58:52 +00:00
|
|
|
if statusDataController.favoritesCount > 0 {
|
2023-02-10 11:12:22 +00:00
|
|
|
Divider()
|
2023-02-10 17:21:05 +00:00
|
|
|
Button {
|
2023-02-15 07:46:14 +00:00
|
|
|
viewModel.routerPath.navigate(to: .favoritedBy(id: viewModel.status.id))
|
2023-02-10 17:21:05 +00:00
|
|
|
} label: {
|
2023-02-10 11:12:22 +00:00
|
|
|
HStack {
|
2023-02-28 05:58:52 +00:00
|
|
|
Text("status.summary.n-favorites \(statusDataController.favoritesCount)")
|
2023-02-10 11:12:22 +00:00
|
|
|
.font(.scaledCallout)
|
|
|
|
Spacer()
|
|
|
|
makeAccountsScrollView(accounts: viewModel.favoriters)
|
|
|
|
Image(systemName: "chevron.right")
|
|
|
|
}
|
|
|
|
.frame(height: 20)
|
|
|
|
}
|
2023-02-10 17:21:05 +00:00
|
|
|
.buttonStyle(.borderless)
|
2023-02-10 11:12:22 +00:00
|
|
|
}
|
2023-02-28 05:58:52 +00:00
|
|
|
if statusDataController.reblogsCount > 0 {
|
2023-02-10 11:12:22 +00:00
|
|
|
Divider()
|
2023-02-10 17:21:05 +00:00
|
|
|
Button {
|
2023-02-15 07:46:14 +00:00
|
|
|
viewModel.routerPath.navigate(to: .rebloggedBy(id: viewModel.status.id))
|
2023-02-10 17:21:05 +00:00
|
|
|
} label: {
|
2023-02-10 11:12:22 +00:00
|
|
|
HStack {
|
2023-02-28 05:58:52 +00:00
|
|
|
Text("status.summary.n-boosts \(statusDataController.reblogsCount)")
|
2023-02-10 11:12:22 +00:00
|
|
|
.font(.scaledCallout)
|
|
|
|
Spacer()
|
|
|
|
makeAccountsScrollView(accounts: viewModel.rebloggers)
|
|
|
|
Image(systemName: "chevron.right")
|
|
|
|
}
|
|
|
|
.frame(height: 20)
|
|
|
|
}
|
2023-02-10 17:21:05 +00:00
|
|
|
.buttonStyle(.borderless)
|
2023-02-10 11:12:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.task {
|
|
|
|
await viewModel.fetchActionsAccounts()
|
|
|
|
}
|
|
|
|
}
|
2023-02-12 15:29:41 +00:00
|
|
|
|
2023-02-10 11:12:22 +00:00
|
|
|
private func makeAccountsScrollView(accounts: [Account]) -> some View {
|
|
|
|
ScrollView(.horizontal, showsIndicators: false) {
|
|
|
|
LazyHStack(spacing: 0) {
|
|
|
|
ForEach(accounts) { account in
|
|
|
|
AvatarView(url: account.avatar, size: .list)
|
|
|
|
.padding(.leading, -4)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.padding(.leading, .layoutPadding)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|