Skip to content

Instantly share code, notes, and snippets.

@michzio
Created May 4, 2020 17:11
Show Gist options
  • Save michzio/e266a7a5d85d91b92f62e9386a4b334c to your computer and use it in GitHub Desktop.
Save michzio/e266a7a5d85d91b92f62e9386a4b334c to your computer and use it in GitHub Desktop.
extension View {
func registerKeyboardAvoider(_ avoider: KeyboardAvoider) -> some View {
self.onPreferenceChange(KeyboardAvoiderPreferenceKey.self) { prefs in
prefs.forEach { pref in
print("Avoider Rect: \(pref.rect)")
avoider.rects[pref.tag] = pref.rect
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment