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 | |
//https://dimillian.medium.com/how-to-use-the-new-inspector-swiftui-view-modifier-9cefb8353beb | |
struct InspectorPanel: View { | |
@State var isShowingInspector = false | |
var body: some View { | |
NavigationStack { | |
VStack { | |
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
//https://betterprogramming.pub/a-data-validation-solution-utilizing-swift-property-wrappers-and-swiftui-view-extensions-ae2db2209a32 | |
import SwiftUI | |
public protocol ValidationRule { | |
associatedtype Value: Equatable | |
associatedtype Failure: Error | |
typealias ValidationResult = Result<Value, Failure> | |
init() |
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 Foundation | |
struct BinaryClock { | |
private(set) var hours24: [Int] = Array(repeating: 0, count: 6) | |
private(set) var hours12: [Int] = Array(repeating: 0, count: 4) | |
private(set) var minutes: [Int] = Array(repeating: 0, count: 6) | |
private(set) var seconds: [Int] = Array(repeating: 0, count: 6) | |
mutating func update(withSeconds seconds: TimeInterval) { | |
let totalSeconds = Int(seconds) |
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 | |
//RandomAccessCollection & MutableCollection & RangeReplaceableCollection & Equatable & Hashable | |
struct CoverFlowCarousel<Content: View, Data: RandomAccessCollection>: View where Data.Element: Identifiable { | |
@Environment(\.layoutDirection) var direction | |
private var config: Config | |
private let data: Data | |
@Binding var selection: Data.Element.ID? | |
private let content: (Data.Element) -> Content |
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
// | |
// CoverFlowCarousel.swift | |
// ClockSample | |
// | |
// Created by Codelaby on 25/7/24. | |
// | |
import SwiftUI | |
//RandomAccessCollection & MutableCollection & RangeReplaceableCollection & Equatable & Hashable | |
struct CoverFlowCarousel<Content: View, Data: RandomAccessCollection>: View where Data.Element: Identifiable { |
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
{ | |
"adult": false, | |
"backdrop_path": "/ifUfE79O1raUwbaQRIB7XnFz5ZC.jpg", | |
"belongs_to_collection": { | |
"id": 2602, | |
"name": "Scream Collection", | |
"poster_path": "/p3EjClFy20jjT0u06dzBs4lvvhi.jpg", | |
"backdrop_path": "/oUcscMECv8DOBsAPCh3KnDZqAC4.jpg" | |
}, | |
"budget": 24000000, |
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 SplashScreen: View { | |
var body: some View { | |
ZStack { | |
Rectangle().fill(Color.blue.gradient) | |
Image(systemName: "apple.logo") | |
.resizable() |
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 | |
fileprivate extension Date.FormatStyle { | |
func withTimeZone(_ timeZone: TimeZone?) -> Date.FormatStyle { | |
var copy = self | |
if let timeZone = timeZone { | |
copy.timeZone = timeZone | |
} | |
return copy | |
} |
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 | |
import MetalKit | |
struct Particle { | |
let color: SIMD4<Float> | |
let radius: Float | |
let lifespan: Float | |
let position: SIMD2<Float> | |
let velocity: SIMD2<Float> | |
} |
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 RemotePhotoDemoModel: Identifiable { | |
let id: UUID = .init() | |
let image: String | |
var imageData: Data? | |
static let allPhotos: [RemotePhotoDemoModel] = [ | |
//RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1531737212413-667205e1cda"), // error sample | |
RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1510001618818-4b4e3d86bf0f"), | |
RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1504284992506-f6d82d0f2f2a"), | |
RemotePhotoDemoModel(image: "https://images.unsplash.com/photo-1465447142348-e9952c393450"), |