UXDivers / Gorilla-Player-Support

This is the public Gorilla Player support website
http://gorillaplayer.com
115 stars 17 forks source link

Doesn't support inheritence #313

Open tlhintoq opened 5 years ago

tlhintoq commented 5 years ago

Our views and pages inherit from base classes in order to provide some basic features throughout in a uniform way - like what inheritance is for.

However Gorilla can't deal with those <controls:ViewBase> and similar tags. So can't make a PgHeader class... etc. LiveReload does handle these fine.

image

LeoHere commented 5 years ago

@tlhintoq you need to use Gorilla SDK to preview this. Please follow the instructions listed there and let me know if you have any issue.

vincentcastagna commented 5 years ago

@LeoHere

You are right. If referencing the assembly in the SDK then its working.

Prob for me is that I'm using prism. I've got a parent class for pages in a UserInterfaceModule. How can I register such assembly in my TargetAndroid project in the MainActivity.cs as it is not aware of the module ?

LeoHere commented 5 years ago

@Umar3x did you tried using the new AutoConfig feature included in 1.5 described here? Before trying it be sure to remove any reference to the SDK, if not probably you will get some errors.

What version of Gorilla SDK are you using?

vincentcastagna commented 5 years ago

Hello @LeoHere ,

Did not see this new release. Amazing, you're doing a great job !

I'll give it a try now, will do a feedback in few mins/hours.

vincentcastagna commented 5 years ago

@LeoHere

Great install OK. But I've got an error. Gorilla tells me it cannot find StaticResource MyStaticResource. I'm using a file for my resource dictionary.

<?xml version="1.0" encoding="utf-8" ?>
<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Unity;assembly=Prism.Unity.Forms"
             xmlns:resourceDictionary="clr-namespace:CoreMp"
             x:Class="CoreMp.App">
    <Application.Resources>
        <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <resourceDictionary:AppResourceDictionary />
        </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</prism:PrismApplication>
LeoHere commented 5 years ago

@Umar3x using a ResourceDictionary should not be an issue. If you can give me a short sample where I can reproduce the issue it would be very useful. i.e. the content of the AppResourceDictionary, content of the page

vincentcastagna commented 5 years ago

@LeoHere thanks for fast answer,
Here is the ResourceDictionary :

<?xml version="1.0" encoding="UTF-8"?>
<ResourceDictionary 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
    xmlns:sfInputLayout="clr-namespace:Syncfusion.XForms.TextInputLayout;assembly=Syncfusion.Core.XForms"
    xmlns:syncfusionComponents="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
    x:Class="CoreMp.AppResourceDictionary">

    <!-- According to modules consumption of main app dictionary, all resources dictionaries
            should be implemented with this pattern and naming convention -->

    <!--- Main app colors -->
    <Color x:Key="PrimaryColorOne">#1A2634</Color>
    <Color x:Key="PrimaryColorTwo">#203E5F</Color>
    <Color x:Key="PrimaryColorThree">#FFCC00</Color>
    <Color x:Key="PrimaryColorFour">#FEE5B1</Color>

    <!--- External assemblies/packages colors -->
    <Color x:Key="FacebookColor">#3b5998</Color>

    <!--                           -->
    <!-- External assemblies style -->
    <!--                           -->

    <!-- SYNCFUSION -->
    <Style TargetType="sfInputLayout:SfTextInputLayout">
        <Setter Property="UnfocusedColor" Value="White"></Setter>
        <Setter Property="FocusedColor" Value="{StaticResource PrimaryColorThree}"></Setter>
    </Style>

    <!-- Button styles -->
    <Style x:Key="ButtonPrimaryStyle" TargetType="Button">
        <Setter Property="BackgroundColor" Value="{StaticResource PrimaryColorTwo}" />
        <Setter Property="TextColor" Value="White" />
    </Style>
    <Style x:Key="FacebookButtonStyle" TargetType="Button">
        <Setter Property="Image" Value="fbicon" />
        <Setter Property="BackgroundColor" Value="{StaticResource FacebookColor}" />
        <Setter Property="TextColor" Value="White" />
    </Style>
    <Style x:Key="GoogleButtonStyle" TargetType="Button">
        <Setter Property="BackgroundColor" Value="White" />
        <Setter Property="Image" Value="googleicon" />
        <Setter Property="TextColor" Value="Black" />
        <Setter Property="FontAttributes" Value="Bold" />
    </Style>
    <Style ApplyToDerivedTypes="True" TargetType="Button">
        <Setter Property="android:Button.UseDefaultPadding" Value="True"></Setter>
        <Setter Property="android:Button.UseDefaultShadow" Value="True"></Setter>
    </Style>

    <Style x:Key="numberOfForecastsMapButton" TargetType="Button">
        <Setter Property="BackgroundColor" Value="{StaticResource PrimaryColorOne}"></Setter>
        <Setter Property="BorderRadius" Value="50"></Setter>
        <Setter Property="WidthRequest" Value="100"></Setter>
        <Setter Property="HeightRequest" Value="100"></Setter>
        <Setter Property="TextColor" Value="White"></Setter>
        <Setter Property="FontSize" Value="Large"></Setter>
    </Style>

    <Style  TargetType="Entry">
        <Setter Property="TextColor" Value="White"></Setter>
        <Setter Property="PlaceholderColor" Value="White"></Setter>
    </Style>

    <!--                           -->
    <!---      Pages styles        -->
    <!--                           -->

    <!-- NavigationPage -->
    <Style ApplyToDerivedTypes="true" TargetType="NavigationPage">
        <Setter Property="BarBackgroundColor" Value="{StaticResource PrimaryColorOne}"/>
        <Setter Property="BarTextColor" Value="White"/>
    </Style>

    <!-- TabbedPage -->
    <Style ApplyToDerivedTypes="True" TargetType="TabbedPage">
        <Setter Property="android:TabbedPage.ToolbarPlacement" Value ="Bottom"></Setter>
        <Setter Property="android:TabbedPage.BarSelectedItemColor" Value="{StaticResource PrimaryColorThree}"></Setter>
        <Setter Property="android:TabbedPage.BarItemColor" Value="{StaticResource PrimaryColorFour}"></Setter>
        <Setter Property="BarBackgroundColor" Value="{StaticResource PrimaryColorOne}"></Setter>
        <Setter Property="BarTextColor" Value="White"></Setter>
    </Style>

        <!-- Control template -->
    <ControlTemplate x:Key="MainAppTemplate">
        <ScrollView>
        <Grid>
            <Image Opacity="0.5"
                           Source="main_background_image"
                           Aspect="AspectFill" />
            <ContentPresenter></ContentPresenter>
        </Grid>
        </ScrollView>
    </ControlTemplate>

    <!-- DataTemplates -->
    <DataTemplate x:Key="numberOfForecastsDataTemplate">
        <Grid>
            <Button Text="7" Style="{StaticResource numberOfForecastsMapButton}"/>
        </Grid>
    </DataTemplate>

</ResourceDictionary>

A page for which the error I told you is raised :

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
             x:Class="CoreMp.Core.Views.Page"
             Title="Actualités"
             BackgroundColor="{StaticResource PrimaryColorOne}"
             ControlTemplate="{StaticResource MainAppTemplate}">

</ContentPage>

Versions : Xamarin Forms : 3.2.0.871581 Prism : 7.1.0.431 Prism Unity forms : 7.1.0.431 Visual Studio : 15.8.7

ChasakisD commented 5 years ago

Any updates on this one? I also have the same issue with MergedDictionaries.

vincentcastagna commented 5 years ago

@LeoHere Have you got any news ? Still got the issue. I'm reverting for now ...

LeoHere commented 5 years ago

@Umar3x I was able to reproduce the issue. Need to dig a bit more. I will keep you posted.

LeoHere commented 5 years ago

@Umar3x it is weird, on Friday I though I was able to reproduce the issue. But today I testing again to start digging and I'm not able to reproduce it any more :(.

