When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:
main {
max-width: 38rem;
padding: 2rem;
margin: auto;
}
// | |
// ContentView.swift | |
// Airdrop Demo | |
// | |
// Created by Daniel Kuntz on 7/30/23. | |
// | |
import SwiftUI | |
struct ContentView: View { |
// | |
// CDView.swift | |
// CD | |
// | |
// Created by Daniel Kuntz on 7/3/23. | |
// | |
import SwiftUI | |
struct ShapeWithHole: Shape { |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Alpha Component</key> | |
<real>1</real> | |
<key>Blue Component</key> | |
<real>0.10980392247438431</real> |
// | |
// (See usage below implementation) | |
// | |
// SwiftUI `CollectionView` type implemented with UIKit's UICollectionView under the hood. | |
// Requires `UIViewControllerRepresentable` over `UIViewRepresentable` as the type that allows | |
// for SwiftUI `View`s to be added as subviews of UIKit `UIView`s at all bridges this gap as | |
// the `UIHostingController`. | |
// | |
// Not battle-tested yet, but seems to be working well so far. | |
// Expect changes. |
struct User: Equatable { | |
var firstName: String | |
var lastName: String | |
} | |
@main | |
struct MyApp: App { | |
@State var value = User(firstName: "", lastName: "") | |
@State var showEdit = false |
// Avoids the keyboard in a UIKit app by leveraging additionalSafeAreaInsets. | |
// You can put this in the root view controller so the whole app will avoid the keyboard. | |
// Only tested on iOS 13.3. | |
// Made for https://douglashill.co/reading-app/ | |
@objc func updateSafeAreaForKeyboardFromNotification(_ notification: Notification) { | |
guard let endFrameInScreenCoords = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else { | |
return | |
} | |
// Please consider whether the force unwrap here is safe for your own use case. |
@propertyWrapper | |
public struct AnyProxy<EnclosingSelf, Value> { | |
private let keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value> | |
public init(_ keyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>) { | |
self.keyPath = keyPath | |
} | |
@available(*, unavailable, message: "The wrapped value must be accessed from the enclosing instance property.") | |
public var wrappedValue: Value { |
// SwiftUI Custom Styles (TripleToggleStyle) | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/custom-styling | |
import SwiftUI | |
// MARK: - TripleToggle View | |
public struct TripleToggle: View { | |
@Environment(\.tripleToggleStyle) var style: AnyTripleToggleStyle | |
@discardableResult | |
public func with<T>(_ value: T, _ builder: (T) -> Void) -> T { | |
builder(value) | |
return value | |
} | |
@discardableResult | |
public func with<T>(_ value: T, _ builder: (T) throws -> Void ) rethrows -> T { | |
try builder(value) | |
return value |