diff --git a/Chat/Chat/ChatViewController.cs b/Chat/Chat/ChatViewController.cs old mode 100644 new mode 100755 index 7760c3a1f..6861d3b2c --- a/Chat/Chat/ChatViewController.cs +++ b/Chat/Chat/ChatViewController.cs @@ -19,7 +19,6 @@ public class ChatViewController : UIViewController { NSLayoutConstraint toolbarBottomConstraint; NSLayoutConstraint toolbarHeightConstraint; - int notifCount = 0; ChatInputView chatInputView; @@ -142,9 +141,10 @@ void SetUpToolbar () if (UIDevice.CurrentDevice.CheckSystemVersion (11, 0)) { // iPhone X layout var safeGuide = View.SafeAreaLayoutGuide; - toolbar.HeightAnchor.ConstraintEqualTo (44).Active = true; toolbar.LeadingAnchor.ConstraintEqualTo (safeGuide.LeadingAnchor).Active = true; toolbar.TrailingAnchor.ConstraintEqualTo (safeGuide.TrailingAnchor).Active = true; + toolbarHeightConstraint = toolbar.HeightAnchor.ConstraintEqualTo (44); + toolbarHeightConstraint.Active = true; toolbarBottomConstraint = toolbar.BottomAnchor.ConstraintEqualTo (safeGuide.BottomAnchor); toolbarBottomConstraint.Active = true; } else { @@ -228,33 +228,18 @@ void AdjustInputToolbar (nfloat change) void KeyboardWillShowHandler (object sender, UIKeyboardEventArgs e) { - UpdateButtomLayoutConstraint (e); + if (UIDevice.CurrentDevice.CheckSystemVersion (11, 0)) { // iPhone X layout + SetToolbarContstraint (-e.FrameEnd.Height); + } else { + SetToolbarContstraint (e.FrameEnd.Height); + } } void KeyboardWillHideHandler (object sender, UIKeyboardEventArgs e) { - notifCount = 0; SetToolbarContstraint (0); } - void UpdateButtomLayoutConstraint (UIKeyboardEventArgs e) - { - UIViewAnimationCurve curve = e.AnimationCurve; - if (UIDevice.CurrentDevice.CheckSystemVersion (11, 0)) { - UIView.Animate (e.AnimationDuration, 0, ConvertToAnimationOptions (e.AnimationCurve), () => { - nfloat offsetFromBottom = toolbar.Frame.GetMaxY () - e.FrameEnd.GetMinY (); - offsetFromBottom = NMath.Max (0, offsetFromBottom); - if (++notifCount >= 2) { SetToolbarContstraint (-offsetFromBottom); } - }, null); - } else { - UIView.Animate (e.AnimationDuration, 0, ConvertToAnimationOptions (e.AnimationCurve), () => { - nfloat offsetFromBottom = tableView.Frame.GetMaxY () - e.FrameEnd.GetMinY (); - offsetFromBottom = NMath.Max (0, offsetFromBottom); - SetToolbarContstraint (offsetFromBottom); - }, null); - } - } - void SetToolbarContstraint (nfloat constant) { toolbarBottomConstraint.Constant = constant;