diff --git a/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlap.Forms.Plugin.iOSUnified.csproj b/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlap.Forms.Plugin.iOSUnified.csproj index 8e0ad96..e9d322f 100644 --- a/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlap.Forms.Plugin.iOSUnified.csproj +++ b/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlap.Forms.Plugin.iOSUnified.csproj @@ -44,25 +44,25 @@ - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + + + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - + \ No newline at end of file diff --git a/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlapRenderer.cs b/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlapRenderer.cs index fdaf081..e8415d7 100644 --- a/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlapRenderer.cs +++ b/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/KeyboardOverlapRenderer.cs @@ -7,134 +7,137 @@ using KeyboardOverlap.Forms.Plugin.iOSUnified; using System.Diagnostics; -[assembly: ExportRenderer (typeof(Page), typeof(KeyboardOverlapRenderer))] +[assembly: ExportRenderer(typeof(Page), typeof(KeyboardOverlapRenderer))] namespace KeyboardOverlap.Forms.Plugin.iOSUnified { - [Preserve (AllMembers = true)] - public class KeyboardOverlapRenderer : PageRenderer - { - NSObject _keyboardShowObserver; - NSObject _keyboardHideObserver; - private bool _pageWasShiftedUp; - private double _activeViewBottom; - private bool _isKeyboardShown; - - public static void Init () - { - var now = DateTime.Now; - Debug.WriteLine ("Keyboard Overlap plugin initialized {0}", now); - } - - public override void ViewWillAppear (bool animated) - { - base.ViewWillAppear (animated); - - var page = Element as ContentPage; + [Preserve(AllMembers = true)] + public class KeyboardOverlapRenderer : PageRenderer + { + NSObject _keyboardShowObserver; + NSObject _keyboardHideObserver; + private bool _pageWasShiftedUp; + private double _activeViewBottom; + private bool _isKeyboardShown; + + public static void Init() + { + var now = DateTime.Now; + Debug.WriteLine("Keyboard Overlap plugin initialized {0}", now); + } + + public override void ViewWillAppear(bool animated) + { + base.ViewWillAppear(animated); + + var page = Element as ContentPage; if (page != null) { - var contentScrollView = page.Content as ScrollView; + var contentScrollView = page.Content as ScrollView; - if (contentScrollView != null) - return; + if (contentScrollView != null) + return; - RegisterForKeyboardNotifications (); - } - } + RegisterForKeyboardNotifications(); + } + } - public override void ViewWillDisappear (bool animated) - { - base.ViewWillDisappear (animated); + public override void ViewWillDisappear(bool animated) + { + base.ViewWillDisappear(animated); - UnregisterForKeyboardNotifications (); - } + UnregisterForKeyboardNotifications(); + } - void RegisterForKeyboardNotifications () - { - if (_keyboardShowObserver == null) - _keyboardShowObserver = NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillShowNotification, OnKeyboardShow); - if (_keyboardHideObserver == null) - _keyboardHideObserver = NSNotificationCenter.DefaultCenter.AddObserver (UIKeyboard.WillHideNotification, OnKeyboardHide); - } + void RegisterForKeyboardNotifications() + { + if (_keyboardShowObserver == null) + _keyboardShowObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardShow); + if (_keyboardHideObserver == null) + _keyboardHideObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardHide); + } - void UnregisterForKeyboardNotifications () - { - _isKeyboardShown = false; + void UnregisterForKeyboardNotifications() + { + _isKeyboardShown = false; if (_keyboardShowObserver != null) { - NSNotificationCenter.DefaultCenter.RemoveObserver (_keyboardShowObserver); - _keyboardShowObserver.Dispose (); - _keyboardShowObserver = null; - } + NSNotificationCenter.DefaultCenter.RemoveObserver(_keyboardShowObserver); + _keyboardShowObserver.Dispose(); + _keyboardShowObserver = null; + } if (_keyboardHideObserver != null) { - NSNotificationCenter.DefaultCenter.RemoveObserver (_keyboardHideObserver); - _keyboardHideObserver.Dispose (); - _keyboardHideObserver = null; - } - } + NSNotificationCenter.DefaultCenter.RemoveObserver(_keyboardHideObserver); + _keyboardHideObserver.Dispose(); + _keyboardHideObserver = null; + } + } - protected virtual void OnKeyboardShow (NSNotification notification) - { - if (!IsViewLoaded || _isKeyboardShown) - return; + protected virtual void OnKeyboardShow(NSNotification notification) + { + if (!IsViewLoaded || _isKeyboardShown) + return; - _isKeyboardShown = true; - var activeView = View.FindFirstResponder (); + _isKeyboardShown = true; + var activeView = View.FindFirstResponder(); - if (activeView == null) - return; + if (activeView == null) + return; - var keyboardFrame = UIKeyboard.FrameEndFromNotification (notification); - var isOverlapping = activeView.IsKeyboardOverlapping (View, keyboardFrame); + if (activeView.Superview.GetType().Name == nameof(PickerRenderer)) //Picker already shifts layout, so this prevents any shifting issues with UIPickers. + return; - if (!isOverlapping) - return; + var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification); + var isOverlapping = activeView.IsKeyboardOverlapping(View, keyboardFrame); + + if (!isOverlapping) + return; if (isOverlapping) { - _activeViewBottom = activeView.GetViewRelativeBottom (View); - ShiftPageUp (keyboardFrame.Height, _activeViewBottom); - } - } + _activeViewBottom = activeView.GetViewRelativeBottom(View); + ShiftPageUp(keyboardFrame.Height, _activeViewBottom); + } + } - private void OnKeyboardHide (NSNotification notification) - { - if (!IsViewLoaded) - return; + private void OnKeyboardHide(NSNotification notification) + { + if (!IsViewLoaded) + return; - _isKeyboardShown = false; - var keyboardFrame = UIKeyboard.FrameEndFromNotification (notification); + _isKeyboardShown = false; + var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification); if (_pageWasShiftedUp) { - ShiftPageDown (keyboardFrame.Height, _activeViewBottom); - } - } + ShiftPageDown(keyboardFrame.Height, _activeViewBottom); + } + } - private void ShiftPageUp (nfloat keyboardHeight, double activeViewBottom) - { - var pageFrame = Element.Bounds; + private void ShiftPageUp(nfloat keyboardHeight, double activeViewBottom) + { + var pageFrame = Element.Bounds; - var newY = pageFrame.Y + CalculateShiftByAmount (pageFrame.Height, keyboardHeight, activeViewBottom); + var newY = pageFrame.Y + CalculateShiftByAmount(pageFrame.Height, keyboardHeight, activeViewBottom); - Element.LayoutTo (new Rectangle (pageFrame.X, newY, - pageFrame.Width, pageFrame.Height)); + Element.LayoutTo (new Rectangle (pageFrame.X, newY, + pageFrame.Width, pageFrame.Height)); - _pageWasShiftedUp = true; - } + _pageWasShiftedUp = true; + } - private void ShiftPageDown (nfloat keyboardHeight, double activeViewBottom) - { - var pageFrame = Element.Bounds; + private void ShiftPageDown (nfloat keyboardHeight, double activeViewBottom) + { + var pageFrame = Element.Bounds; - var newY = pageFrame.Y - CalculateShiftByAmount (pageFrame.Height, keyboardHeight, activeViewBottom); + var newY = pageFrame.Y - CalculateShiftByAmount(pageFrame.Height, keyboardHeight, activeViewBottom); - Element.LayoutTo (new Rectangle (pageFrame.X, newY, - pageFrame.Width, pageFrame.Height)); + Element.LayoutTo (new Rectangle (pageFrame.X, newY, + pageFrame.Width, pageFrame.Height)); - _pageWasShiftedUp = false; - } + _pageWasShiftedUp = false; + } - private double CalculateShiftByAmount (double pageHeight, nfloat keyboardHeight, double activeViewBottom) - { - return (pageHeight - activeViewBottom) - keyboardHeight; - } - } + private double CalculateShiftByAmount (double pageHeight, nfloat keyboardHeight, double activeViewBottom) + { + return (pageHeight - activeViewBottom) - keyboardHeight; + } + } } \ No newline at end of file diff --git a/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/packages.config b/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/packages.config index ea62944..5f8f73c 100644 --- a/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/packages.config +++ b/KeyboardOverlap/KeyboardOverlap/KeyboardOverlap.Forms.Plugin.iOSUnified/packages.config @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/KeyboardOverlap/SampleApp/SampleApp.iOS/SampleApp.iOS.csproj b/KeyboardOverlap/SampleApp/SampleApp.iOS/SampleApp.iOS.csproj index 5302640..4504a19 100644 --- a/KeyboardOverlap/SampleApp/SampleApp.iOS/SampleApp.iOS.csproj +++ b/KeyboardOverlap/SampleApp/SampleApp.iOS/SampleApp.iOS.csproj @@ -249,19 +249,19 @@ - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + + + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - + \ No newline at end of file diff --git a/KeyboardOverlap/SampleApp/SampleApp.iOS/packages.config b/KeyboardOverlap/SampleApp/SampleApp.iOS/packages.config index ea62944..5f8f73c 100644 --- a/KeyboardOverlap/SampleApp/SampleApp.iOS/packages.config +++ b/KeyboardOverlap/SampleApp/SampleApp.iOS/packages.config @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file diff --git a/KeyboardOverlap/SampleApp/SampleApp/SampleApp.csproj b/KeyboardOverlap/SampleApp/SampleApp/SampleApp.csproj index 1258024..efed34c 100644 --- a/KeyboardOverlap/SampleApp/SampleApp/SampleApp.csproj +++ b/KeyboardOverlap/SampleApp/SampleApp/SampleApp.csproj @@ -163,16 +163,17 @@ --> - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll - ..\..\packages\Xamarin.Forms.2.0.0.6490\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll + + + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll + \ No newline at end of file diff --git a/KeyboardOverlap/SampleApp/SampleApp/packages.config b/KeyboardOverlap/SampleApp/SampleApp/packages.config index 9353041..15be8a9 100644 --- a/KeyboardOverlap/SampleApp/SampleApp/packages.config +++ b/KeyboardOverlap/SampleApp/SampleApp/packages.config @@ -1,4 +1,4 @@ - - - + + + \ No newline at end of file