pocheshire / BottomNavigationBar

Bottom Navigation Bar for Xamarin
214 stars 70 forks source link

Translucent NavigationBar is never created since it's method will always return false. #22

Closed tuvalente closed 7 years ago

tuvalente commented 7 years ago

Note: I am using the NuGet Package, but i made the same test at this current code and results the same. Problem: method NavBarMagic(Activity activity, BottomBar bottomBar) always returns as false because the property bottomBar.DrawBehindNavBar which is declared as false, is never set and can't be set as true making the if clause inside the method always returning, making it impossible to draw behind it. In-depth Explanation: In the following if clause, taken from the NuGet code:

if (!bottomBar.DrawBehindNavBar || navBarHeight == 0 ||
                Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich &&
                ViewConfiguration.Get((Context)activity).HasPermanentMenuKey ||
                Build.VERSION.SdkInt < BuildVersionCodes.JellyBeanMr1 &&
                (softMenuIdentifier <= 0 || !res.GetBoolean(softMenuIdentifier)))
            {
                return;
            }

Or, in the following if clause, taken from this current branch:

if (!bottomBar.DrawBehindNavBar
                || navBarHeight == 0)
            {
                return;
            }

The first property bottomBar.DrawBehindNavBar will always return as false since it is declared as false and there is no way to set it as true because it is declared as protected. So we end up having this logical case:

if (true || false || true && true || false && (false || false))
{
                return;
}

In which will always results in true, doesn't matter the other cases since true || will always return true. Solution: Changing access of the property from: protected bool DrawBehindNavBar { get; set; } to: public bool DrawBehindNavBar { get; set; }

pocheshire commented 7 years ago

Fixed