Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS PullToRefreshLayoutRenderer can be simplified #67

Closed
gaocan1992 opened this issue Apr 24, 2019 · 1 comment
Closed

iOS PullToRefreshLayoutRenderer can be simplified #67

gaocan1992 opened this issue Apr 24, 2019 · 1 comment

Comments

@gaocan1992
Copy link

I don't think you have to insert refresh control as a subview.
It has been already a property of UITableView, UICollectionView and UIScrollView.
So even TryOffSetRefresh method is not required if I make this change.

protected bool TryInsertRefresh(UIView view) {
            // Save the refresh control parent.
            refreshControlParent = view;

            if (view is UITableView) {
                var uiTableView = view as UITableView;
                uiTableView = view as UITableView;
                uiTableView.RefreshControl = refreshControl;
                return true;
            }

            if (view is UICollectionView) {
                var uiCollectionView = view as UICollectionView;
                uiCollectionView = view as UICollectionView;
                uiCollectionView.RefreshControl = refreshControl;
                return true;
            }

            if (view is UIWebView) {
                var uiWebView = view as UIWebView;
                uiWebView.ScrollView.RefreshControl = refreshControl;
                return true;
            }

            if (view is UIScrollView) {
                var uiScrollView = view as UIScrollView;
                uiScrollView.RefreshControl = refreshControl;
                uiScrollView.AlwaysBounceVertical = true;
                return true;
            }

            if (view.Subviews == null) return false;

            for (int i = 0; i < view.Subviews.Length; i++) {
                var control = view.Subviews[i];
                if (TryInsertRefresh(control)) return true;
            }

            return false;
        }
public bool IsRefreshing {
            get => _isRefreshing;
            set {
                _isRefreshing = value;
                if (_isRefreshing) {
                    refreshControl.BeginRefreshing();
                }
                else {
                    refreshControl.EndRefreshing();
                }
            }
        }
        private bool _isRefreshing;
@jamesmontemagno
Copy link
Owner

This library will soon be deprecated by the official RefreshView as part of Xamarin.Forms 4.3. No further work will be done on this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants