Пример #1
0
        private void InitToolbar()
        {
            try
            {
                Toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
                if (Toolbar != null)
                {
                    Toolbar.Title = " ";
                    Toolbar.SetTitleTextColor(Color.White);
                    SetSupportActionBar(Toolbar);
                    SupportActionBar.SetDisplayShowCustomEnabled(true);
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    SupportActionBar.SetHomeButtonEnabled(true);
                    SupportActionBar.SetDisplayShowHomeEnabled(true);
                }

                SearchView = FindViewById <AutoCompleteTextView>(Resource.Id.searchBox);
                SearchView.SetOnEditorActionListener(this);
                //SearchView.ClearFocus();

                //Change text colors
                SearchView.SetHintTextColor(Color.ParseColor("#efefef"));
                SearchView.SetTextColor(Color.White);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #2
0
 private void InitToolbar()
 {
     try
     {
         Toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
         if (Toolbar != null)
         {
             Toolbar.SetTitleTextColor(Color.White);
             SetSupportActionBar(Toolbar);
             SupportActionBar.SetDisplayShowCustomEnabled(true);
             SupportActionBar.SetDisplayHomeAsUpEnabled(true);
             SupportActionBar.SetHomeButtonEnabled(true);
             SupportActionBar.SetDisplayShowHomeEnabled(true);
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 private void InitToolbar()
 {
     try
     {
         TopToolBar = FindViewById <Toolbar>(Resource.Id.toolbar);
         if (TopToolBar != null)
         {
             TopToolBar.Title = GetText(Resource.String.Lbl_SharePost);
             TopToolBar.SetTitleTextColor(Color.ParseColor(AppSettings.MainColor));
             SetSupportActionBar(TopToolBar);
             SupportActionBar.SetDisplayShowCustomEnabled(true);
             SupportActionBar.SetDisplayHomeAsUpEnabled(true);
             SupportActionBar.SetHomeButtonEnabled(true);
             SupportActionBar.SetDisplayShowHomeEnabled(true);
             SupportActionBar.SetHomeAsUpIndicator(AppCompatResources.GetDrawable(this, AppSettings.FlowDirectionRightToLeft ? Resource.Drawable.ic_action_right_arrow_color : Resource.Drawable.ic_action_left_arrow_color));
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Пример #4
0
        void UpdateToolbar()
        {
            if (_disposed)
            {
                return;
            }

            Context  context             = Context;
            AToolbar bar                 = _toolbar;
            ActionBarDrawerToggle toggle = _drawerToggle;

            if (bar == null)
            {
                return;
            }

            bool isNavigated = NavigationPageController.StackDepth > 1;

            bar.NavigationIcon = null;
            Page currentPage = Element.CurrentPage;

            if (isNavigated)
            {
                if (NavigationPage.GetHasBackButton(currentPage))
                {
                    if (toggle != null)
                    {
                        toggle.DrawerIndicatorEnabled = false;
                        toggle.SyncState();
                    }

                    var icon = new DrawerArrowDrawable(context.GetThemedContext());
                    icon.Progress      = 1;
                    bar.NavigationIcon = icon;

                    var prevPage        = Element.Peek(1);
                    var backButtonTitle = NavigationPage.GetBackButtonTitle(prevPage);
                    _defaultNavigationContentDescription = backButtonTitle != null
                                                ? bar.SetNavigationContentDescription(prevPage, backButtonTitle)
                                                : bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription);
                }
                else if (toggle != null && _flyoutPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _flyoutPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }
            else
            {
                if (toggle != null && _flyoutPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _flyoutPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }

            Color tintColor = Element.BarBackgroundColor;

            if (tintColor == null)
            {
                bar.BackgroundTintMode = null;
            }
            else
            {
                bar.BackgroundTintMode = PorterDuff.Mode.Src;
                bar.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid());
            }

            Brush barBackground = Element.BarBackground;

            bar.UpdateBackground(barBackground);

            Color textColor = Element.BarTextColor;

            if (textColor != null)
            {
                bar.SetTitleTextColor(textColor.ToAndroid().ToArgb());
            }

            Color navIconColor = NavigationPage.GetIconColor(Current);

            if (navIconColor != null && bar.NavigationIcon != null)
            {
                bar.NavigationIcon.SetColorFilter(navIconColor, FilterMode.SrcAtop);
            }

            bar.Title = currentPage?.Title ?? string.Empty;

            if (_toolbar.NavigationIcon != null && textColor != null)
            {
                var icon = _toolbar.NavigationIcon as DrawerArrowDrawable;
                if (icon != null)
                {
                    icon.Color = textColor.ToAndroid().ToArgb();
                }
            }

            UpdateTitleIcon();

            UpdateTitleView();
        }
        void UpdateToolbar()
        {
            if (_disposed)
            {
                return;
            }

            Context  context             = Context;
            AToolbar bar                 = _toolbar;
            ActionBarDrawerToggle toggle = _drawerToggle;

            if (bar == null)
            {
                return;
            }

            bool isNavigated = NavigationPageController.StackDepth > 1;

            bar.NavigationIcon = null;
            Page currentPage = Element.CurrentPage;

            if (isNavigated)
            {
                if (NavigationPage.GetHasBackButton(currentPage) && !Context.IsDesignerContext())
                {
                    if (toggle != null)
                    {
                        toggle.DrawerIndicatorEnabled = false;
                        toggle.SyncState();
                    }

                    var activity = (AppCompatActivity)context.GetActivity();
                    var icon     = new DrawerArrowDrawable(activity.SupportActionBar.ThemedContext);
                    icon.Progress      = 1;
                    bar.NavigationIcon = icon;

                    var prevPage = Element.Peek(1);
                    _defaultNavigationContentDescription = bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription);
                }
                else if (toggle != null && _masterDetailPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _masterDetailPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }
            else
            {
                if (toggle != null && _masterDetailPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _masterDetailPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }

            Color tintColor = Element.BarBackgroundColor;

            if (Forms.IsLollipopOrNewer)
            {
                if (tintColor.IsDefault)
                {
                    bar.BackgroundTintMode = null;
                }
                else
                {
                    bar.BackgroundTintMode = PorterDuff.Mode.Src;
                    bar.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid());
                }
            }
            else
            {
                if (tintColor.IsDefault && _backgroundDrawable != null)
                {
                    bar.SetBackground(_backgroundDrawable);
                }
                else if (!tintColor.IsDefault)
                {
                    if (_backgroundDrawable == null)
                    {
                        _backgroundDrawable = bar.Background;
                    }
                    bar.SetBackgroundColor(tintColor.ToAndroid());
                }
            }

            Color textColor = Element.BarTextColor;

            if (!textColor.IsDefault)
            {
                bar.SetTitleTextColor(textColor.ToAndroid().ToArgb());
            }

            Color navIconColor = NavigationPage.GetIconColor(Current);

            if (!navIconColor.IsDefault && bar.NavigationIcon != null)
            {
                DrawableExtensions.SetColorFilter(bar.NavigationIcon, navIconColor, FilterMode.SrcAtop);
            }

            bar.Title = currentPage?.Title ?? string.Empty;

            if (_toolbar.NavigationIcon != null && !textColor.IsDefault)
            {
                var icon = _toolbar.NavigationIcon as DrawerArrowDrawable;
                if (icon != null)
                {
                    icon.Color = textColor.ToAndroid().ToArgb();
                }
            }

            UpdateTitleIcon();

            UpdateTitleView();
        }