Last active
February 24, 2021 09:43
-
-
Save grenos/2ebc41df627502233b814f0362eff011 to your computer and use it in GitHub Desktop.
swiftui-medium-004
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 GenericErrorView: View { | |
var image: String = "some-image-from-assets" | |
var title: String = "Title" | |
var subtitle: String = "Subtitle" | |
var buttonTitle: String = "ok" | |
var action: (() -> Void)? | |
var body: some View { | |
ZStack { | |
// here you can even put other views as background | |
VStack { | |
Image(image) | |
.resizable() | |
.aspectRatio(contentMode: .fiil) | |
.frame(width: 250, height: 200) | |
// text content | |
VStack { | |
Text(title) | |
.multilineTextAlignment(.center) | |
.padding() | |
Text(subtitle) | |
.multilineTextAlignment(.center) | |
.padding() | |
Spacer() | |
Button(action: action!) { | |
Text(buttonTitle) | |
.frame(width: 180, height: 45) | |
.foregroundColor(.white) | |
.background(.green) | |
.cornerRadius(5) | |
} | |
} | |
Spacer() | |
} | |
.frame(width: 200, height: 200) | |
.background(.white) | |
.cornerRadius(30, antialiased: true) | |
.shadow(radius: 20) | |
} | |
.edgesIgnoringSafeArea(.all) | |
} | |
} | |
struct GenericErrorView_Previews: PreviewProvider { | |
static var previews: some View { | |
GenericErrorView(image: "some-image-from-assets" , title: "Opps an error!", subtitle: "Subtitle!", buttonTitle: "ok ok") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment