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