-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathStatusCardView.swift
More file actions
59 lines (57 loc) · 1.87 KB
/
StatusCardView.swift
File metadata and controls
59 lines (57 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import SwiftUI
import KotlinSharedUI
struct StatusCardView: View {
@Environment(\.openURL) private var openURL
let data: UiCard
var body: some View {
VStack(
alignment: .leading
) {
if let media = data.media {
AdaptiveGrid(singleFollowsImageAspect: false) {
Color.clear
.overlay {
MediaView(data: media)
.clipped()
}
.clipped()
}
.clipped()
}
VStack(
alignment: .leading
) {
Text(data.title)
.frame(maxWidth: .infinity, alignment: .leading)
.lineLimit(2)
if let desc = data.description_, !desc.isEmpty {
Text(desc)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(2)
} else {
Text(data.url)
.frame(maxWidth: .infinity, alignment: .leading)
.font(.caption)
.foregroundStyle(.secondary)
.lineLimit(2)
}
}
.if(data.media == nil, if: { stack in
stack.padding()
}, else: { stack in
stack.padding(.horizontal)
.padding(.bottom)
})
}
.clipShape(.rect(cornerRadius: 16))
.overlay(
RoundedRectangle(cornerRadius: 16)
.stroke(Color(.separator), lineWidth: 1)
)
.onTapGesture {
openURL.callAsFunction(.init(string: data.url)!)
}
}
}