Impressia/Vernissage/Views/DetailsView.swift

100 lines
4.1 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
struct DetailsView: View {
@Environment(\.dismiss) private var dismiss
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-01 18:13:36 +01:00
if let attachmentData = statusData.attachmentRelation?.first(where: { elemet in true}) as? AttachmentData {
Image(uiImage: UIImage(data: attachmentData.data)!)
.resizable().aspectRatio(contentMode: .fit)
.frame(maxWidth: .infinity)
}
2022-12-29 17:27:15 +01:00
VStack(alignment: .leading) {
HStack (alignment: .center) {
2023-01-01 18:13:36 +01:00
AsyncImage(url: statusData.accountAvatar) { image in
2022-12-29 17:27:15 +01:00
image
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
} placeholder: {
Image(systemName: "person.circle")
.resizable()
2022-12-31 16:31:05 +01:00
.foregroundColor(Color("mainTextColor"))
2022-12-29 17:27:15 +01:00
}
2022-12-31 16:31:05 +01:00
.frame(width: 48.0, height: 48.0)
2022-12-29 17:27:15 +01:00
VStack (alignment: .leading) {
2023-01-01 18:13:36 +01:00
Text(statusData.accountDisplayName ?? statusData.accountUsername)
2022-12-29 17:27:15 +01:00
.foregroundColor(Color("displayNameColor"))
2023-01-01 18:13:36 +01:00
Text("@\(statusData.accountUsername)")
2022-12-29 17:27:15 +01:00
.foregroundColor(Color("lightGrayColor"))
.font(.footnote)
}
.padding(.leading, 8)
}
2023-01-01 18:13:36 +01:00
HTMLFormattedText(statusData.content)
2022-12-29 17:27:15 +01:00
VStack (alignment: .leading) {
LabelIconView(iconName: "camera", value: "SONY ILCE-7M3")
LabelIconView(iconName: "camera.aperture", value: "Viltrox 24mm F1.8 E")
LabelIconView(iconName: "timelapse", value: "24.0 mm, f/1.8, 1/640s, ISO 100")
LabelIconView(iconName: "calendar", value: "2 Oct 2022")
}
.foregroundColor(Color("lightGrayColor"))
HStack (alignment: .top) {
TagView {
// Favorite
} content: {
HStack {
2023-01-01 18:13:36 +01:00
Image(systemName: statusData.favourited ? "heart.fill" : "heart")
Text("\(statusData.favouritesCount) likes")
2022-12-29 17:27:15 +01:00
}
}
TagView {
// Reboost
} content: {
HStack {
2023-01-01 18:13:36 +01:00
Image(systemName: statusData.reblogged ? "arrowshape.turn.up.forward.fill" : "arrowshape.turn.up.forward")
Text("\(statusData.reblogsCount) boosts")
2022-12-29 17:27:15 +01:00
}
}
Spacer()
TagView {
// Bookmark
} content: {
2023-01-01 18:13:36 +01:00
Image(systemName: statusData.bookmarked ? "bookmark.fill" : "bookmark")
2022-12-29 17:27:15 +01:00
}
}
.font(.subheadline)
.foregroundColor(Color("mainTextColor"))
}
.padding(8)
}
}
2022-12-30 18:20:54 +01:00
.navigationBarTitle("Details")
2022-12-29 17:27:15 +01:00
}
}
struct DetailsView_Previews: PreviewProvider {
static var previews: some View {
Text("")
// DetailsView(current: ImageStatus(id: "123", image: UIImage(), status: Status(from: <#T##Decoder#>)))
}
}