Skip to content

Commit 0572098

Browse files
PureWeenmattleibowMartyIXkubaflojsuarezruiz
authored
[net9.0] Merge main into net9.0 (#23126)
* Size and SizeF should not throw on NaN * Fix Release Versioning * Upgrade from 1.5.1 to 1.5.4 * SwipeView Fix #22580 (#22741) Co-authored-by: Javier Suárez <[email protected]> * Update vscode extension recommendations * [XC] Fix SimplifyTypeExtensionVisitor (#23043) * Add test * Fix the visitor * Add SR6 to issue template (#23071) * Make sure the main branch is using .NET 8 SDK (#23077) * Make sure the main branch is using .NET 8 SDK The main branch needs to use the .NET 8 SDK because we are building the .NET 7 TFMs as well. The .NET 9 SDK does not support .NET 7 TFMs anymore. * no previews! * Setup preview versioning for SR6.1 * Remove compat appium tests Since we're moving in a different direction for moving these over in #22635 these projects (and the Issue11853 test, since it's in the other PR) can be deleted. * [main] Update arcade and xharness (#22981) * Update arcade * Update dotnet-tools.json * Update xharness # Conflicts: # .config/dotnet-tools.json # eng/Version.Details.xml # eng/Versions.props * Remove more references to removed projects * Make titlebar button foreground colors use app theme * Update dependencies from https://github.com/dotnet/xharness build 20240612.3 (#23088) Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 9.0.0-prerelease.24311.2 -> To Version 9.0.0-prerelease.24312.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Add additional logging for PopLifeCycle * Remove more legacy pipeline bits * [iOS] Fixed NRE after calling ViewCell.ForceUpdateSize (#23094) * [iOS] Fixed NRE after calling ViewCell.ForceUpdateSize * - add test --------- Co-authored-by: Shane Neuville <[email protected]> * Add x:DataType to the carousel view UI tests (#23113) * Bump to Android 34.0.113 Context: https://github.com/dotnet/android/releases/34.0.113 Changes: dotnet/android@34.0.79...34.0.113 I noticed the Android workload version used in dotnet/maui/main was a couple service releases old. We should use the latest one, as it has a memory leak fix for `Post()`. * Squashed commit of the following: (#22874) commit db8a3bd Author: Matthew Leibowitz <[email protected]> Date: Mon Jun 10 13:46:16 2024 +0800 Add android commit 0bd2d65 Author: Matthew Leibowitz <[email protected]> Date: Mon Jun 10 12:16:34 2024 +0800 oops! commit 647e5f5 Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 18:15:40 2024 +0800 Almost commit c3ea650 Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 16:17:58 2024 +0800 sadfasdf commit d9a398f Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 13:56:34 2024 +0800 screenshots commit 4b3c01f Merge: 595ff03 e94b364 Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 13:54:52 2024 +0800 Merge branch 'main' into dev/gif-in-release commit 595ff03 Author: Matthew Leibowitz <[email protected]> Date: Thu Jun 6 21:00:52 2024 +0800 Update ImageUITests.cs commit 2c20fe0 Author: Matthew Leibowitz <[email protected]> Date: Thu Jun 6 19:05:23 2024 +0800 Make some tests commit 1e82e8b Author: Matthew Leibowitz <[email protected]> Date: Thu Jun 6 18:44:18 2024 +0800 Take 2? commit d576c82 Author: Matthew Leibowitz <[email protected]> Date: Thu Jun 6 07:11:17 2024 +0800 Fix animated gifs in Release builds * Fix loaded so it fires on second subscription (#23095) * Fix loaded so it fires on second subscription * Update VisualElement.cs * Make sure the view is still alive after posting (#23114) I saw in some of my local testing the shape view may actually be disposed if you write code or when you run the device tests. When we come back after the UI loop, make sure the platform view is still alive. This should not happen if the view is attached to the UI since it is still being used, but if you happen to navigate or close some popup it may occur. * [iOS] TapGestureRecognizer should not fire when view is not enabled (#23049) * Don't receive touch when view is disabled * Add UITest for Single Tap enabled/disabled This removes the first pass unit test version which isn't really testing the scenario properly. * Fix element automation id * Don't fire tap for windows if control disabled * Make failure case text less confusing * [Tests] Update to Appium 5.0.0 (#23118) * Update to appium 5.0.0 Their driver has some removed methods (LaunchApp/CloseApp) which seem to be now implemented for windows. Also removed an extra explicit ref to system.drawing.common since it comes in transitively from appium.webdriver package (and the version was causing issues since the newer appium.webdriver uses a newer version). * Fix windows launchapp/closeapp for newer appium In Appium's dotnet driver in v5.0.0 they removed `LaunchApp` from the driver: appium/dotnet-client#766 The deprecation suggests using `ActivateApp` as an alternative, but that throws an error saying it's not implemented on the windows driver. Curiously, `CloseApp` which was also marked as deprecated was _moved_ from the base appium driver to the `WindowsDriver` here: appium/dotnet-client#773 I think the same treatment should have been done to the `LaunchApp` method since there's no alternative in windows. For now the workaround is to invoke the command manually: `windowsDriver.ExecuteScript("windows: launchApp", [_app.GetAppId()]);` * Use correct interface type in FrameRenderer (#23124) * Use correct interface type in FrameRenderer (#23124) (#23146) * Squashed commit of the following: (#19629) commit f6c3bfa Merge: d0b3f84 3143629 Author: Matthew Leibowitz <[email protected]> Date: Mon Jun 17 19:58:40 2024 +0800 Merge remote-tracking branch 'origin/main' into dev/macos-actionsheet commit d0b3f84 Author: Matthew Leibowitz <[email protected]> Date: Tue Jun 11 05:00:38 2024 +0800 Fix the older macOS testing commit 3dc6b4d Author: Matthew Leibowitz <[email protected]> Date: Mon Jun 10 23:40:40 2024 +0800 macOS 13 things commit e3e48e4 Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 02:15:55 2024 +0800 docs commit 693d79c Merge: 3dbce49 a3c872d Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 02:08:31 2024 +0800 Merge remote-tracking branch 'origin/main' into dev/macos-actionsheet commit 3dbce49 Merge: 17ea9c6 93a1bc4 Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 02:06:16 2024 +0800 Merge remote-tracking branch 'origin/main' into dev/macos-actionsheet commit 17ea9c6 Author: Matthew Leibowitz <[email protected]> Date: Sat Jun 8 02:05:42 2024 +0800 Fix the tests commit 026da41 Author: Matthew Leibowitz <[email protected]> Date: Fri Jun 7 03:56:26 2024 +0800 fixes commit d2b85d5 Author: Matthew Leibowitz <[email protected]> Date: Thu Jun 6 23:58:33 2024 +0800 namespaces commit 9fa77cd Merge: 3f9596b 9d71d32 Author: Matthew Leibowitz <[email protected]> Date: Thu Jun 6 23:57:00 2024 +0800 Merge branch 'main' into dev/macos-actionsheet # Conflicts: # src/Controls/samples/Controls.Sample.UITests/Test.cs # src/Controls/src/Core/Platform/AlertManager/AlertManager.iOS.cs # src/Controls/tests/TestCases.Shared.Tests/Tests/Concepts/AlertsGalleryTests.cs # src/Controls/tests/TestCases/Concepts/AlertsGalleryPage.cs # src/TestUtils/src/UITest.Appium/AppiumCatalystApp.cs # src/TestUtils/src/UITest.Appium/HelperExtensions.cs commit 3f9596b Author: Matthew Leibowitz <[email protected]> Date: Sat Dec 30 09:29:31 2023 +0200 Add some UI tests Done: iOS/macOS/Android. TODO: Windows commit 68c930f Author: Matthew Leibowitz <[email protected]> Date: Tue Dec 19 18:15:51 2023 +0200 macOS does not use PopoverPresentationController Fixes #18156 * [ios/catalyst] fix more cycles in `NavigationPage` Fixes: #21453 Context: #22810 In #22810, a leak in `NavigationPage` was fixed for the case: Application.Current.MainPage = new NavigationPage(new Page1()); Application.Current.MainPage = new Page2(); However, it does *not* work for the case: await Navigation.PushModalAsync(new NavigationPage(new Page1())); await Navigation.PopModalAsync(); I could reproduce this problem in `MemoryTests.cs`. There were still a few cycles in `NavigationRenderer`: * `NavigationRenderer` -> `VisualElement _element` -> `NavigationRenderer` * `NavigationRenderer` -> `Page Current` -> `NavigationRenderer` * `NavigationRenderer` -> `ViewHandlerDelegator<NavigationPage> _viewHandlerWrapper` -> `TElement _element` -> `NavigationRenderer` After fixing these cycles, the test passes. `ViewHandlerDelegator` was slightly tricky, as I had to make a `_tempElement` variable and *unset* it immediately after use. * Only change ViewHandlerDelegator for iOS/Catalyst * [ios] fix leak in ListView *Cells (#23143) * [ios] fix leak in ListView *Cells Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2064274 After fixing #22867 for `CollectionView`, there was still a problem with `ListView`. The following types were leaking in the sample app: * `UIKit.UITableView` * `Microsoft.Maui.Controls.Handlers.Compatibility.ViewCellRenderer.ViewTableCell` * `Microsoft.Maui.Platform.MauiLabel` * `Microsoft.Maui.Platform.MauiImageView` * `Microsoft.Maui.Platform.WrapperView` After a lot of debugging, we found that `Cell` was holding a reference to the `UITableView`. This pointed *up* in the hierarchy, creating a cycle. I updated an existing device test to ensure the problem is solved. * Fix missing handlers in tests * Remove assertion * Fix UITableView reference * Update a different test * Can't enumerate while adding * Missed a null check * [Housekeeping] Added UI Test to validate project template (#18567) * Added template UI Test * Added pending snapshot * Updated snapshot * Generate snapshots for all the platforms * Added pending snapshots * Updated snapshot * More changes * Updated droid snapshot * More changes * Updated snapshots * Added sample path * Update Issue19509.cs * Update Issue19509.cs --------- Co-authored-by: Shane Neuville <[email protected]> * Optimize resetting gesture recognizers (#19987) * reduce LINQ usage * Remove useless check that will always be false * use HashSet * reduce enumerations and casting * reduce LINQ usage * only cast once * add benchmarks * fix build --------- Co-authored-by: Edward Miller <[email protected]> * [Windows] Fix ListView insert not working properly (#22746) * Add test * Remove force layout update during collection changed event * Adjust await * Update ListViewTests.Windows.cs --------- Co-authored-by: Mike Corsaro <[email protected]> * Fix <ApplicationTitle> encoding in maui templates (#22084) * Makes <ApplicationTitle> use a custom symbol instead of the default name parameter to ensure the name is XML encoded where necessaru * Adds new tests for various encodings and special characters --------- Co-authored-by: Eilon Lipton <[email protected]> * Fixed a null check #15102 (#23170) * [ios/catalyst] fix memory leak in TabbedPage (#23166) * [ios/catalyst] fix memory leak in TabbedPage Context: #23164 Just the same way as `NavigationPage` in #23164, `TabbedPage` also has a memory leak caused by the cycle: * `TabbedPage` -> `TabbedRenderer` -> `VisualElement _element;` -> `TabbedPage I could add a new `[Theory]` in `MemoryTests.cs` to see the issue. This PR fixes the memory leak by breaking the cycle in `TabbedRenderer`. * Ignore test on Windows I also cleaned up the Task.Delay() * [iOS] Set PlatformGraphicsView to transparent input (#23208) * Avoid JavaCast and exceptions and ask Java (#23215) * Wire RefreshView up to our xplat layout workflow (#23169) * Use better layout/measure path with refreshview * - fix naming * - set RefreshView content to maui compatible container * - add test * - fix null operator * Update Issue23029.xaml.cs * - fix content panel so it removes previous content * - add additional check * Fix Merge --------- Co-authored-by: Matthew Leibowitz <[email protected]> Co-authored-by: MartyIX <[email protected]> Co-authored-by: Jakub Florkowski <[email protected]> Co-authored-by: Javier Suárez <[email protected]> Co-authored-by: redth <[email protected]> Co-authored-by: Šimon Rozsíval <[email protected]> Co-authored-by: Rui Marinho <[email protected]> Co-authored-by: Mike Corsaro <[email protected]> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Vitaly Knyazev <[email protected]> Co-authored-by: Jonathan Peppers <[email protected]> Co-authored-by: Jonathan Dick <[email protected]> Co-authored-by: Edward Miller <[email protected]> Co-authored-by: Edward Miller <[email protected]> Co-authored-by: Mike Corsaro <[email protected]> Co-authored-by: Michael Yanni <[email protected]> Co-authored-by: Eilon Lipton <[email protected]> Co-authored-by: Tim Miller <[email protected]>
1 parent 27a83b7 commit 0572098

File tree

111 files changed

+1914
-530
lines changed

Some content is hidden

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

111 files changed

+1914
-530
lines changed

.config/dotnet-tools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
"microsoft.dotnet.xharness.cli": {
24-
"version": "9.0.0-prerelease.24311.2",
24+
"version": "9.0.0-prerelease.24312.3",
2525
"commands": [
2626
"xharness"
2727
]

.github/ISSUE_TEMPLATE/bug-report.yml

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ body:
4949
- 9.0.0-preview.3.10457
5050
- 9.0.0-preview.2.10293
5151
- 9.0.0-preview.1.9973
52+
- 8.0.60 SR6
5253
- 8.0.40 SR5
5354
- 8.0.21 SR4.1
5455
- 8.0.20 SR4
@@ -111,6 +112,7 @@ body:
111112
- 8.0.20 SR4
112113
- 8.0.21 SR4.1
113114
- 8.0.40 SR5
115+
- 8.0.60 SR6
114116
- 9.0.0-preview.1.9973
115117
- 9.0.0-preview.2.10293
116118
- 9.0.0-preview.3.10457

.vscode/extensions.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"recommendations": [
3-
"ms-dotnettools.csharp",
4-
"ms-vscode.mono-debug",
5-
"visualstudioexptteam.vscodeintellicode",
3+
"ms-dotnettools.vscodeintellicode-csharp",
4+
"ms-dotnettools.dotnet-maui",
5+
"github.copilot-chat"
66
]
77
}

eng/Version.Details.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@
135135
<Uri>https://github.com/dotnet/runtime</Uri>
136136
<Sha>4a0a04cf3e8b8c2a3613270df7f838246e4597e8</Sha>
137137
</Dependency>
138-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.24311.2">
138+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.24312.3">
139139
<Uri>https://github.com/dotnet/xharness</Uri>
140-
<Sha>975b330d51119efc4884f7a323784662cbf74391</Sha>
140+
<Sha>6ce15319de72ab6d4c3b0f4c40f59300cffc5450</Sha>
141141
</Dependency>
142-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="9.0.0-prerelease.24311.2">
142+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="9.0.0-prerelease.24312.3">
143143
<Uri>https://github.com/dotnet/xharness</Uri>
144-
<Sha>975b330d51119efc4884f7a323784662cbf74391</Sha>
144+
<Sha>6ce15319de72ab6d4c3b0f4c40f59300cffc5450</Sha>
145145
</Dependency>
146-
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="9.0.0-prerelease.24311.2">
146+
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="9.0.0-prerelease.24312.3">
147147
<Uri>https://github.com/dotnet/xharness</Uri>
148-
<Sha>975b330d51119efc4884f7a323784662cbf74391</Sha>
148+
<Sha>6ce15319de72ab6d4c3b0f4c40f59300cffc5450</Sha>
149149
</Dependency>
150150
</ProductDependencies>
151151
<ToolsetDependencies>

eng/Versions.props

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>9.0.0-preview.5.24273.1</MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion>
6363
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
6464
<!-- wasdk -->
65-
<MicrosoftWindowsAppSDKPackageVersion>1.5.240311000</MicrosoftWindowsAppSDKPackageVersion>
65+
<MicrosoftWindowsAppSDKPackageVersion>1.5.240607001</MicrosoftWindowsAppSDKPackageVersion>
6666
<MicrosoftWindowsSDKBuildToolsPackageVersion>10.0.22621.756</MicrosoftWindowsSDKBuildToolsPackageVersion>
6767
<MicrosoftGraphicsWin2DPackageVersion>1.2.0</MicrosoftGraphicsWin2DPackageVersion>
6868
<!-- Everything else -->
@@ -108,9 +108,9 @@
108108
<_HarfBuzzSharpVersion>7.3.0.2</_HarfBuzzSharpVersion>
109109
<_SkiaSharpNativeAssetsVersion>0.0.0-commit.7af1d0840a381c0ce7ef2877454a88dbb2949686.1086</_SkiaSharpNativeAssetsVersion>
110110
<MicrosoftTemplateEngineTasksVersion>7.0.114</MicrosoftTemplateEngineTasksVersion>
111-
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>9.0.0-prerelease.24311.2</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
112-
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.24311.2</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
113-
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.24311.2</MicrosoftDotNetXHarnessCLIVersion>
111+
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>9.0.0-prerelease.24312.3</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
112+
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.24312.3</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
113+
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.24312.3</MicrosoftDotNetXHarnessCLIVersion>
114114
<TizenUIExtensionsVersion>0.9.2</TizenUIExtensionsVersion>
115115
<SvgSkiaPackageVersion>1.0.0.16</SvgSkiaPackageVersion>
116116
<FizzlerPackageVersion>1.3.0</FizzlerPackageVersion>

src/Controls/src/Core/Cells/Cell.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async void OnForceUpdateSizeRequested()
273273
// don't run more than once per 16 milliseconds
274274
await Task.Delay(TimeSpan.FromMilliseconds(16));
275275
ForceUpdateSizeRequested?.Invoke(this, null);
276-
Handler.Invoke("ForceUpdateSizeRequested", null);
276+
Handler?.Invoke("ForceUpdateSizeRequested", null);
277277

278278
_nextCallToForceUpdateSizeQueued = false;
279279
}
@@ -307,8 +307,14 @@ void OnParentPropertyChanging(object sender, PropertyChangingEventArgs e)
307307
internal Android.Views.View ConvertView { get; set; }
308308
#elif IOS
309309
internal UIKit.UITableViewCell ReusableCell { get; set; }
310-
internal UIKit.UITableView TableView { get; set; }
311310

