51 lines
2.0 KiB
Swift
51 lines
2.0 KiB
Swift
import SwiftUI
|
|
|
|
/// Short confirmations, bottom-centred 44pt above the window edge. They may sit over an overlay.
|
|
struct ToastStack: View {
|
|
let toasts: ToastStore
|
|
|
|
var body: some View {
|
|
VStack(spacing: 8) {
|
|
ForEach(toasts.toasts) { toast in
|
|
ToastView(toast: toast)
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
|
.padding(.bottom, Metrics.toastBottom)
|
|
.allowsHitTesting(false)
|
|
}
|
|
}
|
|
|
|
private struct ToastView: View {
|
|
let toast: Toast
|
|
|
|
var body: some View {
|
|
HStack(spacing: 12) {
|
|
Image(systemName: "doc.on.doc").font(.system(size: 12, weight: .light)).foregroundStyle(Palette.amber)
|
|
Text(toast.title).typeRole(Typography.toastTitle).foregroundStyle(Palette.text1)
|
|
if let detail = toast.detail, !detail.isEmpty {
|
|
Text(detail)
|
|
.typeRole(Typography.toastReference)
|
|
.foregroundStyle(Palette.ink)
|
|
.lineLimit(1)
|
|
.truncationMode(.middle)
|
|
.padding(.horizontal, 7)
|
|
.padding(.vertical, 3)
|
|
.background(Palette.amber, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
|
|
}
|
|
}
|
|
.padding(.horizontal, 14)
|
|
.padding(.vertical, 10)
|
|
.frame(maxWidth: 560)
|
|
.fixedSize()
|
|
.background(Palette.panel, in: RoundedRectangle(cornerRadius: Metrics.radiusMedium))
|
|
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusMedium).strokeBorder(Palette.raised, lineWidth: Metrics.hairline))
|
|
.overlay(alignment: .leading) {
|
|
UnevenRoundedRectangle(topLeadingRadius: Metrics.radiusMedium, bottomLeadingRadius: Metrics.radiusMedium)
|
|
.fill(Palette.amber)
|
|
.frame(width: Metrics.accentRule)
|
|
}
|
|
.shadow(color: Palette.menuShadow, radius: Metrics.menuShadowRadius / 2, y: Metrics.menuShadowY)
|
|
}
|
|
}
|