UndoToast.swift (919B)
1 import SwiftUI 2 3 struct UndoToastData: Equatable, Identifiable { 4 let id: UUID 5 let message: String 6 } 7 8 struct UndoToastView: View { 9 let data: UndoToastData 10 let onUndo: () -> Void 11 let onDismiss: () -> Void 12 13 var body: some View { 14 HStack(spacing: 12) { 15 Text(data.message) 16 .font(.body) 17 .foregroundStyle(.white) 18 Button(action: onUndo) { 19 Text("Undo") 20 .font(.body.weight(.semibold)) 21 .foregroundStyle(.yellow) 22 } 23 } 24 .padding(.horizontal, 20) 25 .padding(.vertical, 14) 26 .background( 27 RoundedRectangle(cornerRadius: 12) 28 .fill(Color(white: 0.2)) 29 ) 30 .shadow(color: .black.opacity(0.15), radius: 8, y: 2) 31 .padding(.bottom, 24) 32 .transition(.move(edge: .bottom).combined(with: .opacity)) 33 } 34 }