Can you consistently reproduce the issue?

The only thing I can recall I did since Friday was restart Gorilla. Did you try restarting Gorilla desktop app?

NickCullen commented 5 years ago

If I can be of any help, I am seeing the same issue - I came across Gorilla player via the blog post you wrote and linked and is freshly installed as per the guide.

In my app.xaml I have a static resource <x:String x:Key="ShareIcon">&#xf1e0;</x:String>

In my main page (which inherits from a custom xaml based content page) I get the "cannot find static resource 'ShareIcon'" error.

Where my issue differs slightly is that the static resource being referenced is actually used in a DataTemplate which is used by a ListView in my MainPage. The error for not being able to find the static resource is misleading for me as it tells me the static resource "ShareIcon" cannot be found on line 40 of the MainPage file, when in actual fact it is line 40 for the DataTemplate file.

Hope this helps!

NickCullen commented 5 years ago

Hi,

I've further been looking at possible issues for this.

The static resource I am referencing is a simple string (as demonstrated in my previous comment) - I also have a "SettingsIcon" static resource specified in the same way: <x:String x:Key="SettingsIcon">&#xf013;</x:String>

I have the settings icon displaying on the MainPage as follows: <Button Style="{StaticResource SolidIcon}" Text="{StaticResource SettingsIcon}" VerticalOptions="Center" HorizontalOptions="End" Clicked="SettingsButton_Clicked"/>

And in the DataTemplate component used by a ListView on the MainPage I reference to the ShareIcon as follows: <Button Grid.Column="2" Grid.Row="0" IsVisible="{Binding HasImages}" Style="{StaticResource SolidIcon}" Text="{StaticResource ShareIcon}" Clicked="Handle_ExportClicked"> </Button>

The settings icon is displayed on MainPage but the icon referenced in the DataTemplate is not.

My workaround to get it running thus far is to compile the project without the static resource reference in the DataTemplate and deploy. Of course I can't see the share icon but if I compile the project and deploy with this reference in the DataTemplate it will always complain about not being able to find the resource regardless of me editing the reference out of the xaml post deploy.

Hopefully that will help some more

vincentcastagna commented 5 years ago

Can you consistently reproduce the issue?

The only thing I can recall I did since Friday was restart Gorilla. Did you try restarting Gorilla desktop app?

Hello @LeoHere . Yes the issue is always here. I did restart Gorilla, I even uninstalled old version and reinstalled from downloaded .exe on gorilla's website.

I don't know if this help but I think that might be linked with #309 .

I also noticed a similar behavior as @NickCullen in the project. I'm using a the multilingual toolkit and a custom tag to reference where text must be automatically translate :

xmlns:translator="clr-namespace:Project.Helpers"

The page where I use this tag is a page from a tabbedPage which contains two pages :

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
            xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
            xmlns:pages="clr-namespace:Project.Core.Views"
            prism:ViewModelLocator.AutowireViewModel="True"
            x:Class="Project.Core.Views.LandingPage"
            xmlns:translator="clr-namespace:Project.Helpers"
            Title="Project">

    <pages:DetailPage Icon="global_weather_icon.png"></pages:DetailPage>
    <pages:WelcomePage Icon="image001.png"></pages:WelcomePage>
</TabbedPage>

If I don't add the tag in the tabbedPage too (its already added in the detail & welcomepage, gorilla can't recognize the tag and so throw same exception as 309.

What I mean is that its probably a matter of "depth" concerning the path where files are at ... ? This seems to be one common parameter for all errors I got.
For instance, In this snippet I posted https://github.com/UXDivers/Gorilla-Player-Support/issues/313#issuecomment-437837493 my AppResourceDictionary is not at the same level as App.xaml. Note : I also got the same kind of prob with a custom navigation page class that is used in a module and referenced in the gorilla sdk that throws same error as 309.

I'll post here a repro project soon.

toomasz commented 5 years ago

I'm also getting same error with any resource located in App.xaml