Impressia/Vernissage/Views/DetailsView.swift

77 lines
2.8 KiB
Swift
Raw Normal View History

2022-12-29 17:27:15 +01:00
//
// https://mczachurski.dev
// Copyright © 2022 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import SwiftUI
import MastodonSwift
2023-01-02 19:12:25 +01:00
import AVFoundation
2022-12-29 17:27:15 +01:00
struct DetailsView: View {
2023-01-01 18:13:36 +01:00
@State public var statusData: StatusData
2022-12-29 17:27:15 +01:00
var body: some View {
ScrollView {
VStack (alignment: .leading) {
2023-01-03 14:09:22 +01:00
ImagesCarousel(attachments: statusData.attachments())
2022-12-29 17:27:15 +01:00
VStack(alignment: .leading) {
2023-01-03 14:09:22 +01:00
UsernameRow(statusData: statusData)
2023-01-01 18:13:36 +01:00
HTMLFormattedText(statusData.content)
2023-01-03 14:09:22 +01:00
.padding(.leading, -4)
2022-12-29 17:27:15 +01:00
VStack (alignment: .leading) {
2023-01-03 14:09:22 +01:00
LabelIcon(iconName: "camera", value: "SONY ILCE-7M3")
LabelIcon(iconName: "camera.aperture", value: "Viltrox 24mm F1.8 E")
LabelIcon(iconName: "timelapse", value: "24.0 mm, f/1.8, 1/640s, ISO 100")
LabelIcon(iconName: "calendar", value: "2 Oct 2022")
2022-12-29 17:27:15 +01:00
}
.foregroundColor(Color("lightGrayColor"))
2023-01-03 14:09:22 +01:00
HStack {
Text("Uploaded")
Text(statusData.createdAt.toDate(.isoDateTimeMilliSec) ?? Date(), style: .relative)
.padding(.horizontal, -4)
Text("ago")
2023-01-03 20:42:20 +01:00
if let applicationName = statusData.applicationName {
Text("via \(applicationName)")
.padding(.horizontal, -4)
}
2022-12-29 17:27:15 +01:00
}
2023-01-03 14:09:22 +01:00
.foregroundColor(Color("lightGrayColor"))
.font(.footnote)
InteractionRow(statusData: statusData)
2022-12-29 17:27:15 +01:00
}
.padding(8)
2023-01-03 14:09:22 +01:00
2023-01-03 20:42:20 +01:00
if statusData.repliesCount > 0 {
HStack (alignment: .center) {
Image(systemName: "message")
.padding(.leading, 8)
.padding(.vertical, 8)
Text("\(statusData.repliesCount) replies")
Spacer()
}
.font(.footnote)
.frame(maxWidth: .infinity)
.background(Color("mainTextColor").opacity(0.05))
.foregroundColor(Color("lightGrayColor"))
CommentsSection(statusId: statusData.id)
}
2022-12-29 17:27:15 +01:00
}
}
2022-12-30 18:20:54 +01:00
.navigationBarTitle("Details")
2023-01-02 19:12:25 +01:00
.onAppear {
}
2022-12-29 17:27:15 +01:00
}
}
struct DetailsView_Previews: PreviewProvider {
static var previews: some View {
2023-01-03 14:09:22 +01:00
DetailsView(statusData: StatusData())
2022-12-29 17:27:15 +01:00
}
}