This file contains 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 Foundation | |
class Book { | |
let name: String | |
let authorName: String | |
let year: Int | |
let price: Double | |
let isbn: String | |
init(name: String, authorName: String, year: Int, price: Double, isbn: String) { |
This file contains 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 TimeSelectorView: View { | |
var editedDate: Date | |
var completionHandler: (Date) -> Void | |
private let hours: [Int] = (1..<13).reversed().map { $0 } | |
private let minutes: [Int] = [0, 15, 30, 45].reversed() | |
private let meridiems: [Meridiem] = Meridiem.allCases | |
@State private var selection = TimeSelection() | |
This file contains 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
// Answer to https://stackoverflow.com/questions/69929331/current-time-is-not-displayed-in-the-analog-view | |
struct Hand: Shape { | |
let inset: CGFloat | |
let angle: Angle | |
func path(in rect: CGRect) -> Path { | |
let rect = rect.insetBy(dx: inset, dy: inset) | |
var path = Path() | |
path.move(to: CGPoint(x: rect.midX, y: rect.midY)) | |
path.addRoundedRect(in: CGRect(x: rect.midX - 4, y: rect.midY - 4, width: 8, height: 8), cornerSize: CGSize(width: 8, height: 8)) |
This file contains 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
class DebuggingResource: NSObject { | |
private static func printLine(_ line: String) { | |
print("--- \(line) ---") | |
} | |
public static func logJsonDataFormat(_ data: Data) { | |
printLine("Start Debugging Json Format") | |
if let json = try? JSONSerialization.jsonObject(with: data) { | |
This file contains 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
class DraggableAnnotationView: MGLAnnotationView { | |
var didSetNewCoord: (CLLocationCoordinate2D) -> Void = { _ in } | |
init(reuseIdentifier: String, size: CGFloat, didSetCoord: @escaping(CLLocationCoordinate2D) -> Void) { | |
self.didSetNewCoord = didSetCoord | |
super.init(reuseIdentifier: reuseIdentifier) | |
// `isDraggable` is a property of MGLAnnotationView, disabled by default. | |
isDraggable = true |
This file contains 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
class DebuggingResource: NSObject { | |
private static func printLine(_ line: String) { | |
print("--- \(line) ---") | |
} | |
public static func logJsonDataFormat(_ data: Data) { | |
printLine("Start Debugging Json Format") | |
if let json = try? JSONSerialization.jsonObject(with: data) { | |
This file contains 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 PassCodeCodeView: UIViewRepresentable { | |
init(_ count: Int = 5, | |
width: CGFloat, | |
height: CGFloat, | |
spacing: CGFloat = 10, | |
action: @escaping (String) -> ()) { | |
self.width = width | |
self.height = height | |
self.spacing = spacing |
This file contains 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
class ViewController: UIViewController { | |
var animator: UIDynamicAnimator? | |
var origins: [(String, CGPoint)] = [] | |
let range: ClosedRange<CGFloat> = 0.0...255.0 | |
var message = "This is cedric trying to animate the components with gravity" | |
override func viewDidLoad() { |
This file contains 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
@propertyWrapper | |
struct LocalStorage<T: Codable> { | |
private let userDefaults: UserDefaults = .standard | |
private let key: String | |
private let defaultValue: T | |
init(wrappedValue defaultValue: T, key: String) { | |
self.key = key | |
self.defaultValue = defaultValue | |
} |