This file contains 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
// | |
// ContentView.swift | |
// ObservableTester | |
// | |
// Created by Craig Hockenberry on 4/18/24. | |
// | |
import SwiftUI | |
class BackingStore { |
This file contains 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
// | |
// ContentView.swift | |
// NavigationTest | |
// | |
// Created by Craig Hockenberry on 4/16/24. | |
// | |
import SwiftUI | |
struct OddView: View { |
This file contains 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
// In regards to https://mastodon.social/@mattiem/112285978801305971 | |
// MainActor class with synchronous methods | |
@MainActor final class M { | |
func methodA() {} | |
func methodB() {} | |
} | |
// Actor that relies on M. | |
actor A { |
This file contains 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
// | |
// ContentView.swift | |
// BindableOptional | |
// | |
// Created by Craig Hockenberry on 4/12/24. | |
// | |
import SwiftUI | |
@Observable |
This file contains 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 { shadow, ShadowTemplate, html, css } from './shadow.js'; | |
const template: ShadowTemplate = { | |
css: css` | |
:host { | |
display: contents; | |
} | |
`. | |
html: html` | |
<slot></slot> |
This file contains 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
func scrollViewDidScroll(_ scrollView: UIScrollView) { | |
for (i, view) in scrollView.subviews.enumerated() { | |
var ty = 0.0 | |
if scrollView.contentOffset.y < 0 { | |
// We're scrolling past the top of the scroll view. | |
// Translate each item in the scroll view by some amount based on its index and scroll offset. | |
ty = CGFloat(i) * abs(offsetY) / 8.0 * pow(1.12, CGFloat(i)) | |
} | |
view.transform = CGAffineTransform(translationX: 0, y: ty) | |
} |
This file contains 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 UIKit | |
protocol StepAnimatable { | |
/// Start a sequence where you add each step in the `addSteps` closure. Use the provided `AnimationSequence` object | |
/// to add each step which should either be an actual animation or a delay. | |
/// The `completion` closure is executed when the last animation has finished. | |
/// - Parameters: | |
/// - addSteps: Closure used to add steps to the provided `AnimationSequence` object | |
/// - completion: Executed when the last animation has finished. |
This file contains 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
/// Withable is a simple protocol to make constructing | |
/// and modifying objects with multiple properties | |
/// more pleasant (functional, chainable, point-free) | |
public protocol Withable { | |
init() | |
} | |
public extension Withable { | |
/// Construct a new instance, setting an arbitrary subset of properties | |
init(with config: (inout Self) -> Void) { |
This file contains 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
POST https://firestore.googleapis.com/v1beta1/projects/firestore-fun/databases/(default)/documents:commit?key={YOUR_API_KEY} | |
{ | |
"writes": [ | |
{ | |
"update": { | |
"name": "projects/firestore-fun/databases/(default)/documents/foo/bar", | |
"fields": { | |
"some-field": { | |
"stringValue": "some-value" |
This file contains 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 UIKit | |
public extension CGSize { | |
func snapped(scale: CGFloat) -> CGSize { | |
var size = self | |
size.width = ceil(size.width * scale) / scale | |
size.height = ceil(size.height * scale) / scale | |
return size | |
} |
NewerOlder