Beispiel #1
0
 public ChatInputKeyboardDelegate(ChatInputView chatInputView)
 {
     _chatInputView    = new WeakReferenceEx <ChatInputView>(chatInputView);
     _willShowObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, (notification) =>
     {
         if (!KeyBoardOpened)
         {
             TryInvokeOpenKeyboardEvent(notification);
         }
     });
     _willHideObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, (notification) =>
     {
         if (KeyBoardOpened)
         {
             KeyBoardOpened = false;
             KeyboardHeightChanged?.Invoke(0);
         }
     });
     _willChangeFrameObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillChangeFrameNotification, (notification) =>
     {
         if (KeyBoardOpened)
         {
             TryInvokeOpenKeyboardEvent(notification);
         }
     });
 }
        internal static void Init(IKeyboardEvents platformImplementation)
        {
            implementation = platformImplementation;

            implementation.KeyboardHeightChanged += (double height) => {
                KeyboardHeightChanged?.Invoke(height);
            };
        }
Beispiel #3
0
        private void TryInvokeOpenKeyboardEvent(NSNotification notification)
        {
            var keyboardHeight = UIKeyboard.FrameEndFromNotification(notification).Height;

            if (_chatInputView.Target?.Frame.Height < keyboardHeight)
            {
                KeyBoardOpened = true;
            }
            KeyboardHeightChanged?.Invoke(keyboardHeight);
        }
        public KeyboardUtils()
        {
            var windowHeight = UIScreen.MainScreen.Bounds.Height;

            // Show or change frame
            NSNotificationCenter.DefaultCenter.AddObserver(
                UIKeyboard.WillChangeFrameNotification, (notify) => {
                var info   = notify.UserInfo;
                var value  = (NSValue)(info [UIKeyboard.FrameEndUserInfoKey]);
                var height = windowHeight - value.RectangleFValue.Y;

                Debug.WriteLine("KeyboardEvents, height={0}", height);

                KeyboardHeightChanged?.Invoke(height);
            });
        }