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
@objc protocol ExampleActions: AnyObject { | |
func pushUIKitViewController() | |
} | |
struct ExampleView: View { | |
@FirstResponder private var firstResponder | |
var body: some View { | |
Button { | |
firstResponder.sendAction(#selector(ExampleActions.pushUIKitViewController)) |
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
// | |
// UIDebouncedColorWell.swift | |
// | |
import UIKit | |
import Combine | |
private class PublishingColor { | |
@Published var color: UIColor? = nil | |
} |
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
// Bigger iPhones = any Max, any Plus, iPhone XR, iPhone 11 | |
switch (UITraitCollection.current.horizontalSizeClass, UITraitCollection.current.verticalSizeClass) { | |
case (.compact, .compact): | |
// Smaller iPhones in landscape | |
case (.compact, .regular): | |
// iPhones in portrait | |
// iPads in portrait during any split screen, |
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 | |
@propertyWrapper | |
struct IgnoreEquatable<Wrapped>: Equatable { | |
var wrappedValue: Wrapped | |
static func == (lhs: IgnoreEquatable<Wrapped>, rhs: IgnoreEquatable<Wrapped>) -> Bool { | |
true | |
} | |
} |
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
// | |
// GeometryReaderStack.swift | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | |
// of the Software, and to permit persons to whom the Software is furnished to do so, | |
// subject to the following conditions: | |
// |
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
// Copyright 2021 Kyle Hughes | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | |
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | |
// permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | |
// Software. | |
// |
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
extension View { | |
func relative(width: CGFloat? = nil, height: CGFloat? = nil, alignment: Alignment = .center) -> some View { | |
Color.clear | |
.frame(maxWidth: width.map { _ in .infinity }, maxHeight: height.map { _ in .infinity }) | |
.overlay(GeometryReader { proxy in | |
ZStack { | |
self.frame( | |
width: width.map { proxy.size.width * $0 }, | |
height: height.map { proxy.size.height * $0 } | |
) |
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 { | |
static var toggle = false | |
static let settings: [Setting] = [ | |
.push( | |
label: "Embedded content", | |
[ | |
.text(label: "Deeper!", "Here is some embedded informational text") | |
] |
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 | |
@propertyWrapper | |
struct SimpleUserDefault<T> { | |
let userDefaults: UserDefaults | |
let key: String | |
let defaultValue: T | |
init( | |
userDefaults: UserDefaults = UserDefaults.standard, |
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
alias statusbarfix='xcrun simctl status_bar booted override --time 9:41 --cellularMode active --cellularBars 4 --batteryState charging --operatorName ""' |