Bubble/Threaded/Components/Status/PostCardView.swift

57 lines
1.9 KiB
Swift
Raw Normal View History

2024-01-02 19:10:53 +01:00
//Made by Lumaa
import SwiftUI
struct PostCardView: View {
2024-01-21 13:08:43 +01:00
@Environment(\.openURL) private var openURL
2024-01-02 19:10:53 +01:00
var card: Card
2024-01-03 09:55:42 +01:00
var inQuote: Bool = false
2024-01-02 19:10:53 +01:00
var body: some View {
VStack(alignment: .center, spacing: 10) {
if card.image != nil {
2024-01-03 09:55:42 +01:00
OnlineImage(url: card.image, size: inQuote ? 260 : 300, useNuke: false)
.frame(width: inQuote ? 250 : 300)
2024-01-02 19:10:53 +01:00
}
VStack(alignment: .leading) {
if let host = URL(string: card.url)?.host() {
Text(host)
.font(.footnote)
.foregroundStyle(Color.gray)
.multilineTextAlignment(.leading)
.lineLimit(1)
.padding([.top], card.image == nil ? 10 : 0)
}
Text(card.title ?? "")
.font(.headline.bold())
.foregroundStyle(Color(uiColor: UIColor.label))
.multilineTextAlignment(.leading)
.lineLimit(2)
Text(card.description ?? "")
.font(.footnote)
.foregroundStyle(Color.gray)
.multilineTextAlignment(.leading)
.lineLimit(3)
}
.padding([.horizontal, .bottom], 10)
}
2024-01-03 09:55:42 +01:00
.frame(width: inQuote ? 200 : 250)
2024-01-02 19:10:53 +01:00
.padding(.horizontal, 10)
.clipShape(.rect(cornerRadius: 15))
.fixedSize(horizontal: false, vertical: true)
.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(.gray.opacity(0.3), lineWidth: 1)
)
.onTapGesture {
if UIApplication.shared.canOpenURL(URL(string: card.url)!) {
2024-01-21 13:08:43 +01:00
openURL(URL(string: card.url)!)
2024-01-02 19:10:53 +01:00
}
}
}
}