Created
July 16, 2020 16:23
-
-
Save azamsharp/9703bc8f49ae153a3cd94f05c7e56473 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
// | |
// CreditCard.swift | |
// CreditCardSwiftUI | |
// | |
// Created by Mohammad Azam on 7/21/20. | |
// | |
import SwiftUI | |
struct CreditCard<Content>: View where Content: View { | |
var content: () -> Content | |
var body: some View { | |
content() | |
} | |
} | |
struct CreditCardFront: View { | |
var body: some View { | |
VStack(alignment: .leading) { | |
HStack(alignment: .top) { | |
Image(systemName: "checkmark.circle.fill") | |
.foregroundColor(Color.white) | |
Spacer() | |
Text("VISA") | |
.foregroundColor(Color.white) | |
.font(.system(size: 24)) | |
.fontWeight(.bold) | |
} | |
Spacer() | |
Text("**** **** **** 2864") | |
.foregroundColor(Color.white) | |
.font(.system(size: 32)) | |
Spacer() | |
HStack { | |
VStack(alignment: .leading) { | |
Text("CARD HOLDER") | |
.font(.caption) | |
.fontWeight(.bold) | |
.foregroundColor(Color.gray) | |
Text("MOHAMMAD AZAM") | |
.font(.caption) | |
.fontWeight(.bold) | |
.foregroundColor(Color.white) | |
} | |
Spacer() | |
VStack { | |
Text("EXPIRES") | |
.font(.caption) | |
.fontWeight(.bold) | |
.foregroundColor(Color.gray) | |
Text("02/23") | |
.font(.caption) | |
.fontWeight(.bold) | |
.foregroundColor(Color.white) | |
} | |
} | |
}.frame(width: 300, height: 200) | |
.padding() | |
.background(LinearGradient(gradient: Gradient(colors: [Color(#colorLiteral(red: 0.5481430292, green: 0, blue: 0.4720868468, alpha: 1)), Color.blue]), startPoint: .topLeading, endPoint: .bottomTrailing)) | |
.cornerRadius(10) | |
} | |
} | |
struct CreditCardBack: View { | |
var body: some View { | |
VStack { | |
Rectangle() | |
.frame(maxWidth: .infinity, maxHeight: 20) | |
.padding([.top]) | |
Spacer() | |
HStack { | |
Text("123").foregroundColor(Color.black) | |
.rotation3DEffect( | |
.degrees(180), | |
axis: (x: 0.0, y: 1.0, z: 0.0)) | |
.padding(5) | |
.frame(width: 100, height: 20) | |
.background(Color.white) | |
Spacer() | |
}.padding() | |
}.frame(width: 300, height: 200) | |
.background(LinearGradient(gradient: Gradient(colors: [Color.yellow, Color.blue]), startPoint: /*@START_MENU_TOKEN@*/.leading/*@END_MENU_TOKEN@*/, endPoint: /*@START_MENU_TOKEN@*/.trailing/*@END_MENU_TOKEN@*/)) | |
.cornerRadius(10) | |
} | |
} | |
struct CreditCard_Previews: PreviewProvider { | |
static var previews: some View { | |
CreditCard<CreditCardBack>(content: { CreditCardBack() }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment