scriptBoris / NavigationSam

Can intercept action navigation back by user
17 stars 1 forks source link

Navigation Backcolor ? #1

Closed tonyfonager closed 3 years ago

tonyfonager commented 3 years ago

I have now implemented your fine Nuget package for my Xamarin.Forms app.

Normaly my NavigationPage background color is set via a style definition :

<Color x:Key="NavigationBarColor">#6d4585</Color>

<Style TargetType="NavigationPage">
    <Setter Property="BarBackgroundColor" Value="{StaticResource NavigationBarColor}" />
    <Setter Property="BarTextColor" Value="{StaticResource NavigationBarTextColor}" />
</Style>

But when I change to using your NavigationPageSam(), it becomes white ?

Any idea how I can change the color in my app now ?

scriptBoris commented 3 years ago

@tonyfonager let me try to reproduce the problem and find a solution. I'll do it: right now

Edit: Can you send me a more detailed code?

tonyfonager commented 3 years ago

Great, I have looked thru your source to see if I could find something that did it, but without luck.

So it could be something in my code, maybe ... I dont know!

But I have temporarily fix it by overriding your class and setting it implicit like this :

public partial class NavigationPageQuizmo : NavigationPageSam
{
    public NavigationPageQuizmo(Page root) : base(root)
    {
        this.BarBackgroundColor = Color.FromHex("#6d4585");
        this.BarTextColor = Color.White;
    }
}

It fixes it for now, and I can start testing your nice package ;-)

tonyfonager commented 3 years ago

Can you send me a more detailed code?

Its part of a huge / complex game project, so it would be too much of a hassle to separate it out, sorry!

But feel free to ask me anything, and I will provide it - as I wrote initially, the background color of my navigation area was set thru a style inside app.xaml page, but when I added your control that area became white (default) again.

scriptBoris commented 3 years ago

https://github.com/scriptBoris/NavigationSam/tree/issue1%23navigationBackcolor This branch for solve you problem (in process)

tonyfonager commented 3 years ago

Sweet, I also wondered why that constructor with no parameter was missing 👍

You gonna push a new package later ?

And thanks for the quick reply @scriptBoris

scriptBoris commented 3 years ago

I can publish new version on right now, if i solve problem

scriptBoris commented 3 years ago

@tonyfonager solution: try to specify the type explicitly image

code:

<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:navSam="clr-namespace:NavigationSam;assembly=NavigationSam"
             x:Class="Sample.App">
    <Application.Resources>
        <Color x:Key="NavigationBarColor">#6d4585</Color>
        <Color x:Key="NavigationBarTextColor">#FFF</Color>

        <Style TargetType="{Type navSam:NavigationPageSam}">
            <Setter Property="BarBackgroundColor" Value="{StaticResource NavigationBarColor}" />
            <Setter Property="BarTextColor" Value="{StaticResource NavigationBarTextColor}" />
        </Style>
    </Application.Resources>
</Application>
tonyfonager commented 3 years ago

When I try adding that, I do not get any classes from intellisense when typing "navSam:"

image

I tried adding it manually, could compile but navigation area is still white.

Please note, I have not updated Nuget or anything!

scriptBoris commented 3 years ago

@tonyfonager the problem is most likely due to the fact that NavigationPageSam does not have a open constructor. I will fix this in the new version of the package 1.0.2

BUT, you can now solve this problem. Just write {Type navSam:NavigationPageSam} and rebuild project

It worked

tonyfonager commented 3 years ago

I tried adding it anyway, with no luck.

But let me was and test the new Nuget 1.0.2

scriptBoris commented 3 years ago

I tried adding it anyway, with no luck.

But let me was and test the new Nuget 1.0.2

Nuget 1.0.2 is published

image

tonyfonager commented 3 years ago

Thanks alot, I have upgraded to 1.0.2 and can confirm it works now 🥇

scriptBoris commented 3 years ago

@tonyfonager cool!

P.S. Can you star me github project?

tonyfonager commented 3 years ago

Starred 👍