From 45a2e2277d0c84b261f7b3e31be5e79be39b0298 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk Date: Thu, 21 Nov 2024 12:40:40 +0200 Subject: [PATCH] Fix NRE --- .../Android/CustomShellBottomNavViewAppearanceTracker.cs | 4 ++-- .../Platforms/Android/CustomShellToolbarAppearanceTracker.cs | 2 +- .../MacCatalyst/CustomShellToolbarAppearanceTracker.cs | 4 ++-- .../Platforms/iOS/CustomShellNavBarAppearanceTracker.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MauiShellCustomization/Platforms/Android/CustomShellBottomNavViewAppearanceTracker.cs b/MauiShellCustomization/Platforms/Android/CustomShellBottomNavViewAppearanceTracker.cs index 966dea62..1b4b3e97 100644 --- a/MauiShellCustomization/Platforms/Android/CustomShellBottomNavViewAppearanceTracker.cs +++ b/MauiShellCustomization/Platforms/Android/CustomShellBottomNavViewAppearanceTracker.cs @@ -14,7 +14,7 @@ internal class CustomShellBottomNavViewAppearanceTracker(IShellContext shellCont public override void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { base.SetAppearance(bottomView, appearance); - if (Shell.GetTabBarIsVisible(shellContext.Shell.CurrentPage)) + if (Shell.GetTabBarIsVisible(shellContext.Shell.CurrentItem)) { var backgroundDrawable = new GradientDrawable(); backgroundDrawable.SetShape(ShapeType.Rectangle); @@ -37,6 +37,6 @@ public override void SetAppearance(BottomNavigationView bottomView, IShellAppear protected override void SetBackgroundColor(BottomNavigationView bottomView, Color color) { base.SetBackgroundColor(bottomView, color); - bottomView.RootView?.SetBackgroundColor(shellContext.Shell.CurrentPage.BackgroundColor.ToPlatform()); + bottomView.RootView?.SetBackgroundColor(shellContext.Shell.CurrentItem.BackgroundColor.ToPlatform()); } } \ No newline at end of file diff --git a/MauiShellCustomization/Platforms/Android/CustomShellToolbarAppearanceTracker.cs b/MauiShellCustomization/Platforms/Android/CustomShellToolbarAppearanceTracker.cs index 7f1db210..1cf5e93c 100644 --- a/MauiShellCustomization/Platforms/Android/CustomShellToolbarAppearanceTracker.cs +++ b/MauiShellCustomization/Platforms/Android/CustomShellToolbarAppearanceTracker.cs @@ -15,7 +15,7 @@ internal class CustomShellToolbarAppearanceTracker(IShellContext shellContext) public override void SetAppearance(Toolbar toolbar, IShellToolbarTracker toolbarTracker, ShellAppearance appearance) { base.SetAppearance(toolbar, toolbarTracker, appearance); - if (Shell.GetNavBarIsVisible(shellContext.Shell.CurrentPage)) + if (Shell.GetNavBarIsVisible(shellContext.Shell.CurrentItem)) { var backgroundDrawable = new GradientDrawable(); backgroundDrawable.SetShape(ShapeType.Rectangle); diff --git a/MauiShellCustomization/Platforms/MacCatalyst/CustomShellToolbarAppearanceTracker.cs b/MauiShellCustomization/Platforms/MacCatalyst/CustomShellToolbarAppearanceTracker.cs index 06eef264..b9d95cf3 100644 --- a/MauiShellCustomization/Platforms/MacCatalyst/CustomShellToolbarAppearanceTracker.cs +++ b/MauiShellCustomization/Platforms/MacCatalyst/CustomShellToolbarAppearanceTracker.cs @@ -22,9 +22,9 @@ public void ResetAppearance(UINavigationController controller) public void SetAppearance(UINavigationController controller, ShellAppearance appearance) { baseTracker.SetAppearance(controller, appearance); - if (controller.View is not null && shellContext.Shell.CurrentPage is not null) + if (controller.View is not null && shellContext.Shell.CurrentItem is not null) { - controller.View.BackgroundColor = shellContext.Shell.CurrentPage.BackgroundColor.ToPlatform(); + controller.View.BackgroundColor = shellContext.Shell.CurrentItem.BackgroundColor.ToPlatform(); } } diff --git a/MauiShellCustomization/Platforms/iOS/CustomShellNavBarAppearanceTracker.cs b/MauiShellCustomization/Platforms/iOS/CustomShellNavBarAppearanceTracker.cs index 4c76bd0b..d95f5fcb 100644 --- a/MauiShellCustomization/Platforms/iOS/CustomShellNavBarAppearanceTracker.cs +++ b/MauiShellCustomization/Platforms/iOS/CustomShellNavBarAppearanceTracker.cs @@ -23,9 +23,9 @@ public void ResetAppearance(UINavigationController controller) public void SetAppearance(UINavigationController controller, ShellAppearance appearance) { baseTracker.SetAppearance(controller, appearance); - if (controller.View is not null && shellContext.Shell.CurrentPage is not null) + if (controller.View is not null && shellContext.Shell.CurrentItem is not null) { - controller.View.BackgroundColor = shellContext.Shell.CurrentPage.BackgroundColor.ToPlatform(); + controller.View.BackgroundColor = shellContext.Shell.CurrentItem.BackgroundColor.ToPlatform(); } }