Skip to content

Instantly share code, notes, and snippets.

View swiftui-lab's full-sized avatar

SwiftUI-Lab swiftui-lab

View GitHub Profile
@swiftui-lab
swiftui-lab / anim-part6.swift
Last active August 25, 2024 17:51
Examples for SwiftUI Blog Post (Advanced SwiftUI Animations - Part 6)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Advanced SwiftUI Animations - Part 6 Examples
// blog article: https://swiftui-lab.com/swiftui-animations-part6
import SwiftUI
struct ContentView: View {
@State var show: Int? = nil
var body: some View {
@swiftui-lab
swiftui-lab / tree-layout-example.swift
Last active July 11, 2024 12:23
A Tree Layout Example (SwiftUI)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A Tree Layout example
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct TreeNode: Identifiable {
var parentId: UUID? = nil
let id: UUID = UUID()
let name: String
@swiftui-lab
swiftui-lab / showSizes.swift
Last active October 27, 2024 07:11
A debugging modifier for SwiftUI views (showSizes)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Implementation of the showSizes() debugging modifier
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct MeasureExample: View {
var body: some View {
VStack {
@swiftui-lab
swiftui-lab / interpolated-layout.swift
Last active October 2, 2024 14:49
A demonstration of a layout that interpolates the result of two other layouts.
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A demonstration of a layout that interpolates
// the result of two other layouts.
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
// ------------------------------------------------------------------
// Views
// ------------------------------------------------------------------
@swiftui-lab
swiftui-lab / wave-layout.swift
Created September 1, 2022 09:00
A wave layout example
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A demonstration of a wave Layout
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct ContentView: View {
@State var amplitude: CGFloat = 80
@State var phase: Double = 90.0
@State var frequency: Double = 2.0
@swiftui-lab
swiftui-lab / composed-layout.swift
Created August 31, 2022 08:20
An example of a composed layout
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A demonstration of a composed Layout
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct ContentView: View {
let colors: [Color] = [.yellow, .orange, .red, .pink, .purple, .blue, .cyan, .green]
@swiftui-lab
swiftui-lab / recursive-layout.swift
Created August 30, 2022 08:15
A recursive layout example
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A demonstration of a recursive Layout
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct ContentView: View {
let colors: [Color] = [.yellow, .orange, .red, .pink, .purple, .blue, .cyan, .green]
@State var angle: Angle = .zero
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A demonstration of a Layout with custom animations
// and bi-directional layout values.
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct ContentView: View {
let colors: [Color] = [.yellow, .orange, .red, .purple, .blue, .green]
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: a honeycomb eager grid
// blog article: https://swiftui-lab.com/eager-grids
import SwiftUI
struct Person {
let name: String
let image: String
var color: Color = .accentColor
@swiftui-lab
swiftui-lab / grid-trainer.swift
Last active October 21, 2024 15:24
A grid trainer for Grid views
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: this learning tool is designed to showcase the different
// Grid and GridRow view options, added in SwiftUI 2022. It is part of the
// blog article: https://swiftui-lab.com/eager-grids
//
import SwiftUI
import UniformTypeIdentifiers
// The root view of the application
struct ContentView: View {