Skip to content

Commit

Permalink
PullToRefresh & item selection when listView is not Enabled fix [iOS]
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed Jan 23, 2024
1 parent 4f32463 commit e24e667
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ 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();
}
}

public override void TraitCollectionDidChange(UITraitCollection previousTraitCollection)
Expand Down Expand Up @@ -522,7 +528,7 @@ void UpdateHeader()

void UpdateIsRefreshing()
{
var refreshing = Element.IsRefreshing;
var refreshing = Element.IsRefreshing && Element.IsEnabled;
if (_tableViewController != null)
_tableViewController.UpdateIsRefreshing(refreshing);
}
Expand Down Expand Up @@ -689,7 +695,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 +737,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 @@ -1164,7 +1170,7 @@ public void OnItemSelected(object sender, SelectedItemChangedEventArgs eventArg)
return;
}

if (List == null)
if (List == null || !List.IsEnabled)
return;

var location = TemplatedItemsView.TemplatedItems.GetGroupAndIndexOfItem(eventArg.SelectedItem);
Expand Down Expand Up @@ -1215,7 +1221,7 @@ public override void RowSelected(UITableView tableView, NSIndexPath indexPath)

SetCellBackgroundColor(cell, UIColor.Clear);

if (List.SelectionMode == ListViewSelectionMode.None)
if (List.SelectionMode == ListViewSelectionMode.None || !List.IsEnabled)
tableView.DeselectRow(indexPath, false);

_selectionFromNative = true;
Expand Down Expand Up @@ -1599,6 +1605,8 @@ 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 e24e667

Please sign in to comment.