@@ -4,7 +4,7 @@ namespace Maui.Controls.Sample
44{
55 public static class TestCases
66 {
7- public class TestCaseScreen : TableView
7+ public class TestCaseScreen : CollectionView
88 {
99 public static Dictionary < string , Action > PageToAction = new Dictionary < string , Action > ( StringComparer . OrdinalIgnoreCase ) ;
1010
@@ -44,18 +44,6 @@ void CheckInternetAndLoadPage(Type type)
4444 }
4545 }
4646
47-
48- static TextCell MakeIssueCell ( string text , string detail , Action tapped )
49- {
50- PageToAction [ text ] = tapped ;
51- if ( detail != null )
52- PageToAction [ detail ] = tapped ;
53-
54- var cell = new TextCell { Text = text , Detail = detail } ;
55- cell . Tapped += ( s , e ) => tapped ( ) ;
56- return cell ;
57- }
58-
5947 Action ActivatePageAndNavigate ( IssueAttribute issueAttribute , Type type )
6048 {
6149 Action navigationAction = null ;
@@ -148,7 +136,6 @@ public bool Matches(string filter)
148136 }
149137
150138 readonly List < IssueModel > _issues ;
151- TableSection _section ;
152139
153140 void VerifyNoDuplicates ( )
154141 {
@@ -170,8 +157,6 @@ public TestCaseScreen()
170157 {
171158 AutomationId = "TestCasesIssueList" ;
172159
173- Intent = TableIntent . Settings ;
174-
175160 var assembly = typeof ( TestCases ) . Assembly ;
176161
177162#if NATIVE_AOT
@@ -245,17 +230,17 @@ public void FilterIssues(string filter = null)
245230
246231 PageToAction . Clear ( ) ;
247232
248- var issueCells = Enumerable . Empty < TextCell > ( ) ;
233+ var issues = Enumerable . Empty < IssueModel > ( ) ;
249234
250235 if ( ! _filterBugzilla )
251236 {
252237 var bugzillaIssueCells =
253238 from issueModel in _issues
254239 where issueModel . IssueTracker == IssueTracker . Bugzilla && issueModel . Matches ( filter )
255240 orderby issueModel . IssueNumber descending
256- select MakeIssueCell ( issueModel . Name , issueModel . Description , issueModel . Action ) ;
241+ select issueModel ;
257242
258- issueCells = issueCells . Concat ( bugzillaIssueCells ) ;
243+ issues = issues . Concat ( bugzillaIssueCells ) ;
259244 }
260245
261246 if ( ! _filterGitHub )
@@ -264,9 +249,9 @@ orderby issueModel.IssueNumber descending
264249 from issueModel in _issues
265250 where issueModel . IssueTracker == IssueTracker . Github && issueModel . Matches ( filter )
266251 orderby issueModel . IssueNumber descending
267- select MakeIssueCell ( issueModel . Name , issueModel . Description , issueModel . Action ) ;
252+ select issueModel ;
268253
269- issueCells = issueCells . Concat ( githubIssueCells ) ;
254+ issues = issues . Concat ( githubIssueCells ) ;
270255 }
271256
272257 if ( ! _filterManual )
@@ -275,9 +260,9 @@ orderby issueModel.IssueNumber descending
275260 from issueModel in _issues
276261 where issueModel . IssueTracker == IssueTracker . ManualTest && issueModel . Matches ( filter )
277262 orderby issueModel . IssueNumber descending
278- select MakeIssueCell ( issueModel . Name , issueModel . Description , issueModel . Action ) ;
263+ select issueModel ;
279264
280- issueCells = issueCells . Concat ( manualIssueCells ) ;
265+ issues = issues . Concat ( manualIssueCells ) ;
281266 }
282267
283268 if ( ! _filterNone )
@@ -286,24 +271,53 @@ orderby issueModel.IssueNumber descending
286271 from issueModel in _issues
287272 where issueModel . IssueTracker == IssueTracker . None && issueModel . Matches ( filter )
288273 orderby issueModel . IssueNumber descending, issueModel . Description
289- select MakeIssueCell ( issueModel . Name , issueModel . Description , issueModel . Action ) ;
274+ select issueModel ;
290275
291- issueCells = issueCells . Concat ( untrackedIssueCells ) ;
276+ issues = issues . Concat ( untrackedIssueCells ) ;
292277 }
293278
294- if ( _section != null )
279+ ItemTemplate = new DataTemplate ( ( ) =>
295280 {
296- Root . Remove ( _section ) ;
297- }
281+ var grid = new Grid
282+ {
283+ Padding = 10 ,
284+ RowDefinitions =
285+ {
286+ new RowDefinition { Height = GridLength . Auto } ,
287+ new RowDefinition { Height = GridLength . Star }
288+ }
289+ } ;
298290
299- _section = new TableSection ( "Bug Repro" ) ;
291+ var tapGestureRecognizer = new TapGestureRecognizer ( ) ;
292+ tapGestureRecognizer . Tapped += ( sender , args ) =>
293+ {
294+ var issueModel = ( IssueModel ) grid . BindingContext ;
295+ issueModel . Action ? . Invoke ( ) ;
296+ } ;
297+ grid . GestureRecognizers . Add ( tapGestureRecognizer ) ;
300298
301- foreach ( var issueCell in issueCells )
302- {
303- _section . Add ( issueCell ) ;
304- }
299+ var titleLabel = new Label
300+ {
301+ FontSize = 14 ,
302+ FontAttributes = FontAttributes . Bold ,
303+ } ;
304+ titleLabel . SetBinding ( Label . TextProperty , "IssueNumber" ) ;
305+
306+ var descriptionLabel = new Label
307+ {
308+ FontSize = 12 ,
309+ } ;
310+ descriptionLabel . SetBinding ( Label . TextProperty , "Description" ) ;
305311
306- Root . Add ( _section ) ;
312+ grid . Add ( titleLabel ) ;
313+ Grid . SetRow ( titleLabel , 0 ) ;
314+ grid . Add ( descriptionLabel ) ;
315+ Grid . SetRow ( descriptionLabel , 1 ) ;
316+
317+ return grid ;
318+ } ) ;
319+
320+ ItemsSource = issues ;
307321 }
308322
309323 HashSet < string > _exemptNames = new HashSet < string > { } ;
@@ -316,7 +330,13 @@ from issueModel in _issues
316330 public static NavigationPage GetTestCases ( )
317331 {
318332 TestCaseScreen testCaseScreen = null ;
319- var rootLayout = new StackLayout ( ) ;
333+ var rootLayout = new Grid ( ) ;
334+
335+ rootLayout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Auto } ) ;
336+ rootLayout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Auto } ) ;
337+ rootLayout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Auto } ) ;
338+ rootLayout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Auto } ) ;
339+ rootLayout . RowDefinitions . Add ( new RowDefinition { Height = GridLength . Star } ) ;
320340
321341 var testCasesRoot = new ContentPage
322342 {
@@ -352,7 +372,6 @@ public static NavigationPage GetTestCases()
352372 System . Diagnostics . Debug . WriteLine ( e . Message ) ;
353373 Console . WriteLine ( e . Message ) ;
354374 }
355-
356375 } )
357376 } ;
358377
@@ -364,14 +383,21 @@ public static NavigationPage GetTestCases()
364383 } ;
365384
366385 rootLayout . Children . Add ( leaveTestCasesButton ) ;
386+ Grid . SetRow ( leaveTestCasesButton , 0 ) ;
387+
367388 rootLayout . Children . Add ( searchBar ) ;
368- rootLayout . Children . Add ( searchButton ) ;
389+ Grid . SetRow ( searchBar , 1 ) ;
369390
370- testCaseScreen = new TestCaseScreen ( ) ;
391+ rootLayout . Children . Add ( searchButton ) ;
392+ Grid . SetRow ( searchButton , 2 ) ;
371393
372- rootLayout . Children . Add ( CreateTrackerFilter ( testCaseScreen ) ) ;
394+ var trackerFilter = CreateTrackerFilter ( testCaseScreen ) ;
395+ rootLayout . Children . Add ( trackerFilter ) ;
396+ Grid . SetRow ( trackerFilter , 3 ) ;
373397
398+ testCaseScreen = new TestCaseScreen ( ) ;
374399 rootLayout . Children . Add ( testCaseScreen ) ;
400+ Grid . SetRow ( testCaseScreen , 4 ) ;
375401
376402 searchBar . TextChanged += ( sender , args ) => SearchBarOnTextChanged ( sender , args , testCaseScreen ) ;
377403
@@ -434,5 +460,4 @@ static void SearchBarOnTextChanged(object sender, TextChangedEventArgs textChang
434460 cases . FilterIssues ( filter ) ;
435461 }
436462 }
437-
438463}
0 commit comments