Contact

Currently building at the Recurse Center

Thu Dec 12 2024

What I did yesterday

.no-hit {
   pointer-events: none;
   user-select: none;
}

There is also the option to use a custom Content Shape but that seems to have a rather specific use case. Eg. If you have a circle and you would like to have the hit area for the circle to be that of a rectangle you can use .contentShape(.rect). According to Paul Hudson, this comes in really handy when there is a Spacer in your components and you would like to have it handle clicks as well

Run loops let iOS handle running code while the user is actively doing something, such as scrolling in a list.

I’m yet to fully understand what this means in relation to running a heavy app that has timers in there. So the timer stuff was all great until it came time to cancel the timer and that’s where the code made me raise an eyebrow. That looks like this: timer.upstream.connect().cancel(). I had to look at this for a while to understand why it looks this way

struct ContentView: View {
    @Environment(\.accessibilityDifferentiateWithoutColor) var differentiateWithoutColor
    @Environment(\.accessibilityReduceMotion) var reduceMotion
    @Environment(\.accessibilityReduceTransparency) var reduceTransparency
    ...
struct ContentView: View {
    @Environment(\.accessibilityReduceMotion) var reduceMotion
    @State private var scale = 1.0

    var body: some View {
        Button("Hello, World!") {
            if reduceMotion {
                scale *= 1.5
            } else {
                withAnimation {
                    scale *= 1.5
                }
            }

        }
        .scaleEffect(scale)
    }
}

and such, there’s a wrapper function that can be used around withAnimation() that uses UIKit’s UIAccessibility data directly:

func withOptionalAnimation<Result>(_ animation: Animation? = .default, _ body: () throws -> Result) rethrows -> Result {
    if UIAccessibility.isReduceMotionEnabled {
        return try body()
    } else {
        return try withAnimation(animation, body)
    }
}
var body: some View {
        ZStack {
            RoundedRectangle(cornerRadius: 25)
                .fill(.white)
                .shadow(radius: 10)   // Why is this how we get the shadow effect on the card?
            
            VStack {
                Text(card.prompt)
                    .font(.largeTitle)
                    .foregroundStyle(.black)
                
                Text(card.answer)
                    .font(.title)
                    .foregroundStyle(.secondary)
            }
            .padding(20)
            .multilineTextAlignment(.center)
        }
        .frame(width: 450, height: 250)
        \\ Feels like that should exist here
    }

Today

Upcoming

Two more days to finish 100 days of SwiftUI and I’m currently on day 88. Freeing up all my time within today and tomorrow to finish this with my RC batch!