Beispiel #1
0
        public static void MapBarBackground(NavigationPageHandler handler, NavigationPage view)
        {
            var NavPage            = handler.VirtualViewWithValidation();
            var barBackgroundBrush = NavPage.BarBackground;

            if (Brush.IsNullOrEmpty(barBackgroundBrush) &&
                NavPage.BarBackgroundColor != null)
            {
                barBackgroundBrush = new SolidColorBrush(NavPage.BarBackgroundColor);
            }

            if (barBackgroundBrush == null)
            {
                return;
            }

            var navController = handler._controlsNavigationController;
            var NavigationBar = navController.NavigationBar;

            if (NativeVersion.IsAtLeast(13))
            {
                var navigationBarAppearance = NavigationBar.StandardAppearance;

                navigationBarAppearance.ConfigureWithOpaqueBackground();

                //if (barBackgroundColor == null)
                //{
                //	navigationBarAppearance.BackgroundColor = ColorExtensions.BackgroundColor;

                //	var parentingViewController = GetParentingViewController();
                //	parentingViewController?.SetupDefaultNavigationBarAppearance();
                //}
                //else
                //	navigationBarAppearance.BackgroundColor = barBackgroundColor.ToUIColor();

                var backgroundImage = NavigationBar.GetBackgroundImage(barBackgroundBrush);
                navigationBarAppearance.BackgroundImage = backgroundImage;

                NavigationBar.CompactAppearance    = navigationBarAppearance;
                NavigationBar.StandardAppearance   = navigationBarAppearance;
                NavigationBar.ScrollEdgeAppearance = navigationBarAppearance;
            }
            else
            {
                var backgroundImage = NavigationBar.GetBackgroundImage(barBackgroundBrush);
                NavigationBar.SetBackgroundImage(backgroundImage, UIBarMetrics.Default);
            }
        }
 public static void MapTitleView(NavigationPageHandler handler, NavigationPage view)
 {
 }
 public static void MapBarBackground(NavigationPageHandler handler, NavigationPage view)
 {
 }
 public static void MapBarTextColor(NavigationPageHandler handler, NavigationPage view)
 {
 }
 public static void MapPadding(NavigationPageHandler handler, NavigationPage view)
 {
 }
 private static void UpdateToolBar(NavigationPageHandler arg1, NavigationPage arg2)
 {
     arg1._controlsNavigationManager.ToolbarPropertyChanged();
 }
 public static void MapToolbarDynamicOverflowEnabled(NavigationPageHandler handler, NavigationPage view) => handler.UpdateToolbarDynamicOverflowEnabled();
 public static void MapToolbarPlacement(NavigationPageHandler handler, NavigationPage view) => handler.UpdateToolbarPlacement();
 public static void MapTitleView(NavigationPageHandler handler, NavigationPage view) => handler.UpdateTitleView();
 public static void MapBarBackground(NavigationPageHandler handler, NavigationPage view) => handler.UpdateNavigationBarBackground();
 public static void MapBarTextColor(NavigationPageHandler handler, NavigationPage view) => handler.UpdateTitleColor();
 public static void MapPadding(NavigationPageHandler handler, NavigationPage view) =>
 handler.UpdatePadding();
Beispiel #13
0
        public static void MapBarTextColor(NavigationPageHandler handler, NavigationPage view)
        {
            var NavPage = handler.VirtualViewWithValidation();

            var navController = handler._controlsNavigationController;
            var NavigationBar = navController.NavigationBar;

            var barTextColor = NavPage.BarTextColor;

            if (NavigationBar == null)
            {
                return;
            }

            // Determine new title text attributes via global static data
            var globalTitleTextAttributes = UINavigationBar.Appearance.TitleTextAttributes;
            var titleTextAttributes       = new UIStringAttributes
            {
                ForegroundColor = barTextColor == null ? globalTitleTextAttributes?.ForegroundColor : barTextColor.ToNative(),
                Font            = globalTitleTextAttributes?.Font
            };

            // Determine new large title text attributes via global static data
            var largeTitleTextAttributes = titleTextAttributes;

            if (NativeVersion.IsAtLeast(11))
            {
                var globalLargeTitleTextAttributes = UINavigationBar.Appearance.LargeTitleTextAttributes;

                largeTitleTextAttributes = new UIStringAttributes
                {
                    ForegroundColor = barTextColor == null ? globalLargeTitleTextAttributes?.ForegroundColor : barTextColor.ToNative(),
                    Font            = globalLargeTitleTextAttributes?.Font
                };
            }

            if (NativeVersion.IsAtLeast(13))
            {
                if (NavigationBar.CompactAppearance != null)
                {
                    NavigationBar.CompactAppearance.TitleTextAttributes      = titleTextAttributes;
                    NavigationBar.CompactAppearance.LargeTitleTextAttributes = largeTitleTextAttributes;
                }

                NavigationBar.StandardAppearance.TitleTextAttributes      = titleTextAttributes;
                NavigationBar.StandardAppearance.LargeTitleTextAttributes = largeTitleTextAttributes;

                if (NavigationBar.ScrollEdgeAppearance != null)
                {
                    NavigationBar.ScrollEdgeAppearance.TitleTextAttributes      = titleTextAttributes;
                    NavigationBar.ScrollEdgeAppearance.LargeTitleTextAttributes = largeTitleTextAttributes;
                }
            }
            else
            {
                NavigationBar.TitleTextAttributes = titleTextAttributes;

                if (NativeVersion.IsAtLeast(11))
                {
                    NavigationBar.LargeTitleTextAttributes = largeTitleTextAttributes;
                }
            }

            //// set Tint color (i. e. Back Button arrow and Text)
            //var iconColor = Current != null ? NavigationPage.GetIconColor(Current) : null;
            //if (iconColor == null)
            //	iconColor = barTextColor;

            //NavigationBar.TintColor = iconColor == null || NavPage.OnThisPlatform().GetStatusBarTextColorMode() == StatusBarTextColorMode.DoNotAdjust
            //	? UINavigationBar.Appearance.TintColor
            //	: iconColor.ToUIColor();
        }