Ejemplo n.º 1
0
        internal static void UpdateTitle()
        {
            if (Instance?.ActionBar == null)
            {
                return;
            }

            FragmentHistoryStack.SetHomeUp(Pane.Popover);

            var style = Stack.CurrentLayer == null ? iApp.Instance.Style : Stack.CurrentLayer.LayerStyle;

            ((PopoverActivity)Instance).UpdateHeader(style.HeaderColor);

            var popoverView = Stack.CurrentView as IView;
            var title       = popoverView == null ? iApp.Instance.Title : popoverView.Title;

            Instance.ActionBar.Title = title;
        }
Ejemplo n.º 2
0
        internal static void RefreshTitles()
        {
            var actionBar = MainActivity.ActionBar;

            if (actionBar == null)
            {
                return;
            }

            Device.Thread.ExecuteOnMainThread(() => { FragmentHistoryStack.SetHomeUp(Pane.Master); });
            var master     = PaneManager.Instance.FromNavContext(Pane.Master, 0);
            var detail     = PaneManager.Instance.FromNavContext(Pane.Detail, 0);
            var masterView = master?.CurrentView as IView;
            var detailView = detail?.CurrentView as IView;

            var title    = masterView == null ? iApp.Instance?.Title : masterView.Title;
            var subtitle = detailView?.Title;

            if (string.IsNullOrWhiteSpace(subtitle))
            {
                subtitle = null;
            }

            actionBar.NavigationMode = ActionBarNavigationMode.Standard;

            var view = detail ?? master;

            Device.Thread.ExecuteOnMainThread(() =>
            {
                var c = (view?.CurrentView as IView)?.TitleColor;
                if (!c.HasValue || c.Value.IsDefaultColor)
                {
                    actionBar.Title    = title;
                    actionBar.Subtitle = subtitle;
                }
                else
                {
                    if (title == null)
                    {
                        actionBar.TitleFormatted = null;
                    }
                    else
                    {
                        ISpannable text = new SpannableString(title);
                        text.SetSpan(new ForegroundColorSpan(c.Value.ToColor()), 0, text.Length(), SpanTypes.InclusiveInclusive);
                        actionBar.TitleFormatted = text;
                    }

                    if (subtitle == null)
                    {
                        actionBar.SubtitleFormatted = null;
                    }
                    else
                    {
                        ISpannable text = new SpannableString(subtitle);
                        text.SetSpan(new ForegroundColorSpan(c.Value.ToColor()), 0, text.Length(), SpanTypes.InclusiveInclusive);
                        actionBar.SubtitleFormatted = text;
                    }
                }
            });

            UI.Color headerColor;

            if (view?.CurrentLayer != null)
            {
                headerColor = view.CurrentLayer.LayerStyle.HeaderColor;
            }
            else if (view?.CurrentView is IView)
            {
                headerColor = ((IView)view.CurrentView).HeaderColor;
            }
            else if (iApp.Instance != null)
            {
                headerColor = iApp.Instance.Style.HeaderColor;
            }
            else
            {
                return;
            }

            var baseActivity = MainActivity as BaseActivity;

            if (baseActivity != null)
            {
                baseActivity.UpdateHeader(headerColor);
            }
            else
            {
                actionBar.SetBackgroundDrawable(headerColor.ToColorDrawable());
            }
        }