polyhorn_ios_sys/polykit/
keyboard_avoiding_view.rs1use objc::runtime::*;
2use objc::*;
3
4use super::{PLYCallback, PLYView};
5use crate::foundation::NSNumber;
6use crate::Raw;
7
8pub struct PLYKeyboardAvoidingView {
11 pub(super) object: *mut Object,
12}
13
14impl PLYKeyboardAvoidingView {
15 pub fn new() -> PLYKeyboardAvoidingView {
17 unsafe {
18 let mut object: *mut Object = msg_send![class!(PLYKeyboardAvoidingView), alloc];
19 object = msg_send![object, init];
20 PLYKeyboardAvoidingView { object }
21 }
22 }
23
24 pub fn to_view(&self) -> PLYView {
26 unsafe { PLYView::from_raw_retain(self.object) }
27 }
28
29 pub fn set_on_keyboard(&mut self, callback: PLYCallback<NSNumber>) {
32 unsafe {
33 let _: () = msg_send![self.object, setOnKeyboard: callback.as_raw()];
34 }
35 }
36}
37
38impl Raw for PLYKeyboardAvoidingView {
39 unsafe fn from_raw(object: *mut Object) -> Self {
40 PLYKeyboardAvoidingView { object }
41 }
42
43 unsafe fn as_raw(&self) -> *mut Object {
44 self.object
45 }
46}
47
48impl Clone for PLYKeyboardAvoidingView {
49 fn clone(&self) -> Self {
50 unsafe { Self::from_raw_retain(self.as_raw()) }
51 }
52}
53
54impl Drop for PLYKeyboardAvoidingView {
55 fn drop(&mut self) {
56 unsafe { objc_release(self.object) }
57 }
58}