Skip to content

Commit 454838f

Browse files
committed
Addressed AI summary and added snapshot
1 parent 644226b commit 454838f

File tree

7 files changed

+35
-69
lines changed

7 files changed

+35
-69
lines changed

src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,25 +304,20 @@ public virtual void UpdateFlowDirection()
304304
if (ItemsView.Handler.PlatformView is UIView itemsView)
305305
{
306306
itemsView.UpdateFlowDirection(ItemsView);
307-
if (ItemsView.ItemTemplate is not null)
307+
foreach (var child in ItemsView.LogicalChildrenInternal)
308308
{
309-
foreach (var child in ItemsView.LogicalChildrenInternal)
309+
if (child is VisualElement ve && ve.Handler?.PlatformView is UIView view)
310310
{
311-
if (child is VisualElement ve && ve.Handler?.PlatformView is UIView view)
312-
{
313-
view.UpdateFlowDirection(ve);
314-
}
311+
view.UpdateFlowDirection(ve);
315312
}
316313
}
317-
else
314+
315+
// If we don't have an ItemTemplate, then we need to update the default cell's flow direction
316+
if (ItemsView.ItemTemplate is null && CollectionView?.VisibleCells is UICollectionViewCell[] visibleCells)
318317
{
319-
// If we don't have an ItemTemplate, then we need to update the default cell's flow direction
320-
if (CollectionView?.VisibleCells is UICollectionViewCell[] visibleCells)
318+
foreach (var cell in visibleCells.OfType<DefaultCell2>())
321319
{
322-
foreach (var cell in visibleCells.OfType<DefaultCell2>())
323-
{
324-
cell.Label.UpdateFlowDirection(ItemsView);
325-
}
320+
cell.Label.UpdateFlowDirection(ItemsView);
326321
}
327322
}
328323

src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -265,41 +265,15 @@ public override void UpdateFlowDirection()
265265
{
266266
base.UpdateFlowDirection();
267267

268-
UpdateSupplementaryViewsFlowDirection(
269-
ItemsView.Header,
270-
ItemsView.HeaderTemplate,
271-
UICollectionElementKindSectionKey.Header
272-
);
273-
274-
UpdateSupplementaryViewsFlowDirection(
275-
ItemsView.Footer,
276-
ItemsView.FooterTemplate,
277-
UICollectionElementKindSectionKey.Footer
278-
);
279-
}
280-
281-
void UpdateSupplementaryViewsFlowDirection(object content, DataTemplate template, NSString elementKind)
282-
{
283-
if (content is null && template is null)
284-
return;
285-
286-
var visibleViews = CollectionView.GetVisibleSupplementaryViews(elementKind);
268+
// Update DefaultCell2 string-based header/footer flow direction via tag lookup
269+
if (CollectionView.ViewWithTag(HeaderTag) is DefaultCell2 headerCell)
270+
{
271+
headerCell.Label.UpdateFlowDirection(ItemsView);
272+
}
287273

288-
foreach (var view in visibleViews)
274+
if (CollectionView.ViewWithTag(FooterTag) is DefaultCell2 footerCell)
289275
{
290-
if (view is DefaultCell2 defaultCell)
291-
{
292-
// String-based header/footer
293-
defaultCell.Label.UpdateFlowDirection(ItemsView);
294-
}
295-
else if (view is TemplatedCell2 templatedCell &&
296-
ItemsView.ItemTemplate is null &&
297-
templatedCell.PlatformHandler?.VirtualView is VisualElement ve &&
298-
ve.Handler?.PlatformView is UIView uiView)
299-
{
300-
// View or templated header/footer
301-
uiView.UpdateFlowDirection(ve);
302-
}
276+
footerCell.Label.UpdateFlowDirection(ItemsView);
303277
}
304278
}
305279
}
70.9 KB
Loading

src/Controls/tests/TestCases.HostApp/Issues/Issue32771.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
2-
31
namespace Maui.Controls.Sample.Issues;
42

5-
[Issue(IssueTracker.Github, 32771, "Flow direction not working on Header/Footer in CollectionView [iOS]", PlatformAffected.iOS)]
3+
[Issue(IssueTracker.Github, 32771, "Flow direction not working on Header/Footer in CollectionView [iOS]", PlatformAffected.iOS | PlatformAffected.macOS)]
64

75
public class Issue32771 : ContentPage
86
{
@@ -12,6 +10,7 @@ public Issue32771()
1210
{
1311
RowDefinitions =
1412
{
13+
new RowDefinition { Height = GridLength.Auto },
1514
new RowDefinition { Height = GridLength.Auto },
1615
new RowDefinition { Height = GridLength.Star },
1716
new RowDefinition { Height = GridLength.Star },
@@ -21,16 +20,7 @@ public Issue32771()
2120

2221
CollectionView2 headerFooterView = new CollectionView2
2322
{
24-
EmptyView = new Grid
25-
{
26-
Children =
27-
{
28-
new Label
29-
{
30-
Text = "No items to display"
31-
}
32-
}
33-
},
23+
EmptyView = "No items to display (String)",
3424
Header = new Grid
3525
{
3626
Children =
@@ -56,7 +46,7 @@ public Issue32771()
5646
Grid.SetRow(headerFooterView, 2);
5747
CollectionView2 headerFooterStringView = new CollectionView2
5848
{
59-
EmptyView = "No items to display",
49+
EmptyView = "No items to display (String)",
6050
Header = "Header String",
6151
Footer = "Footer String",
6252
Background = Colors.Gray
@@ -66,13 +56,7 @@ public Issue32771()
6656

6757
CollectionView2 headerFooterTemplateView = new CollectionView2
6858
{
69-
EmptyViewTemplate = new DataTemplate(() =>
70-
{
71-
return new Label
72-
{
73-
Text = "No items to display"
74-
};
75-
}),
59+
EmptyView = "No items to display (String)",
7660
HeaderTemplate = new DataTemplate(() =>
7761
{
7862
return new Label
@@ -92,6 +76,12 @@ public Issue32771()
9276
headerFooterTemplateView.FlowDirection = FlowDirection.LeftToRight;
9377
Grid.SetRow(headerFooterTemplateView, 3);
9478

79+
Label label = new Label
80+
{
81+
Text = "Current FlowDirection: LeftToRight",
82+
HorizontalOptions = LayoutOptions.Center
83+
};
84+
9585
Button button = new Button
9686
{
9787
Text = "Toggle FlowDirection",
@@ -104,18 +94,25 @@ public Issue32771()
10494
headerFooterView.FlowDirection = FlowDirection.RightToLeft;
10595
headerFooterStringView.FlowDirection = FlowDirection.RightToLeft;
10696
headerFooterTemplateView.FlowDirection = FlowDirection.RightToLeft;
97+
label.Text = "Current FlowDirection: RightToLeft";
10798
}
10899
else
109100
{
110101
headerFooterView.FlowDirection = FlowDirection.LeftToRight;
111102
headerFooterStringView.FlowDirection = FlowDirection.LeftToRight;
112103
headerFooterTemplateView.FlowDirection = FlowDirection.LeftToRight;
104+
label.Text = "Current FlowDirection: LeftToRight";
113105
}
114106
};
115107
Grid.SetRow(button, 0);
116108
grid.Children.Add(button);
109+
Grid.SetRow(label, 1);
110+
grid.Children.Add(label);
111+
Grid.SetRow(headerFooterStringView, 2);
117112
grid.Children.Add(headerFooterStringView);
113+
Grid.SetRow(headerFooterView, 3);
118114
grid.Children.Add(headerFooterView);
115+
Grid.SetRow(headerFooterTemplateView, 4);
119116
grid.Children.Add(headerFooterTemplateView);
120117
Content = grid;
121118
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32771.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public Issue32771(TestDevice testDevice) : base(testDevice)
1313

1414
[Test]
1515
[Category(UITestCategories.CollectionView)]
16-
public void ShellTitleShouldNotDisappear()
16+
public void FlowdirectionShouldWorkForHeaderFooter()
1717
{
1818
App.WaitForElement("ToggleFlowDirectionButton");
1919
App.Tap("ToggleFlowDirectionButton");
2020
VerifyScreenshot();
2121
}
22-
}
22+
}
91.8 KB
Loading
91.2 KB
Loading

0 commit comments

Comments
 (0)