Skip to content

Commit

Permalink
[iOS] PullToRefresh & item selection when listView is not Enabled fix (
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed Jan 31, 2024
1 parent 4f32463 commit aad33e8
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateVerticalScrollBarVisibility();
else if (e.PropertyName == ScrollView.HorizontalScrollBarVisibilityProperty.PropertyName)
UpdateHorizontalScrollBarVisibility();
else if(e.PropertyName == Microsoft.Maui.Controls.ListView.IsEnabledProperty.PropertyName)
{
UpdatePullToRefreshEnabled();
UpdateSelectionMode();
UpdateIsRefreshing();
UpdateViewCellsEnabled();
}
}

public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
Expand Down Expand Up @@ -527,6 +534,14 @@ void UpdateIsRefreshing()
_tableViewController.UpdateIsRefreshing(refreshing);
}

void UpdateViewCellsEnabled()
{
foreach (var cell in TemplatedItemsView.TemplatedItems)
{
cell.IsEnabled = ListView.IsEnabled;
}
}

void UpdateItems(NotifyCollectionChangedEventArgs e, int section, bool resetWhenGrouped)
{
var exArgs = e as NotifyCollectionChangedEventArgsEx;
Expand Down Expand Up @@ -689,7 +704,7 @@ void UpdatePullToRefreshEnabled()
{
if (_tableViewController != null)
{
var isPullToRequestEnabled = Element.IsPullToRefreshEnabled && ListView.RefreshAllowed;
var isPullToRequestEnabled = Element.IsPullToRefreshEnabled && ListView.RefreshAllowed && ListView.IsEnabled;
_tableViewController.UpdatePullToRefreshEnabled(isPullToRequestEnabled);
}
}
Expand Down Expand Up @@ -731,7 +746,7 @@ void UpdateSeparatorVisibility()

void UpdateSelectionMode()
{
if (Element.SelectionMode == ListViewSelectionMode.None)
if (Element.SelectionMode == ListViewSelectionMode.None || !Element.IsEnabled)
{
Element.SelectedItem = null;
var selectedIndexPath = Control.IndexPathForSelectedRow;
Expand Down Expand Up @@ -1599,6 +1614,10 @@ public void UpdatePullToRefreshEnabled(bool pullToRefreshEnabled)
RefreshControl = _refresh;
}
}
else
{
RemoveRefresh();
}
// https://bugzilla.xamarin.com/show_bug.cgi?id=52962
// just because pullToRefresh is being disabled does not mean we should kill an in progress refresh.
// Consider the case where:
Expand Down

0 comments on commit aad33e8

Please sign in to comment.