Skip to content

Commit 9705d5c

Browse files
authored
Check if RefreshControl is enabled on iOS (#28360)
1 parent f9ac7d0 commit 9705d5c

File tree

6 files changed

+144
-1
lines changed

6 files changed

+144
-1
lines changed
Loading
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using System.ComponentModel;
2+
3+
namespace Maui.Controls.Sample.Issues
4+
{
5+
6+
[Issue(IssueTracker.Github, 28343, "Progress spinner is not disabled after setting content on disabled RefreshView.", PlatformAffected.iOS)]
7+
public class Issue28343 : ContentPage
8+
{
9+
public Issue28343()
10+
{
11+
var refreshView = new RefreshView
12+
{
13+
IsEnabled = false,
14+
Content = CreateContent(),
15+
};
16+
17+
Grid grid = new Grid
18+
{
19+
{
20+
new Label
21+
{
22+
Text = "Refresh Not Triggered",
23+
AutomationId = "RefreshNotTriggered"
24+
}, 0, 0 },
25+
{
26+
new Button
27+
{
28+
Text = "Set To Enabled",
29+
AutomationId = "SetToEnabled",
30+
Command = new Command(() =>
31+
{
32+
refreshView.IsEnabled = true;
33+
})
34+
}, 0, 1 },
35+
{
36+
new Button
37+
{
38+
Text = "Reset Content",
39+
AutomationId = "ResetContent",
40+
Command = new Command(() =>
41+
{
42+
refreshView.Content = CreateContent();
43+
})
44+
}, 0, 2 },
45+
{ refreshView, 0, 3 }
46+
};
47+
48+
refreshView.Command = new Command(() =>
49+
{
50+
grid.RemoveAt(0);
51+
grid.Insert(0, new Label() { Text = "Refresh Triggered", AutomationId = "RefreshTriggered" });
52+
});
53+
54+
Content = grid;
55+
56+
grid.RowDefinitions[0].Height = GridLength.Auto;
57+
grid.RowDefinitions[1].Height = GridLength.Auto;
58+
grid.RowDefinitions[2].Height = GridLength.Auto;
59+
grid.RowDefinitions[3].Height = GridLength.Star;
60+
}
61+
62+
View CreateContent()
63+
{
64+
return new CollectionView
65+
{
66+
AutomationId = "CollectionView",
67+
ItemsSource = Enumerable.Range(0, 100).Select(x=> $"ListItem{x}"),
68+
ItemTemplate = new DataTemplate(() =>
69+
{
70+
var label = new Label
71+
{
72+
HeightRequest = 100,
73+
BackgroundColor = Colors.Green,
74+
TextColor = Colors.White
75+
};
76+
77+
label.SetBinding(Label.TextProperty, ".");
78+
label.SetBinding(Label.AutomationIdProperty, ".");
79+
80+
return label;
81+
})
82+
};
83+
}
84+
}
85+
}

Diff for: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue16910.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void BindingUpdatesFromProgrammaticRefresh()
2626
App.Tap("StopRefreshing");
2727
App.WaitForElement("IsNotRefreshing");
2828
}
29-
#if TEST_FAILS_ON_CATALYST || TEST_FAILS_ON_WINDOWS //Scroll actions cannot be performed on the macOS test server
29+
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //Scroll actions cannot be performed on the macOS test server
3030
[Test]
3131
public void BindingUpdatesFromInteractiveRefresh()
3232
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS
8+
[Category(UITestCategories.RefreshView)]
9+
public class Issue28343 : _IssuesUITest
10+
{
11+
public Issue28343(TestDevice testDevice) : base(testDevice)
12+
{
13+
}
14+
15+
protected override bool ResetAfterEachTest => true;
16+
17+
public override string Issue => "Progress spinner is not disabled after setting content on disabled RefreshView.";
18+
19+
[Test]
20+
public void ProgressSpinnerNotDisabledOnStartup()
21+
{
22+
App.WaitForElement("RefreshNotTriggered");
23+
App.WaitForElement("ListItem0");
24+
App.ScrollUp("CollectionView");
25+
App.WaitForElement("RefreshNotTriggered");
26+
VerifyScreenshot("Issue28343_ProgressSpinnerDisabled");
27+
28+
}
29+
30+
#if TEST_FAILS_ON_ANDROID // https://github.com/dotnet/maui/issues/28361
31+
[Test]
32+
public void ProgressSpinnerRemainsDisabledAfterSwappingContent()
33+
{
34+
App.WaitForElement("RefreshNotTriggered");
35+
App.WaitForElement("ListItem0");
36+
App.Tap("ResetContent");
37+
App.WaitForElement("ListItem0");
38+
App.ScrollUp("CollectionView");
39+
App.WaitForElement("RefreshNotTriggered");
40+
VerifyScreenshot("Issue28343_ProgressSpinnerDisabled");
41+
}
42+
#endif
43+
44+
[Test]
45+
public void ProgressSpinnerWorksWhenReEnabled()
46+
{
47+
App.WaitForElement("SetToEnabled").Tap();
48+
App.ScrollUp("CollectionView");
49+
App.WaitForElement("RefreshTriggered");
50+
}
51+
}
52+
#endif
53+
}
Loading

Diff for: src/Core/src/Platform/iOS/MauiRefreshView.cs

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ bool TryRemoveRefresh(UIView view, int index = 0)
132132

133133
bool TryInsertRefresh(UIView view, int index = 0)
134134
{
135+
if(!_refreshControl.Enabled)
136+
{
137+
return false;
138+
}
139+
135140
_refreshControlParent = view;
136141

137142
if (view is UIScrollView scrollView)

0 commit comments

Comments
 (0)