Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Created February 20, 2021 16:32
Show Gist options
  • Save prafullakumar/ea0ca0bf4581b3d9ccd465db1354174c to your computer and use it in GitHub Desktop.
Save prafullakumar/ea0ca0bf4581b3d9ccd465db1354174c to your computer and use it in GitHub Desktop.
struct Toast: View {
struct ToastDataModel {
var title:String
var image:String
}
let dataModel: ToastDataModel
@Binding var show: Bool
var body: some View {
VStack {
Spacer()
HStack {
Image(systemName: dataModel.image)
Text(dataModel.title)
}.font(.headline)
.foregroundColor(.primary)
.padding([.top,.bottom],20)
.padding([.leading,.trailing],40)
.background(Color(UIColor.secondarySystemBackground))
.clipShape(Capsule())
}
.frame(width: UIScreen.main.bounds.width / 1.25)
.transition(AnyTransition.move(edge: .bottom).combined(with: .opacity))
.onTapGesture {
withAnimation {
self.show = false
}
}.onAppear(perform: {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
withAnimation {
self.show = false
}
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment