Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using AndroidX.Core.View;
using AndroidX.Fragment.App;
using Google.Android.Material.AppBar;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Platform;
using AndroidAnimation = Android.Views.Animations.Animation;
using AnimationSet = Android.Views.Animations.AnimationSet;
Expand Down Expand Up @@ -136,6 +138,11 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup container,

_root = inflater.Inflate(Controls.Resource.Layout.shellcontent, null).JavaCast<CoordinatorLayout>();

// Set theme-aware background color immediately to prevent white flash during transitions.
// The CoordinatorLayout is inflated without a background color, which can cause
// white flash during fragment transitions when using dark theme.
_root.SetBackgroundColor(ShellRenderer.DefaultBottomNavigationViewBackgroundColor.ToPlatform());

MauiWindowInsetListener.SetupViewWithLocalListener(_root);

var shellContentMauiContext = _shellContext.Shell.Handler.MauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Google.Android.Material.Navigation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Graphics;
using AColor = Android.Graphics.Color;
using AView = Android.Views.View;
Expand Down Expand Up @@ -76,6 +77,14 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup container,
_navigationArea = PlatformInterop.CreateNavigationBarArea(context, _outerLayout);
_bottomView = PlatformInterop.CreateNavigationBar(context, Resource.Attribute.bottomNavigationViewStyle, _outerLayout, this);

// Set theme-aware background colors immediately to prevent white flash during transitions.
// The BottomNavigationView is created with Color.WHITE in PlatformInterop.java, but the
// correct theme-aware color should be applied immediately before any UI is rendered.
// We also set the navigation area background to prevent white flash during fragment transitions.
var themeAwareBackgroundColor = ShellRenderer.DefaultBottomNavigationViewBackgroundColor.ToPlatform();
_bottomView.SetBackgroundColor(themeAwareBackgroundColor);
_navigationArea.SetBackgroundColor(themeAwareBackgroundColor);

if (ShellItem is null)
throw new InvalidOperationException("Active Shell Item not set. Have you added any Shell Items to your Shell?");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Google.Android.Material.AppBar;
using Google.Android.Material.Tabs;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Platform;
using AToolbar = AndroidX.AppCompat.Widget.Toolbar;
using AView = Android.Views.View;
Expand Down Expand Up @@ -102,6 +104,12 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup container,

var context = Context;
var root = PlatformInterop.CreateShellCoordinatorLayout(context);

// Set theme-aware background color immediately to prevent white flash during transitions.
// The CoordinatorLayout is created without a background, which can cause white flash
// during fragment transitions when using dark theme.
root.SetBackgroundColor(ShellRenderer.DefaultBottomNavigationViewBackgroundColor.ToPlatform());

var appbar = PlatformInterop.CreateShellAppBar(context, Resource.Attribute.appBarLayoutStyle, root);

MauiWindowInsetListener.SetupViewWithLocalListener(root);
Expand Down