1+ using System . Linq ;
2+
3+ namespace Maui . Controls . Sample . Issues
4+ {
5+ [ Issue ( IssueTracker . Github , 30690 , "RefreshView IsRefreshEnabled Property and Consistent IsEnabled Behavior" , PlatformAffected . All ) ]
6+ public class Issue30690 : TestContentPage
7+ {
8+ RefreshView _refreshView ;
9+ Label _statusLabel ;
10+ Entry _testEntry ;
11+
12+ public Issue30690 ( )
13+ {
14+ }
15+
16+ protected override void Init ( )
17+ {
18+ Title = "RefreshView IsRefreshEnabled Tests" ;
19+
20+ // Create status label to show current states
21+ _statusLabel = new Label
22+ {
23+ AutomationId = "StatusLabel" ,
24+ Text = "Ready to test" ,
25+ BackgroundColor = Colors . LightGray ,
26+ Padding = 10
27+ } ;
28+
29+ // Create a test entry to verify child control interaction
30+ _testEntry = new Entry
31+ {
32+ AutomationId = "TestEntry" ,
33+ Placeholder = "Type here to test child interaction" ,
34+ BackgroundColor = Colors . LightBlue ,
35+ Margin = 10
36+ } ;
37+
38+ // Create scrollable content
39+ var scrollViewContent = new StackLayout ( ) ;
40+ scrollViewContent . Children . Add ( _testEntry ) ;
41+
42+ Enumerable
43+ . Range ( 0 , 5 )
44+ . Select ( i => new Label ( )
45+ {
46+ HeightRequest = 100 ,
47+ Text = $ "Item { i + 1 } - Pull down to refresh",
48+ BackgroundColor = i % 2 == 0 ? Colors . LightGreen : Colors . LightYellow ,
49+ VerticalTextAlignment = TextAlignment . Center ,
50+ HorizontalTextAlignment = TextAlignment . Center
51+ } )
52+ . ToList ( )
53+ . ForEach ( scrollViewContent . Children . Add ) ;
54+
55+ // Create refresh view
56+ _refreshView = new RefreshView ( )
57+ {
58+ AutomationId = "TestRefreshView" ,
59+ Content = new ScrollView ( )
60+ {
61+ Content = scrollViewContent ,
62+ AutomationId = "ScrollViewContent"
63+ } ,
64+ Command = new Command ( async ( ) =>
65+ {
66+ UpdateStatusLabel ( "Refreshing..." ) ;
67+ await Task . Delay ( 1000 ) ;
68+ _refreshView . IsRefreshing = false ;
69+ UpdateStatusLabel ( "Refresh completed" ) ;
70+ } )
71+ } ;
72+
73+ // Update status when refresh state changes
74+ _refreshView . Refreshing += ( sender , args ) => UpdateStatusLabel ( "Refresh started" ) ;
75+
76+ Content = new StackLayout ( )
77+ {
78+ Padding = 10 ,
79+ Children =
80+ {
81+ _statusLabel ,
82+
83+ // Control buttons
84+ new Button ( )
85+ {
86+ AutomationId = "ToggleIsRefreshEnabled" ,
87+ Text = "Toggle IsRefreshEnabled" ,
88+ Command = new Command ( ( ) =>
89+ {
90+ _refreshView . IsRefreshEnabled = ! _refreshView . IsRefreshEnabled ;
91+ UpdateStatusLabel ( $ "IsRefreshEnabled: { _refreshView . IsRefreshEnabled } ") ;
92+ } )
93+ } ,
94+
95+ new Button ( )
96+ {
97+ AutomationId = "ToggleIsEnabled" ,
98+ Text = "Toggle IsEnabled" ,
99+ Command = new Command ( ( ) =>
100+ {
101+ _refreshView . IsEnabled = ! _refreshView . IsEnabled ;
102+ UpdateStatusLabel ( $ "IsEnabled: { _refreshView . IsEnabled } ") ;
103+ } )
104+ } ,
105+
106+ new Button ( )
107+ {
108+ AutomationId = "StartRefresh" ,
109+ Text = "Start Refresh Programmatically" ,
110+ Command = new Command ( ( ) =>
111+ {
112+ _refreshView . IsRefreshing = true ;
113+ } )
114+ } ,
115+
116+ new Button ( )
117+ {
118+ AutomationId = "CheckStates" ,
119+ Text = "Check Current States" ,
120+ Command = new Command ( ( ) =>
121+ {
122+ UpdateStatusLabel ( $ "IsEnabled: { _refreshView . IsEnabled } , IsRefreshEnabled: { _refreshView . IsRefreshEnabled } , IsRefreshing: { _refreshView . IsRefreshing } ") ;
123+ } )
124+ } ,
125+
126+ new Button ( )
127+ {
128+ AutomationId = "TestEntryFocus" ,
129+ Text = "Focus Entry" ,
130+ Command = new Command ( ( ) =>
131+ {
132+ _testEntry . Focus ( ) ;
133+ UpdateStatusLabel ( "Entry focus attempted" ) ;
134+ } )
135+ } ,
136+
137+ _refreshView
138+ }
139+ } ;
140+
141+ // Initial status
142+ UpdateStatusLabel ( $ "Initial - IsEnabled: { _refreshView . IsEnabled } , IsRefreshEnabled: { _refreshView . IsRefreshEnabled } ") ;
143+ }
144+
145+ private void UpdateStatusLabel ( string message )
146+ {
147+ _statusLabel . Text = $ "{ DateTime . Now : HH:mm:ss} - { message } ";
148+ }
149+ }
150+ }
0 commit comments