311+
WeakReference<UIKit.UITableView> _tableView;
312+
313+
internal UIKit.UITableView TableView
314+
{
315+
get => _tableView?.GetTargetOrDefault();
316+
set => _tableView = value is null ? null : new(value);
317+
}
312318
#endif
313319

314320

src/Controls/src/Core/Compatibility/Handlers/Android/FrameRenderer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ protected override void OnLayout(bool changed, int l, int t, int r, int b)
176176

177177

178178
if (Element.Handler is IPlatformViewHandler pvh &&
179-
Element is IContentView cv)
179+
Element is ICrossPlatformLayout cv)
180180
{
181181
pvh.LayoutVirtualView(l, t, r, b, cv.CrossPlatformArrange);
182182
}

src/Controls/src/Core/Compatibility/Handlers/ListView/Windows/ListViewRenderer.cs

-2
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
260260
ClearSizeEstimate();
261261
ReloadData();
262262
}
263-
264-
Element.Dispatcher.DispatchIfRequired(() => List?.UpdateLayout());
265263
}
266264

267265
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)

src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/CellRenderer.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class CellRenderer : ElementHandler<Cell, UITableViewCell>, IRegisterable
1818

1919
public static CommandMapper<Cell, CellRenderer> CommandMapper =
2020
new CommandMapper<Cell, CellRenderer>(ElementHandler.ElementCommandMapper);
21-
UITableView? _tableView;
21+
WeakReference<UITableView>? _tableView;
2222

2323
private protected event PropertyChangedEventHandler? CellPropertyChanged;
2424

@@ -37,7 +37,7 @@ protected override UITableViewCell CreatePlatformElement()
3737

3838
public virtual UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
3939
{
40-
_tableView = tv;
40+
_tableView = new(tv);
4141
Performance.Start(out string reference);
4242

4343
var tvc = reusableCell as CellTableViewCell ?? new CellTableViewCell(UITableViewCellStyle.Default, item.GetType().FullName);
@@ -173,15 +173,17 @@ public override void Invoke(string command, object? args)
173173

174174
if (command == "ForceUpdateSizeRequested" &&
175175
VirtualView is BindableObject bindableObject &&
176-
GetRealCell(bindableObject) is UITableViewCell ctv)
176+
GetRealCell(bindableObject) is UITableViewCell ctv &&
177+
_tableView is not null &&
178+
_tableView.TryGetTarget(out var tableView))
177179
{
178-
var index = _tableView?.IndexPathForCell(ctv);
180+
var index = tableView.IndexPathForCell(ctv);
179181
if (index == null && VirtualView is Cell c)
180182
{
181183
index = Controls.Compatibility.Platform.iOS.CellExtensions.GetIndexPath(c);
182184
}
183185
if (index != null)
184-
_tableView?.ReloadRows(new[] { index }, UITableViewRowAnimation.None);
186+
tableView.ReloadRows(new[] { index }, UITableViewRowAnimation.None);
185187
}
186188
}
187189
}

