Skip to content

Commit

Permalink
Merge pull request unoplatform#14674 from unoplatform/dev/sb/commandb…
Browse files Browse the repository at this point in the history
…ar-native

fix: avoid calling Native getter in NativeCommandBarPresenter
  • Loading branch information
jeromelaban authored Dec 4, 2023
2 parents c56e433 + e9c011d commit 8b3b3e9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/Uno.UI/Controls/CommandBar/NativeCommandBarPresenter.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,28 @@ private protected override void OnLoaded()
_commandBar = new WeakReference<CommandBar?>(commandBar);
}

if (commandBar?.TryGetRenderer<CommandBar, CommandBarRenderer>() is { } commandBarRenderer)
if ((commandBar?.TryGetNative<CommandBar, CommandBarRenderer, UINavigationBar>(out var nativeBar) ?? false)
&& nativeBar is { })
{
if (commandBarRenderer.Native is { } nativeBar)
{
LayoutNativeBar(nativeBar);
}
LayoutNativeBar(nativeBar);
}
else if (commandBar is { } && FeatureConfiguration.CommandBar.AllowNativePresenterContent)
{
commandBarRenderer = new CommandBarRenderer(commandBar);
var commandBarRenderer = new CommandBarRenderer(commandBar);
commandBar.SetRenderer(commandBarRenderer);


var commandBarItemRenderer = new CommandBarNavigationItemRenderer(commandBar);
commandBar.SetRenderer(commandBarItemRenderer);

var navigationItem = new UINavigationItem();
var nativeBar = new UINavigationBar();
nativeBar.PushNavigationItem(navigationItem, false);
var navBar = new UINavigationBar();
navBar.PushNavigationItem(navigationItem, false);

commandBarItemRenderer.Native = navigationItem;
commandBarRenderer.Native = nativeBar;
commandBarRenderer.Native = navBar;

LayoutNativeBar(nativeBar);
LayoutNativeBar(navBar);
}
}

Expand Down

0 comments on commit 8b3b3e9

Please sign in to comment.