Skip to content

Instantly share code, notes, and snippets.

@nickffox
nickffox / ContentView.swift
Created November 11, 2019 07:19
An example of using the KeyboardObserving Swift Package
struct ContentView: View {
var body: some View {
VStack {
ColorList()
TextInputView()
}.keyboardObserving()
}
}
struct ColorList: View {
@nickffox
nickffox / Keyboard.swift
Created August 16, 2019 18:43
Adjusting a SwiftUI View for the Keyboard.
import Combine
final class Keyboard: ObservableObject {
// MARK: - Published Properties
@Published var state: Keyboard.State = .default
// MARK: - Private Properties
convenience init(hexString: String) {
let hexString = hexString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let scanner = NSScanner(string: hexString)
if (hexString.hasPrefix("#")) {
scanner.scanLocation = 1
}
var color: UInt32 = 0
scanner.scanHexInt(&color)
protocol Incomparable: Comparable {}
func ==<T: Incomparable>(lhs: T, rhs: T) -> Bool {
fatalError()
}
func !=<T: Incomparable>(lhs: T, rhs: T) -> Bool {
fatalError()
}