src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs

+18-12
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class NavigationRenderer : UINavigationController, INavigationViewHandler
4848
public static CommandMapper<NavigationPage, NavigationRenderer> CommandMapper = new CommandMapper<NavigationPage, NavigationRenderer>(ViewHandler.ViewCommandMapper);
4949
ViewHandlerDelegator<NavigationPage> _viewHandlerWrapper;
5050
bool _navigating = false;
51-
VisualElement _element;
51+
WeakReference<VisualElement> _element;
52+
WeakReference<Page> _current;
5253
bool _uiRequestedPop; // User tapped the back button or swiped to navigate back
5354
MauiNavigationDelegate NavigationDelegate => Delegate as MauiNavigationDelegate;
5455

@@ -60,14 +61,18 @@ public NavigationRenderer() : base(typeof(MauiControlsNavigationBar), null)
6061
Delegate = new MauiNavigationDelegate(this);
6162
}
6263

63-
Page Current { get; set; }
64+
Page Current
65+
{
66+
get => _current?.GetTargetOrDefault();
67+
set => _current = value is null ? null : new(value);
68+
}
6469

6570
IPageController PageController => Element as IPageController;
6671

6772
NavigationPage NavPage => Element as NavigationPage;
6873
INavigationPageController NavPageController => NavPage;
6974

70-
public VisualElement Element { get => _viewHandlerWrapper.Element ?? _element; }
75+
public VisualElement Element { get => _viewHandlerWrapper.Element ?? _element?.GetTargetOrDefault(); }
7176

7277
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
7378

@@ -85,7 +90,7 @@ public UIView NativeView
8590
public void SetElement(VisualElement element)
8691
{
8792
(this as IElementHandler).SetVirtualView(element);
88-
_element = element;
93+
_element = element is null ? null : new(element);
8994
}
9095

9196
public UIViewController ViewController
@@ -171,7 +176,8 @@ public override void ViewDidDisappear(bool animated)
171176
public override void ViewWillLayoutSubviews()
172177
{
173178
base.ViewWillLayoutSubviews();
174-
if (Current == null)
179+
180+
if (Current is not Page current)
175181
return;
176182

177183
UpdateToolBarVisible();
@@ -180,7 +186,7 @@ public override void ViewWillLayoutSubviews()
180186
var toolbar = _secondaryToolbar;
181187

182188
//save the state of the Current page we are calculating, this will fire before Current is updated
183-
_hasNavigationBar = NavigationPage.GetHasNavigationBar(Current);
189+
_hasNavigationBar = NavigationPage.GetHasNavigationBar(current);
184190

185191
// Use 0 if the NavBar is hidden or will be hidden
186192
var toolbarY = NavigationBarHidden || NavigationBar.Translucent || !_hasNavigationBar ? 0 : navBarFrameBottom;
@@ -475,8 +481,8 @@ void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
475481
}
476482
else if (e.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
477483
{
478-
Current = NavPage?.CurrentPage;
479-
ValidateNavbarExists(Current);
484+
var current = Current = NavPage?.CurrentPage;
485+
ValidateNavbarExists(current);
480486
}
481487
else if (e.PropertyName == IsNavigationBarTranslucentProperty.PropertyName)
482488
{
@@ -806,7 +812,7 @@ void UpdateBarTextColor()
806812
}
807813

808814
// set Tint color (i. e. Back Button arrow and Text)
809-
var iconColor = Current != null ? NavigationPage.GetIconColor(Current) : null;
815+
var iconColor = Current is Page current ? NavigationPage.GetIconColor(current) : null;
810816
if (iconColor == null)
811817
iconColor = barTextColor;
812818

@@ -860,8 +866,8 @@ void UpdateToolBarVisible()
860866

861867
if (currentHidden != _secondaryToolbar.Hidden)
862868
{
863-
if (Current?.Handler != null)
864-
Current.ToPlatform().InvalidateMeasure(Current);
869+
if (Current is Page current && current.Handler is not null)
870+
current.ToPlatform().InvalidateMeasure(current);
865871

866872
if (VisibleViewController is ParentingViewController pvc)
867873
pvc.UpdateFrames();
@@ -1716,7 +1722,7 @@ void IElementHandler.SetMauiContext(IMauiContext mauiContext)
17161722
void IElementHandler.SetVirtualView(Maui.IElement view)
17171723
{
17181724
_viewHandlerWrapper.SetVirtualView(view, ElementChanged, false);
1719-
_element = view as VisualElement;
1725+
_element = view is VisualElement v ? new(v) : null;
17201726

17211727
void ElementChanged(ElementChangedEventArgs<NavigationPage> e)
17221728
{

0 commit comments

Comments
 (0)