Skip to content

Instantly share code, notes, and snippets.

@arkilis
Created December 19, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arkilis/c027fb42cf8deafa9dc030a12ab2aee6 to your computer and use it in GitHub Desktop.
Save arkilis/c027fb42cf8deafa9dc030a12ab2aee6 to your computer and use it in GitHub Desktop.
preview on iphone
import SwiftUI
struct PurchaseButtonView: View {
var title: String
var callback: () -> Void
var body: some View {
Button(
action: { self.callback() },
label: {
HStack {
Spacer()
Text(title).bold().padding()
Spacer()
}
}
)
.foregroundColor(.white)
.background(
//RoundedRectangle(cornerRadius: 8)
LinearGradient(
gradient: Gradient(colors: [Color.red, Color.blue]),
startPoint: .leading,
endPoint: .trailing
)
)
.cornerRadius(16)
}
}
struct PurchaseButtonView_Previews: PreviewProvider {
static var previews: some View {
VStack {
PurchaseButtonView(title: "Buy") {
print("Buy button clicked")
}.padding()
PurchaseButtonView(title: "Sell") {
print("Buy button clicked")
}.padding()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment