|
| 1 | +import ToastUI |
| 2 | +import SwiftUI |
| 3 | + |
| 4 | +struct ExamplesView: View { |
| 5 | + @State var toast: ToastView? |
| 6 | + |
| 7 | + var body: some View { |
| 8 | + VStack(spacing: 12) { |
| 9 | + Button("Regular toast") { |
| 10 | + toast = ToastView( |
| 11 | + style: .regular, |
| 12 | + icon: Image(systemName: "exclamationmark.square"), |
| 13 | + title: "Regular toast", |
| 14 | + subtitle: "This is the subtitle." |
| 15 | + ) |
| 16 | + } |
| 17 | + |
| 18 | + Button("Failure toast") { |
| 19 | + toast = ToastView( |
| 20 | + style: .failure, |
| 21 | + icon: Image(systemName: "exclamationmark.square"), |
| 22 | + title: "Failure toast", |
| 23 | + subtitle: "This is the subtitle." |
| 24 | + ) |
| 25 | + } |
| 26 | + |
| 27 | + Button("Warning toast") { |
| 28 | + toast = ToastView( |
| 29 | + style: .warning, |
| 30 | + icon: Image(systemName: "exclamationmark.square"), |
| 31 | + title: "Warning toast", |
| 32 | + subtitle: "This is the subtitle." |
| 33 | + ) |
| 34 | + } |
| 35 | + |
| 36 | + Button("Info toast") { |
| 37 | + toast = ToastView( |
| 38 | + style: .info, |
| 39 | + icon: Image(systemName: "exclamationmark.square"), |
| 40 | + title: "Info toast", |
| 41 | + subtitle: "This is the subtitle." |
| 42 | + ) |
| 43 | + } |
| 44 | + |
| 45 | + Button("Success toast") { |
| 46 | + toast = ToastView( |
| 47 | + style: .success, |
| 48 | + icon: Image(systemName: "exclamationmark.square"), |
| 49 | + title: "Success toast", |
| 50 | + subtitle: "This is the subtitle." |
| 51 | + ) |
| 52 | + } |
| 53 | + } |
| 54 | + .buttonStyle(.bordered) |
| 55 | + .padding(12) |
| 56 | + .toast(item: $toast) { $0 } |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +struct ContentView_Previews: PreviewProvider { |
| 61 | + static var previews: some View { |
| 62 | + ExamplesView() |
| 63 | + } |
| 64 | +} |
0 commit comments