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
// | |
// KeyboardToolbar.swift | |
// | |
// Created by James Sedlacek on 9/20/23. | |
// | |
import SwiftUI | |
import Combine | |
@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
#!/bin/bash -e | |
echo "🤡 Applying carthage 12 and 13 workaround 🤡" | |
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX) | |
# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise | |
# the build will fail on lipo due to duplicate architectures. | |
CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3) | |
echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' > $xcconfig | |
echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig |
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
/*: | |
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI | |
The only purpose of this code is to implement those wrappers myself | |
just to understand how they work internally and why they are needed, | |
⚠️ This is not supposed to be a reference implementation nor cover all | |
subtleties of the real Binding and State types. | |
The only purpose of this playground is to show how re-implementing | |
them myself has helped me understand the whole thing better |
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 | |
import Reachability | |
//Reachability | |
//declare this property where it won't go out of scope relative to your listener | |
fileprivate var reachability: Reachability! | |
protocol ReachabilityActionDelegate { | |
func reachabilityChanged(_ isReachable: Bool) |
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
readonly MODULEMAP="${PODS_ROOT}/TwitterCore/iOS/TwitterCore.framework/Modules/module.private.modulemap" | |
readonly HEADER="${PODS_ROOT}/TwitterCore/iOS/TwitterCore.framework/Headers/TwitterCore.h" | |
if ! grep -q "TwitterCore_Private" "${MODULEMAP}"; then | |
cat >"${MODULEMAP}" <<EOL | |
module TwitterCore_Private { | |
} | |
EOL | |
fi |
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
protocol LayoutGuideProvider { | |
var leadingAnchor: NSLayoutXAxisAnchor { get } | |
var trailingAnchor: NSLayoutXAxisAnchor { get } | |
var leftAnchor: NSLayoutXAxisAnchor { get } | |
var rightAnchor: NSLayoutXAxisAnchor { get } | |
var topAnchor: NSLayoutYAxisAnchor { get } | |
var bottomAnchor: NSLayoutYAxisAnchor { get } | |
var widthAnchor: NSLayoutDimension { get } | |
var heightAnchor: NSLayoutDimension { get } | |
var centerXAnchor: NSLayoutXAxisAnchor { get } |
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
typedef CF_ENUM(int, CFNetworkErrors) { | |
kCFHostErrorHostNotFound = 1, | |
kCFHostErrorUnknown = 2, // Query the kCFGetAddrInfoFailureKey to get the value returned from getaddrinfo; lookup in netdb.h | |
// SOCKS errors; in all cases you may query kCFSOCKSStatusCodeKey to recover the status code returned by the server | |
kCFSOCKSErrorUnknownClientVersion = 100, | |
kCFSOCKSErrorUnsupportedServerVersion = 101, // Query the kCFSOCKSVersionKey to find the version requested by the server | |
// SOCKS4-specific errors | |
kCFSOCKS4ErrorRequestFailed = 110, // request rejected or failed by the server | |
kCFSOCKS4ErrorIdentdFailed = 111, // request rejected because SOCKS server cannot connect to identd on the client |
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 | |
// A lens is a getter and a setter combined | |
struct Lens<Whole, Part> { | |
let get: (Whole) -> Part | |
let set: (inout Whole, Part) -> () | |
} | |
// We can create a lens from a key path | |
extension Lens { |
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 | |
// known-good: Xcode 8.2.1 | |
/** | |
UIImageView subclass which works with Auto Layout to try | |
to maintain the same aspect ratio as the image it displays. | |
This is unlike the usual behavior of UIImageView, where the |
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 RxSwift // Version 3.2.0 | |
import RxCocoa // Version 3.2.0 | |
func keyboardHeight() -> Observable<CGFloat> { | |
return Observable | |
.from([ | |
NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow) | |
.map { notification -> CGFloat in | |
(notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0 | |
}, |
NewerOlder