Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No badge displayed both on Android and iOS #80

Open
Giulio64 opened this issue Jan 10, 2020 · 0 comments
Open

No badge displayed both on Android and iOS #80

Giulio64 opened this issue Jan 10, 2020 · 0 comments

Comments

@Giulio64
Copy link

I need to test this scenario:
I have a reference to a tab bar menu in my App.xaml.cs so I can display badges from all over the app calling by calling a method, anyway I can't display any badges no matter what I do, both on iOS and Android, here is my tabbed page :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hangover.Pagine;
using Plugin.Badge.Abstractions;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using Xamarin.Forms.Xaml;

namespace Hangover
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Menu : Xamarin.Forms.TabbedPage
{
private List pagine = new List();

    public Menu()
    {
        InitializeComponent();

        On<Xamarin.Forms.PlatformConfiguration.Android>().SetToolbarPlacement(ToolbarPlacement.Bottom);
        this.On<Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(false);

        this.pagine = new List<NavigationPage>() {

            new NavigationPage(new cp_PaginaUno()){
                Icon = "Eventi.png",
                Title = "Uno",
                BarBackgroundColor = Color.White,
                BarTextColor = Color.FromHex("#FF7F00")
            },
            new NavigationPage(new cp_PaginaDue()){
                Icon = "Search.png",
                Title = "Due",
                BarBackgroundColor = Color.White,
                BarTextColor = Color.FromHex("#FF7F00")
            }

        };

        foreach (NavigationPage pagina in pagine)
        {
            this.Children.Add(pagina);
        }

    }

    /// <summary>
    /// Imposta il numero di una pagina contenuta nel menu
    /// </summary>
    /// <returns><c>true</c>, if page badge value was set, <c>false</c> otherwise.</returns>
    public bool setBadgePagina(String pageName, Object value)
    {

        foreach (NavigationPage pagina in pagine)
        {
            if (pagina.CurrentPage.GetType().Name.Equals(pageName))
            {
                TabBadge.SetBadgeText(pagina, "1+");
                TabBadge.SetBadgeColor(pagina, Color.FromHex("#A0FFA500"));
                TabBadge.SetBadgeText(pagina.CurrentPage, "1+");
                TabBadge.SetBadgeColor(pagina.CurrentPage, Color.FromHex("#A0FFA500"));
            }

        }

        foreach (Page page in this.Children)
        {
            var x = page as NavigationPage;

            if (x.CurrentPage.GetType().Name.Equals(pageName))
            {
                TabBadge.SetBadgeText(x, "1+");
                TabBadge.SetBadgeColor(x, Color.FromHex("#A0FFA500"));
                TabBadge.SetBadgeText(x.CurrentPage, "1+");
                TabBadge.SetBadgeColor(x.CurrentPage, Color.FromHex("#A0FFA500"));

            }

        }


        return false;

    }
}

}

To try to display the badge I call from one page the setBadgePagina method:

public cp_PaginaUno()
{
InitializeComponent();
}

    public void gestisciGenerazioneNotifica(Object sender, EventArgs e)
    {
        TabBadge.SetBadgeText(this, "1+");
        TabBadge.SetBadgeColor(this, Color.FromHex("#A0FFA500"));
    }

nothing displayed.

Xamarin.Forms 4.4.0(last)
Plugin.Badge 2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant