-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathUserCompatView.swift
More file actions
55 lines (52 loc) · 1.43 KB
/
UserCompatView.swift
File metadata and controls
55 lines (52 loc) · 1.43 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
import SwiftUI
import KotlinSharedUI
struct UserCompatView<TrailingContent: View>: View {
@Environment(\.openURL) private var openURL
let data: UiUserV2
let trailing: () -> TrailingContent
var body: some View {
HStack {
AvatarView(data: data.avatar)
.frame(width: 44, height: 44)
VStack(
alignment: .leading
) {
RichText(text: data.name)
Text(data.handle)
.font(.caption)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)
trailing()
}
.lineLimit(1)
}
}
extension UserCompatView {
init(data: UiUserV2) where TrailingContent == EmptyView {
self.data = data
self.trailing = {
EmptyView()
}
}
}
struct UserLoadingView: View {
var body: some View {
HStack {
Rectangle()
.fill(.placeholder)
.frame(width: 44, height: 44)
.clipShape(.circle)
VStack(
alignment: .leading
) {
Text("user name")
Text("user handle")
.font(.caption)
.foregroundStyle(.secondary)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
.redacted(reason: .placeholder)
}
}