Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_packager == null)
                {
                    return;
                }

                Element?.ClearValue(Platform.RendererProperty);
                SetElement(null);

                _shellScrollTracker.Dispose();
                _shellScrollTracker = null;

                _packager.Dispose();
                _packager = null;

                _tracker.NativeControlUpdated -= OnNativeControlUpdated;
                _tracker.Dispose();
                _tracker = null;

                _events.Dispose();
                _events = null;

                _insetTracker.Dispose();
                _insetTracker = null;

                ScrollAnimationEnded -= HandleScrollAnimationEnded;
                Scrolled             -= HandleScrolled;
            }

            base.Dispose(disposing);
        }
Esempio n. 2
0
        public void SetElement(VisualElement element)
        {
            _requestedScroll = null;
            var oldElement = Element;

            Element = element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= HandlePropertyChanged;
                ((ScrollView)oldElement).ScrollToRequested -= OnScrollToRequested;
            }

            if (element != null)
            {
                element.PropertyChanged += HandlePropertyChanged;
                ((ScrollView)element).ScrollToRequested += OnScrollToRequested;
                if (_packager == null)
                {
                    _packager = new VisualElementPackager(this);
                    _packager.Load();

                    _tracker = new VisualElementTracker(this);
                    _tracker.NativeControlUpdated += OnNativeControlUpdated;
                    _events = new EventTracker(this);
                    _events.LoadEvents(this);

                    _insetTracker = new KeyboardInsetTracker(this, () => Window, insets => ContentInset = ScrollIndicatorInsets = insets, point =>
                    {
                        var offset = ContentOffset;
                        offset.Y  += point.Y;
                        SetContentOffset(offset, true);
                    });
                }

                UpdateDelaysContentTouches();
                UpdateContentSize();
                UpdateBackgroundColor();
                UpdateIsEnabled();
                UpdateVerticalScrollBarVisibility();
                UpdateHorizontalScrollBarVisibility();

                _shellScrollTracker = new ShellScrollViewTracker(this);

                OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

                EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

                if (element != null)
                {
                    element.SendViewInitialized(this);
                }

                if (!string.IsNullOrEmpty(element.AutomationId))
                {
                    AccessibilityIdentifier = element.AutomationId;
                }
            }
        }
Esempio n. 3
0
 public KeyboardInsetTracker(UIScrollView targetView, Func <UIWindow> fetchWindow, Action <UIEdgeInsets> setInsetAction, Action <PointF> setContentOffset, IVisualElementRenderer renderer)
 {
     _setContentOffset = setContentOffset;
     _targetView       = targetView;
     _fetchWindow      = fetchWindow;
     _setInsetAction   = setInsetAction;
     KeyboardObserver.KeyboardWillShow += OnKeyboardShown;
     KeyboardObserver.KeyboardWillHide += OnKeyboardHidden;
     if (renderer != null)
     {
         _shellScrollViewTracker = new ShellScrollViewTracker(renderer);
     }
 }
Esempio n. 4
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            KeyboardObserver.KeyboardWillShow -= OnKeyboardShown;
            KeyboardObserver.KeyboardWillHide -= OnKeyboardHidden;

            _shellScrollViewTracker?.Dispose();
            _shellScrollViewTracker = null;
        }