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
#!/bin/bash | |
# Assigns a keyboard shortcut to the Export Unmodified Originals | |
# menu command in Photos.app on macOS. | |
# @ = Command | |
# ^ = Control | |
# ~ = Option | |
# $ = Shift | |
shortcut='@~^e' |
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 Foundation | |
enum FinderColor: Int { | |
case noColor = 0 | |
case grey = 1 | |
case green = 2 | |
case purple = 3 | |
case blue = 4 | |
case yellow = 5 | |
case red = 6 |
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 Foundation | |
struct ContainerEncoded: Encodable { | |
var date: Date = .now | |
func encode(to encoder: Encoder) throws { | |
var container = encoder.singleValueContainer() | |
try container.encode(date) | |
} | |
} |
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 SwiftUI | |
extension View { | |
func noLargerThan(_ maxSize: CGSize) -> some View { | |
NoLargerThanLayout(maxSize: maxSize) { | |
self | |
} | |
} | |
} |
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 SwiftUI | |
struct ContentView: View { | |
@State private var buttonTapCount: Int = 0 | |
@State private var rectTapCount: Int = 0 | |
@State private var isClippingDisabled: Bool = false | |
@State private var activateContentShape: Bool = false | |
var body: some View { | |
VStack(spacing: 40) { |
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 SwiftUI | |
struct Item: Identifiable { | |
var id: UUID = .init() | |
var value: Int | |
} | |
let sampleItems: [Item] = (1...99).map { Item.init(value: $0) } | |
struct ContentView: 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
// SwiftUI question: How do you put a continuous background behind a GridRow? | |
// | |
// I would have thought: | |
// | |
// GridRow { … } | |
// .background { … } | |
// | |
// But this puts the background behind each cell individually (behaves like Group), | |
// which is not what I want. |
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 SwiftUI | |
/// A wrapper view that provides a mutable Binding to its content closure. | |
/// | |
/// Useful in Xcode Previews for interactive previews of views that take a Binding. | |
struct Stateful<Value, Content: View>: View { | |
var content: (Binding<Value>) -> Content | |
@State private var state: Value | |
init(initialState: Value, @ViewBuilder content: @escaping (Binding<Value>) -> Content) { |
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
// Structure of _StackLayoutCache and related types. | |
// Used by SwiftUI as the Cache type for VStackLayout and HStackLayout. | |
// | |
// As of: iOS 16.0 simulator in Xcode 14.0b6 | |
import SwiftUI | |
struct _StackLayoutCache { | |
var stack: StackLayout | |
} |
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
// Excerpt from `SwiftUI.framework/Modules/SwiftUI.swiftmodule/arm64-apple-ios.swiftinterface` | |
// in Xcode 14.0b1 | |
// | |
// This is how any `Layout`-conforming type becomes a container view | |
// when it's used with a `@ViewBuilder` closure. | |
@available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) | |
extension SwiftUI.Layout { | |
@_alwaysEmitIntoClient public func callAsFunction<V>(@SwiftUI.ViewBuilder _ content: () -> V) -> some SwiftUI.View where V : SwiftUI.View { | |
return _VariadicView.Tree( | |
root: _LayoutRoot(self), content: content()) |