-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathToastPanelView.swift
More file actions
45 lines (40 loc) · 1.45 KB
/
ToastPanelView.swift
File metadata and controls
45 lines (40 loc) · 1.45 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
import ComposableArchitecture
import Dependencies
import Foundation
import SwiftUI
import Toast
struct ToastPanelView: View {
let store: StoreOf<ToastPanel>
var body: some View {
WithPerceptionTracking {
VStack(spacing: 4) {
if !store.alignTopToAnchor {
Spacer()
}
ForEach(store.toast.messages) { message in
message.content
.foregroundColor(.white)
.padding(8)
.frame(maxWidth: .infinity)
.background({
switch message.type {
case .info: return Color.accentColor
case .error: return Color(nsColor: .systemRed)
case .warning: return Color(nsColor: .systemOrange)
}
}() as Color, in: RoundedRectangle(cornerRadius: 8))
.overlay {
RoundedRectangle(cornerRadius: 8)
.stroke(Color.black.opacity(0.3), lineWidth: 1)
}
}
if store.alignTopToAnchor {
Spacer()
}
}
.colorScheme(store.colorScheme)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.allowsHitTesting(false)
}
}
}