This file contains hidden or 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
struct ContentView: View { | |
var body: some View { | |
VStack { | |
ColorList() | |
TextInputView() | |
}.keyboardObserving() | |
} | |
} | |
struct ColorList: View { |
This file contains hidden or 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 Combine | |
final class Keyboard: ObservableObject { | |
// MARK: - Published Properties | |
@Published var state: Keyboard.State = .default | |
// MARK: - Private Properties | |
This file contains hidden or 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
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) |
This file contains hidden or 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 Incomparable: Comparable {} | |
func ==<T: Incomparable>(lhs: T, rhs: T) -> Bool { | |
fatalError() | |
} | |
func !=<T: Incomparable>(lhs: T, rhs: T) -> Bool { | |
fatalError() | |
} |