Created
December 19, 2020 21:28
-
-
Save arkilis/c027fb42cf8deafa9dc030a12ab2aee6 to your computer and use it in GitHub Desktop.
preview on iphone
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
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