Skip to content

Instantly share code, notes, and snippets.

View azamsharp's full-sized avatar

Mohammad Azam azamsharp

View GitHub Profile
private func starType(index: Int) -> String {
if let rating = self.rating {
return index <= rating ? "star.fill" : "star"
} else {
return "star"
}
}
var body: some View {
HStack {
ForEach(1..<(max + 1), id: \.self) { index in
Image(systemName: "star")
.foregroundColor(Color.orange)
.onTapGesture {
self.rating = index
}
}
}
var body: some View {
HStack {
ForEach(1..<(max + 1), id: \.self) { index in
Image(systemName: "star")
.foregroundColor(Color.orange)
}
}
}
var body: some View {
HStack {
ForEach(1..<(max + 1), id: \.self) { index in
Image(systemName: "star.fill")
.foregroundColor(Color.orange)
.onTapGesture {
self.rating = index
}
}
}
var body: some View {
HStack {
ForEach(1..<(max + 1), id: \.self) { index in
Image(systemName: "star.fill")
.foregroundColor(Color.orange)
}
}
}
struct RatingView: View {
@Binding var rating: Int?
var max: Int = 5
}
//
// ContentView.swift
// Shared
//
// Created by Mohammad Azam on 7/21/20.
//
import SwiftUI
struct ContentView: View {
TextField("CVV", text: $cvv) { (editingChanged) in
withAnimation {
degrees += 180
flipped.toggle()
}
} onCommit: {}
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding([.leading,.trailing])
CreditCard {
VStack {
Group {
if flipped {
CreditCardBack(cvv: cvv)
} else {
CreditCardFront(name: name, expires: expires)
}
}
struct CreditCardFront: View {
let name: String
let expires: String
var body: some View {
VStack(alignment: .leading) {
... code to create the form