protected virtual void Dispose(bool disposing)
        {
            if (_disposed || !disposing)
            {
                return;
            }

            _disposed = true;

            SetVisualElement(_visualElement, null);

            _defaultShape = null;
            if (_shapeManager != null)
            {
                _shapeManager.Dispose();
                _shapeManager = null;
            }

            if (_renderer != null)
            {
                _renderer.ElementChanged -= OnRendererElementChanged;
                _renderer = null;
            }

            if (_inkTouchController != null)
            {
                _inkTouchController.CancelInkTouchProcessing();
                _inkTouchController?.Dispose();
                _inkTouchController = null;
            }
        }
        InkView GetInkViewAtTouchLocation(InkTouchController inkTouchController, CGPoint location)
        {
            var indexPath = CollectionView.IndexPathForItemAtPoint(location);

            if (indexPath == null)
            {
                return(new InkView());
            }

            var cell = CollectionView.CellForItem(indexPath);

            return(GetInkView(cell));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            Title = "Material Components for iOS";

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                CollectionView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Always;
            }

            CollectionView.BackgroundColor = UIColor.FromWhiteAlpha(0.9f, 1);

            inkTouchController = new InkTouchController(CollectionView)
            {
                DelaysInkSpread = true,
                Delegate        = this
            };
            inkTouchController.AddInkView();
        }
        private void UpdateRipple()
        {
            if (_renderer.NativeView is Card || _renderer.NativeView is ChipView || _renderer.NativeView is MButton)
            {
                return;
            }

            _shapeManager?.SetIsRippleEnabled(_backgroundElement.IsRippleEnabled);

            if (_backgroundElement.IsRippleEnabled)
            {
                if (_inkTouchController == null)
                {
                    _inkTouchController = new InkTouchController(_renderer.NativeView);
                    _inkTouchController.AddInkView();
                }

                InvalidateShape();

                if (_inkTouchController?.DefaultInkView == null)
                {
                    return;
                }
                _inkTouchController.DefaultInkView.UsesLegacyInkRipple = false;

                if (_backgroundElement.RippleColor != Color.Default)
                {
                    _inkTouchController.DefaultInkView.InkColor = _backgroundElement.RippleColor.ToUIColor();
                }
            }
            else if (_inkTouchController != null && !_backgroundElement.IsRippleEnabled)
            {
                _inkTouchController.CancelInkTouchProcessing();
                _inkTouchController?.DefaultInkView?.RemoveFromSuperview();
                _inkTouchController?.Dispose();
                _inkTouchController = null;
            }
        }
 public bool ShouldProcessInkTouches(InkTouchController inkTouchController, CGPoint location) => CollectionView.IndexPathForItemAtPoint(location) != null;