Skip to content

Instantly share code, notes, and snippets.

View pitt500's full-sized avatar

Pedro Rojas pitt500

View GitHub Profile
@pitt500
pitt500 / TodoList.swift
Last active August 3, 2022 14:46
For more context about this code, check out this video: https://youtu.be/Yk-KPDa4w8E
import SwiftUI
struct Todo: Identifiable {
let id: UUID
var title = "Untitled"
var isComplete = false
static var sample: [Todo] {
[
import SwiftUI
struct Todo: Identifiable {
let id: UUID
var title: String = "Untitled"
var isComplete: Bool = false
static var sample: [Todo] {
[
Todo(
import SwiftUI
struct ContentView: View {
@State var path = NavigationPath()
var body: some View {
NavigationStack(path: $path) {
List {
import SwiftUI
struct ContentView: View {
@State private var path: [Fruit] = []
var body: some View {
NavigationStack(path: $path) {
List {
NavigationLink(Fruit.apple.name, value: Fruit.apple)
import SwiftUI
struct ContentView: View {
@State private var path: [Fruit] = []
var body: some View {
NavigationStack(path: $path) {
List {
NavigationLink(Fruit.apple.name, value: Fruit.apple)
@pitt500
pitt500 / NavigationStack_CustomBackButton.swift
Last active July 8, 2022 04:43
Demo showing a custom back button implemented using SwiftUI's NavigationStack
import SwiftUI
struct ContentView: View {
@State private var path: [Fruit] = []
var body: some View {
NavigationStack(path: $path) {
List {
NavigationLink(Fruit.apple.name, value: Fruit.apple)
import Foundation
protocol Animal {
associatedtype CommodityType: Food
associatedtype FeedType: AnimalFeed
var isHungry: Bool { get }
func produce() -> CommodityType
func eat(_: FeedType)
@pitt500
pitt500 / SwiftLogo.swift
Created March 4, 2022 18:37
If you want to know the details of this implementation, check out this video 👉🏻 https://youtu.be/8vAJ9x0z4k8
import SwiftUI
struct SwiftLogo: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
let width = rect.width
let height = rect.height
let startPoint = CGPoint(x: rect.minX, y: height * 0.63)
@pitt500
pitt500 / MagnificationGestureDemo.swift
Last active January 16, 2025 00:38
Magnification gesture demo made in SwiftUI. Check out all the details of this code in this video: https://youtu.be/Gq39U4mJEY4
import SwiftUI
struct ImageDetailView: View {
let image: Image
@State var scale = 1.0
@State private var lastScale = 1.0
private let minScale = 1.0
private let maxScale = 5.0
var magnification: some Gesture {
@pitt500
pitt500 / TapGestureDemo.swift
Created January 28, 2022 15:22
Tap Gesture demo. Check out all the details here: https://youtu.be/90NcdAV0gPg
import SwiftUI
struct ContentView: View {
@GestureState var anotherState = false
@State var isTapped = false
var tap: some Gesture {
TapGesture(count: 4)
.onEnded { state in
// State is an empty tuple (void)