Skip to content

Instantly share code, notes, and snippets.

@andreyz
andreyz / Calendar.swift
Created November 3, 2020 14:38 — forked from mecid/Calendar.swift
SwiftUI Calendar view using LazyVGrid
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
}
static var monthAndYear: DateFormatter {
@andreyz
andreyz / LoadAndNavigateStyle.swift
Created November 22, 2022 22:42 — forked from tgrapperon/LoadAndNavigateStyle.swift
This gist demonstrates how to achieve a "Load and Navigate" navigation style using `NavigationStack` on iOS 16.
// This file is self contained and can be copy/pasted in place of the `ContentView.swift` in a default iOS 16/macOS 13 app.
import SwiftUI
struct ContentView: View {
@State var path: NavigationPath = .init()
@State var isLoading1: Bool = false
@State var isLoading2: Bool = false
@State var isLoading3: Bool = false
@andreyz
andreyz / Example.swift
Created December 6, 2022 13:15 — forked from IanKeen/Example.swift
PropertyWrapper: Ignore codable properties
struct Foo: Codable {
var name: String
@Ignore var foo: Int?
}
let model = Foo(name: "Ian", foo: 42)
let data = try! JSONEncoder().encode(model)
print(String(data: data, encoding: .utf8)!) // {"name":"Ian"}
@andreyz
andreyz / PageView.swift
Created February 28, 2023 15:13
An example of how to create a lazy loaded paged view in SwiftUI
import SwiftUI
/**
A container view that manages navigation between pages of content.
*/
public struct PageView<Content: View, Item: Hashable> {
public typealias ItemProvider = (Item) -> Item?
public typealias ViewProvider = (Item) -> Content
@andreyz
andreyz / ChoasLinesShader.metal
Created May 8, 2024 19:25 — forked from realvjy/ChoasLinesShader.metal
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);