Created
February 20, 2021 16:32
-
-
Save prafullakumar/ea0ca0bf4581b3d9ccd465db1354174c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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