-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathUserMessage.swift
More file actions
62 lines (58 loc) · 1.58 KB
/
UserMessage.swift
File metadata and controls
62 lines (58 loc) · 1.58 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
60
61
import ComposableArchitecture
import ChatService
import Foundation
import MarkdownUI
import SharedUIComponents
import SwiftUI
struct UserMessage: View {
var r: Double { messageBubbleCornerRadius }
let id: String
let text: String
let chat: StoreOf<Chat>
@Environment(\.colorScheme) var colorScheme
var body: some View {
HStack() {
Spacer()
VStack(alignment: .trailing) {
ThemedMarkdownText(text)
.frame(alignment: .leading)
.padding()
}
.background {
RoundedCorners(tl: r, tr: r, bl: r, br: 0)
.fill(Color.userChatContentBackground)
}
.overlay {
RoundedCorners(tl: r, tr: r, bl: r, br: 0)
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
}
.shadow(color: .black.opacity(0.05), radius: 6)
}
.padding(.leading, 8)
.padding(.trailing, 8)
}
}
#Preview {
UserMessage(
id: "A",
text: #"""
Please buy me a coffee!
| Coffee | Milk |
|--------|------|
| Espresso | No |
| Latte | Yes |
```swift
func foo() {}
```
```objectivec
- (void)bar {}
```
"""#,
chat: .init(
initialState: .init(history: [] as [DisplayedChatMessage], isReceivingMessage: false),
reducer: { Chat(service: ChatService.service()) }
)
)
.padding()
.fixedSize(horizontal: true, vertical: true)
}