-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: navBar initialization-Android & iOS (#1275)
Co-authored-by: Steve Bilogan <[email protected]>
- Loading branch information
1 parent
1fd7607
commit 1c8aaf9
Showing
3 changed files
with
75 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/Uno.Toolkit.UI/Controls/NavigationBar/NativeNavigationBarPresenter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#if __ANDROID__ || __IOS__ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Uno.Disposables; | ||
|
||
#if IS_WINUI | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
#else | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
#endif | ||
|
||
namespace Uno.Toolkit.UI | ||
{ | ||
partial class NativeNavigationBarPresenter : ContentPresenter, INavigationBarPresenter | ||
{ | ||
private WeakReference<NavigationBar?>? _weakNavBar; | ||
|
||
public void SetOwner(NavigationBar? navigationBar) | ||
{ | ||
if (GetNavBar() == navigationBar) | ||
{ | ||
return; | ||
} | ||
_weakNavBar = new WeakReference<NavigationBar?>(navigationBar); | ||
|
||
OnOwnerChanged(); | ||
} | ||
|
||
private NavigationBar? GetNavBar() | ||
{ | ||
if (_weakNavBar == null) | ||
{ | ||
return null; | ||
} | ||
|
||
NavigationBar? targetNavBar = null; | ||
if (_weakNavBar.TryGetTarget(out targetNavBar)) | ||
{ | ||
return targetNavBar; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
partial void OnOwnerChanged(); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters