public override void TouchesCancelled(Foundation.NSSet touches, UIEvent evt) { _scrollOrientation = ARNotificationScrollOrientation.Unknown; if (_alertType == ARNotificationType.Confirm) { OnTouchCancel(); } else { StartHiddenTimer(); } base.TouchesCancelled(touches, evt); }
public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt) { var xOffset = (DeviceInfo.ScreenWidth * 0.1f); var yOffset = HEIGHT * -0.1f; if (Frame.X < -xOffset || Frame.X > xOffset || Frame.Y < yOffset) { AnimateNotify(0.3f, 0.0f, UIViewAnimationOptions.CurveEaseIn, () => AnimateFrameChanges(), (finished) => { RemoveFromSuperview(); _onHideCallback?.Invoke(); _previousTouchPosition = CGPoint.Empty; }); } else if (_alertType == ARNotificationType.Error && _scrollOrientation == ARNotificationScrollOrientation.FromTopToBottom && Frame.Height > HEIGHT) { _textView.ScrollEnabled = true; _textView.UserInteractionEnabled = true; AnimateNotify(0.3f, 0.0f, UIViewAnimationOptions.CurveEaseIn, () => AnimateFrameChanges(), (finished) => { _textView.SetContentOffset(CGPoint.Empty, true); StartHiddenTimer(); }); } else { AnimateNotify(0.3f, 0.0f, UIViewAnimationOptions.CurveEaseIn, () => this.ChangeFrame(x: 0, y: 0), (finished) => { TouchesCancelled(touches, evt); _previousTouchPosition = CGPoint.Empty; }); } _scrollOrientation = ARNotificationScrollOrientation.Unknown; base.TouchesEnded(touches, evt); }
public override void TouchesMoved(Foundation.NSSet touches, UIEvent evt) { if (touches.Count == 1) { var touch = touches.First() as UITouch; var point = touch.LocationInView(this); var currentScrollOrientation = Math.Abs(GetTouchDistance(touch.Timestamp, point.X, _previousTouchPosition.X)) > Math.Abs(GetTouchDistance(touch.Timestamp, point.Y, _previousTouchPosition.Y)) ? ARNotificationScrollOrientation.FromRightToLeft : (point.Y < _previousTouchPosition.Y ? ARNotificationScrollOrientation.FromBottomToTop : ARNotificationScrollOrientation.FromTopToBottom); //if (_scrollOrientation == ARNotificationScrollOrientation.Unknown) // _scrollOrientation = currentScrollOrientation; //else if ((_scrollOrientation == ARNotificationScrollOrientation.FromLeftToRight || _scrollOrientation == ARNotificationScrollOrientation.FromRightToLeft) // && (currentScrollOrientation == ARNotificationScrollOrientation.FromLeftToRight || currentScrollOrientation == ARNotificationScrollOrientation.FromRightToLeft)) // _scrollOrientation = currentScrollOrientation; //else if ((_scrollOrientation == ARNotificationScrollOrientation.FromBottomToTop || _scrollOrientation == ARNotificationScrollOrientation.FromTopToBottom) // && (currentScrollOrientation == ARNotificationScrollOrientation.FromBottomToTop || currentScrollOrientation == ARNotificationScrollOrientation.FromTopToBottom)) //_scrollOrientation = currentScrollOrientation; Debug.WriteLine(point); Debug.WriteLine(_scrollOrientation); Debug.WriteLine(_previousTouchPosition); if (Frame.Y == 0 && point.X < _previousTouchPosition.X && currentScrollOrientation == ARNotificationScrollOrientation.FromRightToLeft) { var delta = _previousTouchPosition.X - point.X; this.ChangeFrame(x: Frame.X - delta); _scrollOrientation = currentScrollOrientation; } else if (Frame.X == 0 && point.Y < _previousTouchPosition.Y && currentScrollOrientation == ARNotificationScrollOrientation.FromBottomToTop) { var delta = _previousTouchPosition.Y - point.Y; this.ChangeFrame(y: Frame.Y - delta); _scrollOrientation = currentScrollOrientation; } else if (Frame.X == 0 && _alertType == ARNotificationType.Error && point.Y > _previousTouchPosition.Y && currentScrollOrientation == ARNotificationScrollOrientation.FromTopToBottom) { var delta = point.Y - _previousTouchPosition.Y; if (_realTextSize.Height > TEXT_VIEW_HEIGHT) { var newHeight = Frame.Height + delta; var maxHeight = (nfloat)Math.Min(_realTextSize.Height + TEXT_VIEW_OFFSET, DeviceInfo.ScreenHeight); this.ChangeFrame(h: newHeight > maxHeight ? maxHeight : newHeight); } _scrollOrientation = currentScrollOrientation; } _previousTouchPosition = point; } base.TouchesMoved(touches, evt); }