Skip to content

Commit c59607a

Browse files
authored
[2025/03/24] Candidate - In Flight Branch (#28560)
### Description of Change Only PRs related to fixing this branch should be merge here For more information about inflight process check #28486
2 parents c680563 + 06e8924 commit c59607a

File tree

118 files changed

+2999
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+2999
-237
lines changed

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ public override void PushViewController(UIViewController viewController, bool an
610610

611611
public override UIViewController PopViewController(bool animated)
612612
{
613+
_popRequested = true;
613614
_pendingViewControllers = null;
614615
if (IsInMoreTab && ParentViewController is UITabBarController tabBarController)
615616
{

src/Controls/src/Core/Compatibility/iOS/Extensions/ToolbarItemExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ void UpdateIconAndStyle(ToolbarItem item)
114114
{
115115
Image = result?.Value;
116116
Style = UIBarButtonItemStyle.Plain;
117-
if (item.IconImageSource is FontImageSource fontImageSource && fontImageSource.Color is not null)
118-
{
119-
TintColor = fontImageSource.Color.ToPlatform();
120-
}
121117
});
122118
}
123119
}

src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,24 @@ void CollectionItemsSourceChanged(object sender, System.Collections.Specialized.
271271
return;
272272
}
273273

274+
// While Modifying the collection we should consider the ItemsUpdatingScrollMode to update the position
275+
if (Carousel.ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepLastItemInView)
276+
{
277+
if (count == 0)
278+
{
279+
carouselPosition = 0;
280+
}
281+
else
282+
{
283+
carouselPosition = count - 1;
284+
}
285+
286+
}
287+
else if (Carousel.ItemsUpdatingScrollMode == ItemsUpdatingScrollMode.KeepItemsInView)
288+
{
289+
carouselPosition = 0;
290+
}
291+
274292
Carousel.
275293
Handler.
276294
MauiContext.

src/Controls/src/Core/Handlers/Items/ItemsViewHandler.Windows.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ protected override void DisconnectHandler(ListViewBase platformView)
5858
{
5959
VirtualView.ScrollToRequested -= ScrollToRequested;
6060
CleanUpCollectionViewSource(platformView);
61+
_formsEmptyView?.Handler?.DisconnectHandler();
6162
base.DisconnectHandler(platformView);
6263
}
6364

src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,17 @@ void CollectionViewUpdating(object sender, NotifyCollectionChangedEventArgs e)
334334
[UnconditionalSuppressMessage("Memory", "MEM0003", Justification = "Proven safe in test: MemoryTests.HandlerDoesNotLeak")]
335335
void CollectionViewUpdated(object sender, NotifyCollectionChangedEventArgs e)
336336
{
337+
int targetPosition;
337338
if (_positionAfterUpdate == -1)
338339
{
339340
return;
340341
}
341342

342343
_gotoPosition = -1;
343344

344-
var targetPosition = _positionAfterUpdate;
345+
// We need to update the position while modifying the collection.
346+
targetPosition = GetTargetPosition();
347+
345348
_positionAfterUpdate = -1;
346349

347350
SetPosition(targetPosition);
@@ -354,6 +357,22 @@ int GetPositionWhenAddingItems(int carouselPosition, int currentItemPosition)
354357
return currentItemPosition != -1 ? currentItemPosition : carouselPosition;
355358
}
356359

360+
private int GetTargetPosition()
361+
{
362+
363+
if (ItemsSource.ItemCount == 0)
364+
{
365+
return 0;
366+
}
367+
368+
return ItemsView.ItemsUpdatingScrollMode switch
369+
{
370+
ItemsUpdatingScrollMode.KeepItemsInView => 0,
371+
ItemsUpdatingScrollMode.KeepLastItemInView => ItemsSource.ItemCount - 1,
372+
_ => _positionAfterUpdate
373+
};
374+
}
375+
357376
int GetPositionWhenResetItems()
358377
{
359378
//If we are reseting the collection Position should go to 0

src/Controls/src/Core/Handlers/Items/iOS/ObservableGroupedSource.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,7 @@ void CollectionChanged(NotifyCollectionChangedEventArgs args)
164164

165165
// Force UICollectionView to get the internal accounting straight
166166
var collectionView = controller.CollectionView;
167-
if (!collectionView.Hidden)
168-
{
169-
var numberOfSections = collectionView.NumberOfSections();
170-
for (int section = 0; section < numberOfSections; section++)
171-
{
172-
collectionView.NumberOfItemsInSection(section);
173-
}
174-
}
167+
UpdateSection(collectionView);
175168

176169
switch (args.Action)
177170
{
@@ -193,8 +186,23 @@ void CollectionChanged(NotifyCollectionChangedEventArgs args)
193186
default:
194187
throw new ArgumentOutOfRangeException();
195188
}
189+
190+
// Calculate section and item counts after processing changes
191+
// to ensure UICollectionView reflects the updated state
192+
UpdateSection(collectionView);
196193
}
197194

195+
void UpdateSection(UICollectionView collectionView)
196+
{
197+
if (!collectionView.Hidden)
198+
{
199+
var numberOfSections = collectionView.NumberOfSections();
200+
for (int section = 0; section < numberOfSections; section++)
201+
{
202+
collectionView.NumberOfItemsInSection(section);
203+
}
204+
}
205+
}
198206
void Reload(bool collectionWasReset = false)
199207
{
200208
ResetGroupTracking();

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,17 @@ void CollectionViewUpdating(object sender, NotifyCollectionChangedEventArgs e)
254254
[UnconditionalSuppressMessage("Memory", "MEM0003", Justification = "Proven safe in test: MemoryTests.HandlerDoesNotLeak")]
255255
void CollectionViewUpdated(object sender, NotifyCollectionChangedEventArgs e)
256256
{
257+
int targetPosition;
257258
if (_positionAfterUpdate == -1)
258259
{
259260
return;
260261
}
261262

262263
//_gotoPosition = -1;
263264

264-
var targetPosition = _positionAfterUpdate;
265+
// We need to update the position while modifying the collection.
266+
targetPosition = GetTargetPosition();
267+
265268
_positionAfterUpdate = -1;
266269

267270
SetPosition(targetPosition);
@@ -291,6 +294,21 @@ int GetPositionWhenAddingItems(int carouselPosition, int currentItemPosition)
291294
return currentItemPosition != -1 ? currentItemPosition : carouselPosition;
292295
}
293296

297+
private int GetTargetPosition()
298+
{
299+
if (ItemsSource.ItemCount == 0)
300+
{
301+
return 0;
302+
}
303+
304+
return ItemsView.ItemsUpdatingScrollMode switch
305+
{
306+
ItemsUpdatingScrollMode.KeepItemsInView => 0,
307+
ItemsUpdatingScrollMode.KeepLastItemInView => ItemsSource.ItemCount - 1,
308+
_ => _positionAfterUpdate
309+
};
310+
}
311+
294312
int GetPositionWhenResetItems()
295313
{
296314
//If we are reseting the collection Position should go to 0

src/Controls/src/Core/Internals/PropertyPropagationExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#nullable disable
2+
using System;
23
using System.Collections;
34
using System.Collections.Generic;
45
using System.Linq;
@@ -8,6 +9,15 @@ namespace Microsoft.Maui.Controls.Internals
89
/// <include file="../../../docs/Microsoft.Maui.Controls.Internals/PropertyPropagationExtensions.xml" path="Type[@FullName='Microsoft.Maui.Controls.Internals.PropertyPropagationExtensions']/Docs/*" />
910
public static class PropertyPropagationExtensions
1011
{
12+
[Obsolete]
13+
internal static void PropagatePropertyChanged(string propertyName, Element element, IEnumerable children)
14+
{
15+
if (children == null)
16+
return;
17+
18+
PropagatePropertyChanged(propertyName, element, children.OfType<IVisualTreeElement>().ToList());
19+
}
20+
1121
internal static void PropagatePropertyChanged(string propertyName, Element element, IReadOnlyList<IVisualTreeElement> children)
1222
{
1323
if (propertyName == null || propertyName == VisualElement.FlowDirectionProperty.PropertyName)

0 commit comments

Comments
 (0)