Skip to content

Instantly share code, notes, and snippets.

@michzio
Created May 4, 2020 17:20
Show Gist options
  • Save michzio/5cc4096a5becadd35da9871f0595fd16 to your computer and use it in GitHub Desktop.
Save michzio/5cc4096a5becadd35da9871f0595fd16 to your computer and use it in GitHub Desktop.
struct KeyboardAvoiderPreference: Equatable {
let tag: Int
let rect: CGRect
static func == (lhs: KeyboardAvoiderPreference, rhs: KeyboardAvoiderPreference) -> Bool {
print("y: \(lhs.rect.minY) vs \(rhs.rect.minY)")
return lhs.tag == rhs.tag && (lhs.rect.minY == rhs.rect.minY)
}
}
struct KeyboardAvoiderPreferenceKey: PreferenceKey {
typealias Value = [KeyboardAvoiderPreference]
static var defaultValue: [KeyboardAvoiderPreference] = []
static func reduce(value: inout [KeyboardAvoiderPreference], nextValue: () -> [KeyboardAvoiderPreference]) {
value.append(contentsOf: nextValue())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment