Coder Social home page Coder Social logo

roubachof / sharpnado.shadows Goto Github PK

View Code? Open in Web Editor NEW
326.0 10.0 24.0 25.35 MB

Add as many custom shadows (Color, Offset, Blur, Neumorphism) as you like to any Xamarin.Forms view (Android, iOS, UWP).

License: MIT License

C# 97.74% PowerShell 2.26%

sharpnado.shadows's Introduction

Sharpnado.Shadows

Get it from NuGet:

Nuget

Supported platforms
✔️ Android
✔️ iOS
✔️ UWP
✔️ Tizen

Presentation

Initialization

  • On Core project in App.xaml.cs:

For the namespace schema to work, you need to call initializer from App.xaml.cs like this:

public App()
{
    InitializeComponent();

    Sharpnado.Shades.Initializer.Initialize(loggerEnable: false);
    ...
}
  • On iOS add this line after Xamarin.Forms.Forms.Init() and before LoadApplication(new App()).

Sharpnado.Shades.iOS.iOSShadowsRenderer.Initialize();

  • On UWP, you must register the renderers assembly like this, before Xamarin.Forms.Forms.Init():

var rendererAssemblies = new[] { typeof(UWPShadowsRenderer).GetTypeInfo().Assembly };

  • On Tizen add this line after Xamarin.Forms.Forms.Init() and before LoadApplication(new App()).

Sharpnado.Shades.Tizen.TizenShadowsRenderer.Initialize();

Presentation

Add as many custom shadows as you like to any Xamarin.Forms view (Android, iOS, UWP, Tizen).

  • You can specify each shadow Color, Opacity, BlurRadius, and Offset
  • Simply implement Neumorphism
  • You can add one shadow, 3 shadows, 99 shadows, to any Xamarin.Forms element
  • Animate any of these property and make the shadows dance around your elements
  • No AndroidX or SkiaSharp dependency required (except Tizen), only Xamarin.Forms

Animating shadows

Rendering Shadows is cpu intensive (especially on Android).

Using Xamarin.Forms animation API whith shadows is totally fine: it won't recreate the Shadows bitmaps.

However, animating the color, blur, opacity or size of a Shade, will result in creating multiple bitmap on Android.

Therefore if you want to animate the size of a view which is using Shadows, you should "disable" the shadows during the animation.

<sh:Shadows x:Name="MyViewShadows"
            CornerRadius="30"
            Shades="{sh:SingleShade Offset='0, 10',
                                    Opacity=0.7,
                                    Color=Violet}">
    <mine:SuperCustomView x:Name="MyView" />
</sh:Shadows>
private async Task MyViewTotallyFineAnimations()
{
    // Nothing to disable here
    await MyView.RotateXTo(90);
    await MyView.ScaleTo(2);
    await MyView.RotateXTo(0);
    await MyView.ScaleTo(1);
}

private async Task MyViewNeedsDisableShadowsAnimation()
{
    var shades = MyViewShadows.Shades;
    
    // Disabling shadows
    MyViewShadows.Shades = new List<Shades>();

    await MyView.AnimateWidthRequestAsync();
    
    // Restoring shadows
    MyViewShadows.Shades = shades;
}

Shadows for Xamarin.Forms components creators

Shadows has been developed with modularity in mind, making it really easy to integrate into your own components.

Read the wiki doc: https://github.com/roubachof/Sharpnado.Shadows/wiki/Shadows-for-Xamarin.Forms-components-builders.

Using Shadows

Shadows is a container for any Xamarin.Forms view. Just wrap your view in it and start adding shadows:

XAML

<sh:Shadows x:Name="CatShadows"
            CornerRadius="10">
    <sh:Shadows.Shades>
        <sh:ImmutableShades>
            <sh:Shade BlurRadius="10"
                      Opacity="0.5"
                      Offset="-10,-10"
                      Color="#FE99FE" />
            <sh:Shade BlurRadius="10"
                      Opacity="0.5"
                      Offset="10,10"
                      Color="#00B0FB" />
        </sh:ImmutableShades>
    </sh:Shadows.Shades>
    <Frame WidthRequest="80"
           Padding="10"
           HorizontalOptions="Center"
           VerticalOptions="Center"
           BackgroundColor="White"
           CornerRadius="10">
        <Image Source="{images:ImageResource nyan_cat.png}" />
    </Frame>
</sh:Shadows>

OUTPUT

Thanks to the CornerRadius property you can match your target corner to achieve a perfect shadow. For example, you can add a shadow to a rounded button:

XAML

<sh:Shadows CornerRadius="30"
            Shades="{sh:SingleShade Offset='0, 10',
                                    Opacity=0.7,
                                    Color=Violet}">
    <ImageButton WidthRequest="60"
                 HeightRequest="60"
                 Padding="20"
                 HorizontalOptions="Center"
                 VerticalOptions="Center"
                 BackgroundColor="Violet"
                 CornerRadius="30"
                 Source="{StaticResource IconPlusWhite}" />
</sh:Shadows>

OUTPUT

Choose your Shade Collection

You can use several type of IEnumerable<Shade>:

1. ReadOnlyCollection

This is what you want to use most of the time. All the different IMarkupExtension like ImmutableShades, NeumorphismShades, SingleShade, return a ReadOnlyCollection<Shade>. If you use a ReadOnlyCollection<Shade>, all shades will be cloned to be sure the immutability is respected. It means, you can specify shades as static objects in your ResourceDictionary, it won't create any leak or view hierarchy issues.

<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                    xmlns:sh="clr-namespace:Sharpnado.Shades;assembly=Sharpnado.Shadows">
    <sh:SingleShade x:Key="ShadowTop"
                    BlurRadius="6"
                    Opacity="0.15"
                    Offset="0,-8"
                    Color="{StaticResource ShadowsColor}" />

    <sh:SingleShade x:Key="ShadowBottom"
                    BlurRadius="6"
                    Opacity="0.1"
                    Offset="0,5"
                    Color="{StaticResource ShadowsColor}" />

    <sh:SingleShade x:Key="ShadowAccentBottom"
                    BlurRadius="6"
                    Opacity="0.4"
                    Offset="0,4"
                    Color="{StaticResource AccentColor}" />

    <sh:ImmutableShades x:Key="ShadowNone" />

    <sh:NeumorphismShades x:Key="ShadowNeumorphism" />

    <sh:NeumorphismShades x:Key="ShadowThinNeumorphism"
                          LowerOffset="8, 6"
                          UpperOffset="-8,-6" />
</ResourceDictionary>

2. ObservableCollection

Only if you want to dynamically add or remove shade during the view lifetime.

3. All other IEnumerable

If you want to modify a shade property during the view lifetime.

IMPORTANT: if you don't use a ReadOnlyCollection<Shade> please be sure to declare your Shade as transient. It means you should declare a new instance of Shade for each Shadows views. For example, in code-behind with new Shade(), or in xaml with Shades property. Just don't reference static instances of shade from ResourceDictionary with StaticResource references, or even in a C# class.

Shades

The Shadows component has only 2 properties:

  1. int CornerRadius which should be equal to the component's child view CornerRadius to achieve a good shadow effect,
  2. IEnumerable<Shade> Shades which is the enumeration of all the shades this shadow is made of.

A shade is what you could call a "sub-shadow".

Each shade has 4 properties:

  1. Point Offset: the offset of the shade
  2. Color Color: the color of the shade
  3. double Opacity: the opacity of the shade
  4. double BlurRadius: the amount of blur your want for this shade

Logo.xaml

<?xml version="1.0" encoding="UTF-8" ?>
<sh:Shadows x:Class="ShadowsSample.Views.Logo"
            xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:sh="http://sharpnado.com/schemas/shadows"
            CornerRadius="3">
    <sh:Shadows.Shades>
        <sh:ImmutableShades>
            <sh:Shade BlurRadius="10"
                      Opacity="1"
                      Offset="-15,-15"
                      Color="Yellow" />
            <sh:Shade BlurRadius="10"
                      Opacity="1"
                      Offset="15,15"
                      Color="Yellow" />
            <sh:Shade BlurRadius="10"
                      Opacity="1"
                      Offset="-15,15"
                      Color="Violet" />
            <sh:Shade BlurRadius="10"
                      Opacity="1"
                      Offset="15,-15"
                      Color="Violet" />
            <sh:Shade BlurRadius="5"
                      Opacity="1"
                      Offset="-5,-5"
                      Color="DeepSkyBlue" />
            <sh:Shade BlurRadius="5"
                      Opacity="1"
                      Offset="5,5"
                      Color="DeepSkyBlue" />
            <sh:Shade BlurRadius="5"
                      Opacity="1"
                      Offset="0,0"
                      Color="White" />
        </sh:ImmutableShades>
    </sh:Shadows.Shades>
    <Label Style="{StaticResource TextHuge}"
           VerticalOptions="Center"
           FontFamily="{StaticResource FontKarmatic}"
           Text="Shadows" />
</sh:Shadows>

OUTPUT

Neumorphism

To have a nice Neumorphism effect we need to choose a background color. I found that #F0F0F3 was quite good, so I will stick to it for our content and our page background color.

Since Neumorphism implementation is made of 2 shadows, one bright at the top left, one dark at the bottom right, achieving a Neumorphism style with Shadows for all the views is really easy:

<Style ApplyToDerivedTypes="True" TargetType="sh:Shadows">
    <Setter Property="CornerRadius" Value="10" />
    <Setter Property="Shades">
        <sh:ImmutableShades>
            <sh:Shade BlurRadius="10"
                      Opacity="1"
                      Offset="-10,-10"
                      Color="White" />
            <sh:Shade BlurRadius="10"
                      Opacity="1"
                      Offset="6, 6"
                      Color="#19000000" />
        </sh:ImmutableShades>
    </Setter>
</Style>

If you want to add Neumorphism to specific elements a NeumorphismShades markup extension will help you with that:

XAML

<sh:Shadows Grid.Row="1"
            Grid.Column="0"
            CornerRadius="40"
            Shades="{sh:NeumorphismShades}">
    <ImageButton WidthRequest="60"
                 HeightRequest="60"
                 Padding="20"
                 HorizontalOptions="Center"
                 VerticalOptions="Center"
                 BackgroundColor="#F0F0F3"
                 CornerRadius="30"
                 Source="{StaticResource IconPlusGray}" />
</sh:Shadows>

<sh:Shadows Grid.Row="1"
            Grid.Column="1"
            CornerRadius="10"
            Shades="{sh:NeumorphismShades}">
    <Button Style="{StaticResource TextHeadline}"
            WidthRequest="120"
            HeightRequest="60"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            BackgroundColor="#F0F0F3"
            CornerRadius="10"
            Text="Reset"
            TextColor="Gray" />
</sh:Shadows>

OUTPUT

Be creative!

One last thing: all properties of a Shade are animatable.

You can achieve nice effects thinking outside the box! Have a look at the BeCreative.xaml file and its code-behind.

BeCreative

Immutable and mutable collections of shades

To have a better control of your shades, Shadows provides 2 kinds of MarkupExtension:

  1. One immutable collection of shades: ImmutableShades (readonly type)
  2. One mutable collection: ShadeStack (observable collection type)

Use the first one if the shade collection will not change and the second one if you want to dynamically add or remove shades.

Dynamic shades starting with 0 shade.

<sh:Shadows CornerRadius="10">
    <sh:Shadows.Shades>
        <sh:ShadeStack />
    </sh:Shadows.Shades>
    <Frame WidthRequest="80"
           Padding="10"
           HorizontalOptions="Center"
           VerticalOptions="Center"
           BackgroundColor="White"
           CornerRadius="10">
        <Image Source="{images:ImageResource nyan_cat.png}" />
    </Frame>
</sh:Shadows>

SingleShade

You can also use the SingleShade markup extension if you just have one shadow. It will remove some xaml elements:

<sh:Shadows CornerRadius="30"
            Shades="{sh:SingleShade Offset='0, 10',
                                    Opacity=0.7,
                                    Color=Violet}">
    <ImageButton WidthRequest="60"
                 HeightRequest="60"
                 Padding="20"
                 HorizontalOptions="Center"
                 VerticalOptions="Center"
                 BackgroundColor="Violet"
                 CornerRadius="30"
                 Source="{StaticResource IconPlusWhite}" />
</sh:Shadows>

Performance

Warning: be sure to have the latest version of Shadows installed. Very big performance improvements (bitmap caching) have been implement in version 1.2.

  • On Android, shadows are created thanks to RenderScript. Bitmaps are cached in a global BitmapCache. For a particular color, size and blur, you will only have one instance alive.
  • On iOS, a Shade is implemented with a simple CALayer
  • On UWP, Shade is implemented with SpriteVisual drop shadows.
  • On Tizen, Shade is implemented with SkiaSharp.

sharpnado.shadows's People

Contributors

rookiejava avatar roubachof avatar themronion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharpnado.shadows's Issues

[Bug][UWP] White Background added inside Shadow element when using SingleShade.

Platform (please complete the following information):

  • OS: UWP
  • Device: Local Machine
  • Sdk version:
    • Target Version: Windows 10, version 2004.
    • Min Version: Windows 10, version 1809.
  • Xamarin.Forms: 5.0.0.1709-pre4
  • Library version: 1.2.0

Describe the bug
While trying the library I came up with this background I couldn't remove inside UWP when implementing a SingleShade.
I have not tried other shades because I only wanted one.
Tried setting the property BackgroundColor to transparent in the Shadow element but didn't do anything.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Xamarin.Forms project with Sharpnado.Shadows nuget installed in Android & UWP.
  2. In your MainPage, add the following code:
<shadows:Shadows CornerRadius="20" Shades="{shadows:SingleShade Offset='5, 5', BlurRadius=10, Opacity=0.25, Color=Black}">
                            <shadows:Shadows.HorizontalOptions>
                                <OnPlatform x:TypeArguments="LayoutOptions">
                                    <On Platform="UWP" Value="Center" />
                                    <On Platform="Android" Value="Start" />
                                </OnPlatform>
                            </shadows:Shadows.HorizontalOptions>
                            <Label
                                FontSize="Large"
                                Text="This is a test Label"
                                VerticalOptions="Center" />
                        </shadows:Shadows>
  1. Run both in Android & UWP.

The expected result is to see ONLY the shadow in both platforms.
In UWP the shadow does appear but it also adds a white background.

Screenshots (if applicable)
If applicable, add screenshots to help explain your problem.
Android:
screenshot-1607485895304
UWP:
image

[BUG] udating to XamarinFrom 5.0.0.2291 InvalidOperationException "Invalid on Color.Default"

On Xamarin Form Droid project I got InvalidOperationException "Invalid on Color.Default" exception.
I narrow down the issue to be in Shadow.Droid file Shadow.View.cs line 390. method FromShade.
The issue is happing because it is not valid to cal Color.MultiplyAlpha on Color.Default. For Example I got the same error with this line of code. Xamarin.Forms.Color.Default.MultiplyAlpha(0);
Therefore I tried to fix this avoiding the call Color.MultiplyAlpha if color is Color.Default.
Not sure if it is a full fix but it works form me

public static ShadeInfo FromShade(Context context, Shade shade, float cornerRadius, View shadowsSource)
{
    //ensure that we do not call Color.MultiplyAlpha on Color.Default
    Xamarin.Forms.Color color = Xamarin.Forms.Color.Default;
    if (shade.Color != Xamarin.Forms.Color.Default)
    {
        color = shade.Color.MultiplyAlpha(shade.Opacity);
    }
    var androidColor = color.ToAndroid();
    float blurRadius = context.ToPixels(shade.BlurRadius) * 2;
    float offsetX = context.ToPixels(shade.Offset.X);
    float offsetY = context.ToPixels(shade.Offset.Y);

    int width = shadowsSource.MeasuredWidth + 2 * Padding;
    int height = shadowsSource.MeasuredHeight + 2 * Padding;

    return new ShadeInfo(
        androidColor,
        blurRadius,
        offsetX,
        offsetY,
        cornerRadius,
        width,
        height);
}

Shadow binding stopped working in 1.2.0 version (worked in 1.1.0)

Platform (please complete the following information):

  • OS: Both
  • Device: all
  • Sdk vervion: all
  • Xamarin.Forms: Latest

Describe the bug
Shadow color binding stopped working in 1.2.0 version (worked in 1.1.0)

To Reproduce
Code:

   <sfList:SfListView
        Grid.Row="5"
        HorizontalOptions="CenterAndExpand"
        IsScrollBarVisible="False"
        IsScrollingEnabled="False"
        ItemSize="75"
        ItemTemplate="{StaticResource LedColorItemTemplate}"
        ItemsSource="{Binding LedsColorList}"
        SelectedItem="{Binding SelectedLed}"
        SelectedItemTemplate="{StaticResource SelectedLedColorItemTemplate}"
        SelectionMode="Single"
        VerticalOptions="StartAndExpand">
        <sfList:SfListView.LayoutManager>
            <sfList:GridLayout SpanCount="4" />
        </sfList:SfListView.LayoutManager>
    </sfList:SfListView>



  <DataTemplate x:Key="SelectedLedColorItemTemplate">
            <shades:Shadows
                Margin="0,2,0,0"
                BackgroundColor="White"
                CornerRadius="40"
                HorizontalOptions="Center">
                <shades:Shadows.Shades>
                    <shades:ImmutableShades>
                        <shades:Shade
                            BlurRadius="10"
                            Opacity="0.3"
                            Offset="5,5"
                            Color="{Binding ShadowColor}" />
                        <shades:Shade
                            BlurRadius="10"
                            Opacity="0.3"
                            Offset="-5,-5"
                            Color="{Binding ShadowColor}" />
                        <shades:Shade
                            BlurRadius="10"
                            Opacity="0.3"
                            Offset="-5,5"
                            Color="{Binding ShadowColor}" />
                        <shades:Shade
                            BlurRadius="10"
                            Opacity="0.3"
                            Offset="5,-5"
                            Color="{Binding ShadowColor}" />
                    </shades:ImmutableShades>
                </shades:Shadows.Shades>
                <border:SfBorder
                    BorderColor="{StaticResource FiordColor}"
                    BorderWidth="3"
                    CornerRadius="25"
                    HeightRequest="50"
                    HorizontalOptions="Center"
                    ShadowColor="{StaticResource ShadowGrayColor}"
                    VerticalOptions="Center"
                    WidthRequest="50">

                    <gradient:SfGradientView BackgroundBrush="{Binding BackgroundGradient}" />
                </border:SfBorder>
            </shades:Shadows>
        </DataTemplate>

Screenshots:
With 1.1.0:
good

With 1.2.0:
bad

iOS shadows do not have the correct color after updating Sharpnado.Shadows Nuget

Platform:

  • OS: iOS
  • Device: iPhone 11 Pro Max
  • Sdk vervion: iOS 16.2
  • Xamarin.Forms: 5.0.0.2545

We see shadows with correct color on:

  • iPhone 11 with iOS 15.1 and Nuget version: 1.2.1
  • iPhone 11 Pro max with iOS 16.2 and Nuget version 1.1.1

We see shadows with incorrect color on:

  • iPhone 11 Pro max with iOS 16.2 and Nuget version 1.2.1

So there is some problem in that version to support a later version of iOS.
If you could please investigate?

Shadow works only with iOS

Platform (please complete the following information):

  • OS: [Android]
  • Device: [AndroidEmulator]
  • Sdk vervion: [Android SDK 28]
  • Xamarin.Forms: [5.0.0.2012]

Describe the bug
Shadow is draw with iOS, but not with Android.

To Reproduce
Steps to reproduce the behavior:

  1. Run attached sample app with android and iOS

Screenshots (if applicable)
Android:
android

iOS:
ios

Sample App:
Sharpnado.Shadows.Bug.zip

UWP x64/x86 compilation

  • OS: Windows
  • Device: Windows PC
  • Sdk vervion: 10.0.18363
  • Xamarin.Forms: Latest

Describe the bug
The UWP project cannot be compiled in x64

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Xamarin Forms projekt with UWP
  2. Add NuGet Package Sharpnado.Shadows
  3. Try to compile in x64
  4. See error

Exceptions
There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "C:\Users\Lars.nuget\packages\sharpnado.shadows\1.0.2\lib\uap10.0.16299\Sharpnado.Shadows.UWP.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Possible to dynamically change properties on a shade using DataTriggers?

Has anyone figured out how to dynamically change properties on a shade using DataTriggers? I am finding it extremely difficult.

Something like

                <tabs:Shadows.Triggers> 
                         <DataTrigger Binding="{Binding Text}"  TargetType="tabs:Shadows.Shades"(of course this does not work because it is an IEnumerable)    Value="view all">  
                                 <Setter Property="Color" Value="Black" /> 
                        </DataTrigger>
                  </tabs:Shadows.Triggers> 

Support MAUI

Are there plans to support Microsoft's MAUI platform with Sharpnado.Shadows?

Now x86 doesn't compile in new version

Platform (please complete the following information):

  • OS: Windows
  • Sdk vervion: latest
  • Xamarin.Forms: latest

Describe the bug
Now after you have added the x64 uwp dll in the new version - getting errors when compiling x86. It's a closed circuit :D Maybe try to reach out nuget support, maybe they know how to include both x64 and x86 dlls?

Exceptions (if applicable)
Copy paste the exception and the stack trace

error MSB3270: There was a mismatch between the processor architecture of the project being build "x86" and the processor architecture of the reference "C:\Users\pluki_000\.nuget\packages\sharpnado.shadows\1.1.0\lib\uap10.0.16299\Sharpnado.Shadows.dll", "AMD64" (and the same for Sharpnado.Shadows.UWP.dll)

Some optimization tips on android when using a shadow in the data template of collview/listview?

Hey, it's me again. I am wondering wether it is possible to somehow optimize the appearance of datatemplates in a collectionview/listview with shadows? I guess i am getting some lags because the shadows are getting rendered in bitmaps and then disposed all over again when i am scrolling my list (as i understand how your code works). I will attach a gif of what i have now. Maybe it is possible to somehow save the created shadows in cache (maybe using FFImageLoading plugin, don't know) - so that when we have a lot of shadow items in a list we can reduce the lag? Or at least u can advice me something to minimize the lag (because on older phones i have serious lagging). Appreciate your answer and once again - love your work!
ezgif com-video-to-gif

Java.Lang.OutOfMemoryError

Describe the bug

Hi,

I have some pages in my app. On every page is a custom TitleBar, which I enclosed with your ShadowView so that it casts a shadow. Now I have noticed that after 30-40 pages have been created and rendered, an exception is thrown that the memory reserved for the app is full.

This only happens when I use your shadows. Apparently you are creating very large byte arrays for the shadows that are not cleared from memory quickly enough when navigating back and forth.

Can this problem be remedied?

Exceptions (if applicable)

Unhandled Exception:

Java.Lang.OutOfMemoryError: Failed to allocate a 2886412 byte allocation with 832368 free bytes and 812KB until OOM

Received Error Messages after Installation

  • OS:Both
  • Device: iPhoneSimulator & AndroidEmulator
  • Xamarin.Forms: 4.7.0.1239

After installation I received the following error message in "AppDelegate.cs" file:
The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)

Steps to reproduce the behavior:

  1. Install Sharpnado.Shadows plugin from Nuget
  2. Setup plugin in AppDelegate.cs file
  3. Run emulator
  4. Error message is produced

After uninstalling the plugin, the errors were resolved.

BackgroundColor Transparent isn't so transparent..

Platform (please complete the following information):

  • OS: [Android/Both]
  • Device: AndroidEmulator/OnePlus 6T
  • Sdk vervion: [Android SDK 29]
  • Xamarin.Forms: 4.6.0.1073

Applying a shadow to an item at the top of a stack layout. I then have a ListView immediately below it.
The idea was to have the list when scrolling look like items are moving underneath the item at the top of the stack layout.

After applying a shadow, the background colour of the item to which the shadow is on top of runs until the end of the shadow.
So if something is to pass 'under' it, the effect is lost.

Steps to reproduce the behavior:
-Add StackLayout with a SearchBar, and then a ListView.

  • Apply a white background to the SearchBar and a slightly darker background to the ListView
    -Add items to the list so it scrolls
    -Apply a shadow to the SearchBar and set BackgroundColor to Transparent
    -Scroll screen and notice the darker background proceeds past the end of the shadow

<sh:Shadows BackgroundColor="Transparent" Shades="{sh:SingleShade BlurRadius=3, Offset='0,0', Opacity=0.8, Color=Black}">

Shadow Not Transparent
image

[Bug] Super weird behavior with Material button

Platform (please complete the following information):

  • OS: Android 11
  • Device: Pizel 3a Android Emulator
  • Sdk vervion: Android API level 30
  • Xamarin.Forms: 5.0.0.2083

Describe the bug
I don't know where to file this bug so I figured I'd report it in both places,
if you think this bug is not related to this library feel free to close it.

More info:
xamarin/Xamarin.Forms#14601

Shadow White Box

  • OS: Windows10 20H2
  • Device: PC
  • Sdk vervion: UWP Target: 19041
  • Xamarin.Forms: 5.0.0.2012

I noticed a white box under the shadow and after disabling lines 113 and 136 in the UWPShadowsController.cs, the problem was fixed

with-white-box

without-white-box

UWP Documentation

For UWP, assembly information needs to be included when the app is loading in app.xaml.cs. If this is not added, the app will throw some exceptions. This info is missing from the wiki, but the code is there in the samples. Attaching the screenshot of the line which I'm referring to. This would help anyone who might be facing this issue.
image

Maui support?

Is there a plan/effort to port this package to Maui?

Would like to use this in a Maui App

Describe alternatives you've considered
None, yet.

Java.Lang.OutOfMemoryError on Android

Platform:

  • OS: Android
  • Device: Galaxy Note10+
  • Sdk vervion: Android SDK 29
  • Xamarin.Forms: 5.0.0.2012

Describe the bug
In some situations when Shadows is in bindable StackLayout and ScrollView, OutOfMemoryError is occurring

Exceptions

ShadowView.CreateBitmap (Sharpnado.Shades.Droid.ShadowView+ShadeInfo shadeInfo)
D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\ShadowView.cs, line 235

JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)
JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters)
Bitmap.CreateBitmap (System.Int32 width, System.Int32 height, Android.Graphics.Bitmap+Config config) /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Graphics.Bitmap.cs:855
ShadowView.CreateBitmap (Sharpnado.Shades.Droid.ShadowView+ShadeInfo shadeInfo) D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\ShadowView.cs:235
ShadowView+<>c__DisplayClass33_0.<InsertBitmap>b__1 () D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\ShadowView.cs:223
BitmapCache.Create (System.String hash, System.Func`1[TResult] create) D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\BitmapCache.cs:124
BitmapCache.Add (System.String hash, System.Func`1[TResult] create) D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\BitmapCache.cs:60
ShadowView.InsertBitmap (Sharpnado.Shades.Shade shade) D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\ShadowView.cs:223
ShadowView.RefreshBitmaps () D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\ShadowView.cs:175
ShadowView.OnSizeChanged (System.Int32 w, System.Int32 h, System.Int32 oldw, System.Int32 oldh) D:\Dev\Sharpnado\src\Sharpnado.Shadows\Shadows\Shadows.Droid\ShadowView.cs:100
View.n_OnSizeChanged_IIII (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 w, System.Int32 h, System.Int32 oldw, System.Int32 oldh) /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Views.View.cs:18500
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.156(intptr,intptr,int,int,int,int)
java.lang.OutOfMemoryError
android.graphics.Bitmap.nativeCreate(Native Method)
android.graphics.Bitmap.createBitmap Bitmap.java:1163
android.graphics.Bitmap.createBitmap Bitmap.java:1117
android.graphics.Bitmap.createBitmap Bitmap.java:1067
android.graphics.Bitmap.createBitmap Bitmap.java:1028
crc64994682affb61faca.ShadowView.n_onSizeChanged(Native Method)
crc64994682affb61faca.ShadowView.onSizeChanged ShadowView.java:54
android.view.View.sizeChange View.java:24682
android.view.View.setFrame View.java:24615
android.view.View.layout View.java:24472
crc64994682affb61faca.AndroidShadowsRenderer.n_onLayout(Native Method)
crc64994682affb61faca.AndroidShadowsRenderer.onLayout AndroidShadowsRenderer.java:45
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:37
crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.Platform_DefaultRenderer.onLayout Platform_DefaultRenderer.java:72
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:37
crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.Platform_DefaultRenderer.onLayout Platform_DefaultRenderer.java:72
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:37
crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.Platform_DefaultRenderer.onLayout Platform_DefaultRenderer.java:72
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:37
crc643f46942d9dd1fff9.ScrollViewContainer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.ScrollViewContainer.onLayout ScrollViewContainer.java:54
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.FrameLayout.layoutChildren FrameLayout.java:332
android.widget.FrameLayout.onLayout FrameLayout.java:270
androidx.core.widget.NestedScrollView.onLayout NestedScrollView.java:1854
crc643f46942d9dd1fff9.ScrollViewRenderer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.ScrollViewRenderer.onLayout ScrollViewRenderer.java:91
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
crc643f46942d9dd1fff9.VisualElementRenderer_1.n_onMeasure(Native Method)
crc643f46942d9dd1fff9.VisualElementRenderer_1.onMeasure VisualElementRenderer_1.java:108
android.view.View.measure View.java:27131
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:36
crc643f46942d9dd1fff9.PageRenderer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.PageRenderer.onLayout PageRenderer.java:72
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:37
crc64720bb2db43a66fe9.NavigationPageRenderer.n_onLayout(Native Method)
crc64720bb2db43a66fe9.NavigationPageRenderer.onLayout NavigationPageRenderer.java:65
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout FormsViewGroup.java:37
crc643f46942d9dd1fff9.PlatformRenderer.n_onLayout(Native Method)
crc643f46942d9dd1fff9.PlatformRenderer.onLayout PlatformRenderer.java:63
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.RelativeLayout.onLayout RelativeLayout.java:1103
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.FrameLayout.layoutChildren FrameLayout.java:332
android.widget.FrameLayout.onLayout FrameLayout.java:270
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.FrameLayout.layoutChildren FrameLayout.java:332
android.widget.FrameLayout.onLayout FrameLayout.java:270
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.FrameLayout.layoutChildren FrameLayout.java:332
android.widget.FrameLayout.onLayout FrameLayout.java:270
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.LinearLayout.setChildFrame LinearLayout.java:1829
android.widget.LinearLayout.layoutVertical LinearLayout.java:1673
android.widget.LinearLayout.onLayout LinearLayout.java:1582
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.widget.FrameLayout.layoutChildren FrameLayout.java:332
android.widget.FrameLayout.onLayout FrameLayout.java:270
com.android.internal.policy.DecorView.onLayout DecorView.java:1225
android.view.View.layout View.java:24475
android.view.ViewGroup.layout ViewGroup.java:7383
android.view.ViewRootImpl.performLayout ViewRootImpl.java:4260
android.view.ViewRootImpl.performTraversals ViewRootImpl.java:3695
android.view.ViewRootImpl.doTraversal ViewRootImpl.java:2618
android.view.ViewRootImpl$TraversalRunnable.run ViewRootImpl.java:9971
android.view.Choreographer$CallbackRecord.run Choreographer.java:1010
android.view.Choreographer.doCallbacks Choreographer.java:809
android.view.Choreographer.doFrame Choreographer.java:744
android.view.Choreographer$FrameDisplayEventReceiver.run Choreographer.java:995
android.os.Handler.handleCallback Handler.java:938
android.os.Handler.dispatchMessage Handler.java:99
android.os.Looper.loop Looper.java:246
android.app.ActivityThread.main ActivityThread.java:8512
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:602
com.android.internal.os.ZygoteInit.main ZygoteInit.java:1130

Error XFC0000: Cannot resolve type "shades:Shadows"

  • Sdk version: iOS 11/Android SDK 21
  • Xamarin.Forms: 4.8+

I installed the NuGet and added a shadow to a label, but got the next compilation error on build:

Error XFC0000: Cannot resolve type "shades:Shadows"

Steps to reproduce the behavior:

  1. Install nuget
  2. Add shadow namespace inside xaml
  3. Add shadow
  4. Try to build
  5. See error

Source of the page:


<?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:shades="http://sharpnado.com"
    x:Class="FailsInShadowsNuget.MainPage">
        <shades:Shadows>

            <Label FontSize="16" Padding="30,24,30,0">
                <Label.FormattedText>
                    <FormattedString>
                        <FormattedString.Spans>
                            <Span Text="Learn more at " />
                            <Span Text="https://aka.ms/xamarin-quickstart" FontAttributes="Bold" />
                        </FormattedString.Spans>
                    </FormattedString>
                </Label.FormattedText>
            </Label>
        </shades:Shadows>
</ContentPage>


Shadows degrade performance of ListViews/CollectionViews/SfListViews

First, thanks for this great feature, that enable us easy-development for nice UIs in XForms ;-)

The only problem we encounter with shadows, is that if we use them in DataTemplates/ItemTemplates, the lists have degraded performances and encounter some "lag" when scrolling...

Any maner to improve shadows better in ListViews ?
We tested it with ListViews, CollectionViews, SfListViews, Sharpnado.HorizontalListView, etc... the same "lag" everywhere, but if we just remove the shadows, the good performances are back again normaly...

Here attach some "Neumorphism UI" renders with Sharpnado.Shadows implemented... for Light and Dark Themes :-)
It will be great and soon in production if we can optimize these listview lags

Screenshot_20200902-172817

Screenshot_20200902-172952

Shade ColorBindableProperty is not Dynamic !

Platform (please complete the following information):

  • OS: [Both]
  • Devices: [iPhoneDevices/iPhoneSimulators/AndroidDevices/AndroidEmulators]
  • Sdk vervion: Whatever
  • Xamarin.Forms: [4.8.0.1451]

Describe the bug
When theming application (with LightTheme and DarkTheme for example), we need to apply "DynamicResources" to our visual elements, and when applying the theme, we just dynamically change the DynamicResources Values, and the application is themed automaticaly.

When I apply a "DynamicResource" to the "Color" property of a Sharpnado.Shade, it works for the first display, but when I change the value of my DynamicResource, it doesn't apply to the shade (it will do only if I reload completely the page, but it's not dynamic).

<sh:Shadows.Shades>
	<sh:ImmutableShades>
		<sh:Shade BlurRadius="3"
				  Opacity="1"
				  Offset="-4,-4"
				  Color="{DynamicResource DynamicNeumorphTopShadowColor}" />
		<sh:Shade BlurRadius="3"
				  Opacity="1"
				  Offset="4, 4"
				  Color="{DynamicResource DynamicNeumorphBottomShadowColor}" />
    </sh:ImmutableShades>
</sh:Shadows.Shades>

But the good news, is that I know why this behavior happens :

The "ColorProperty" (typeof(BindableProperty)) and the "Color" (typeof(Xamarin.Forms.Color)) are defining a type "Xamarin.Forms.Color" -> the Color type doesn't support/manage DynamicResources changes (it just convert the first call of our dynamicResource, to the current color associated)

To resolve this, you need to declare them as an "object" Type/returnType (and not a "Xamarin.Forms.Color" type) -> so we can give him a "DynamicResource" (in place of a static color) and when the value changes, it applies automagically ;-)

And maybe just ensure that this dynamic color changes is correctly managed in the "ElementPropertyChanged" methods of the platform renderers...

More info here -> https://forums.xamarin.com/discussion/comment/378514/#Comment_378514

Screenshots (if applicable)

Current behavior (Bad Shadows without page reload) :
Wrong

Expected behavior (Good Shadows after page reload) :
Right

If I got enough time, I could do a PR...
Let me know if you'll do it (or if you want a PR) for not doing the same work twice ;)

Very bad performance on Android

Platform (please complete the following information):

  • OS: Android
  • Device: any Android device
  • Sdk vervion: Android SDK 29
  • Xamarin.Forms: 5.0.0.1874

Describe the bug
Really bad performance when using shadows.
I used one same immutable shadow defined in App.xaml resources, for 5 frames in a page, the UI freezes for ~4 seconds to load the page. iOS works perfectly.
Even with only one shadow object, it hangs a little to load the page.

To Reproduce
Steps to reproduce the behavior:

  1. Create a view
  2. Create an immutable shade like in the readme.
  3. Apply the shade to some views

Colored Neumorphism

Is your feature request related to a problem? Please describe.
The neumorphism shades seem to only be for white, however I was thinking support for coloured neumorphism would be a really cool feature, because it looks really really cool as well: Coloured Neumorphism

Describe the solution you'd like
The plugin could have colour support for the neumorphism shade, like blue for example in the aforementioned website.
NeumorphButtons
NeuButton2
NeuButton3

These are some examples of coloured neumorphism, but I'm not really sure if this is going to be easy or hard to implement so this is more of just thoughts that a feature request I guess.

Crash: ShadowView.CreateBitmap: java.lang.nullpointerException

Platform (please complete the following information):

  • OS: Android
  • Device: Reports on galaxy Tab & Lenovo Tab
  • Sdk vervion: 9 & 10
  • Xamarin.Forms: Latest

Describe the bug
We're getting crash reports on ShadowView.CreateBitmap. Here's the stack trace from app center

To Reproduce
Steps to reproduce the behavior:
Haven't been able to repro locally - we're seeing these crash reports in App Center

Exceptions (if applicable)
stack.txt

Unhandled Exception:
ShadowView.CreateBitmap (Sharpnado.Shades.Droid.ShadowView+ShadeInfo shadeInfo)
Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.renderscript.RenderScript.validate()' on a null object reference```

How can I hide Shadows depending on platform?

Hello!

Your shadow library is really great! It works perfectly and I'm glad to finally have found someone who has managed to correctly display shadows easily on both Android and iOS.

But I have a suggestion. That is, could you add a property that indicates whether the shadow will be displayed? In some cases, I would like to display or render the shadow only on Android and not on iOS.

So that you can achieve something like this:

    <sh:Shadows CornerRadius="12">
        <sh:Shadows.Shades>
            <sh:ImmutableShades>
                <sh:Shade BlurRadius="12"
                          Opacity="0.3"
                          Offset="0,10"
                          Color="Black" />
            </sh:ImmutableShades>
        </sh:Shadows.Shades>

        <sh:Shadows.IsShown>
            <OnPlatform Android="True"
                        iOS="False"></OnPlatform>
        </sh:Shadows.IsShown>

        <ContentView Content="Some content."></ContentView>
    </sh:Shadows>

Of course I could set Opacity or all values to 0. But that would be unnecessary computing, since the shadow would still be rendered. Would you be able to do this or is it too complex?

Thanks! :)

Please add support for multiple corner radius too. I'm ready to help but I am a beginner.

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[Enhancement] Inner Shadows

Can we have an inner shadow property in Sharpnado.Shadows because there is litterally no inner shadow thing for Xamarin.Forms.

Strict mode - ShadowView LeakedClosableViolation

Platform (please complete the following information):

  • OS: Android
  • Device: Physical device (LG G8s)
  • Sdk vervion: Android 12.0 (S) - API 32
  • Xamarin.Forms: 5.0.0.2401

Describe the bug
When using shadows and having StrictMode enabled:

[StrictMode] StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
[StrictMode] 	at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1924)
[StrictMode] 	at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:303)
[StrictMode] 	at android.renderscript.BaseObj.finalize(BaseObj.java:145)
[StrictMode] 	at android.renderscript.Allocation.finalize(Allocation.java:432)
[StrictMode] 	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
[StrictMode] 	at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
[StrictMode] 	at java.lang.Daemons$Daemon.run(Daemons.java:139)
[StrictMode] 	at java.lang.Thread.run(Thread.java:923)
[StrictMode] Caused by: java.lang.Throwable: Explicit termination method 'destroy' not called
[StrictMode] 	at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:259)
[StrictMode] 	at dalvik.system.CloseGuard.open(CloseGuard.java:230)
[StrictMode] 	at android.renderscript.Allocation.<init>(Allocation.java:421)
[StrictMode] 	at android.renderscript.Allocation.<init>(Allocation.java:425)
[StrictMode] 	at android.renderscript.Allocation.createFromBitmap(Allocation.java:2833)
[StrictMode] 	at crc64994682affb61faca.ShadowView.n_onSizeChanged(Native Method)
[StrictMode] 	at crc64994682affb61faca.ShadowView.onSizeChanged(ShadowView.java:58)
[StrictMode] 	at android.view.View.sizeChange(View.java:23079)
[StrictMode] 	at android.view.View.setFrame(View.java:23031)
[StrictMode] 	at android.view.View.layout(View.java:22888)
[StrictMode] 	at crc64994682affb61faca.AndroidShadowsRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc64994682affb61faca.AndroidShadowsRenderer.onLayout(AndroidShadowsRenderer.java:48)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc643f46942d9dd1fff9.Platform_DefaultRenderer.onLayout(Platform_DefaultRenderer.java:75)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc643f46942d9dd1fff9.PageRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc643f46942d9dd1fff9.PageRenderer.onLayout(PageRenderer.java:75)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc64720bb2db43a66fe9.NavigationPageRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc64720bb2db43a66fe9.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:68)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc643f46942d9dd1fff9.PlatformRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc643f46942d9dd1fff9.PlatformRenderer.onLayout(PlatformRenderer.java:67)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1103)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] 	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
[StrictMode] 	at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at com.android.internal.policy.DecorView.onLayout(DecorView.java:892)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3664)
[StrictMode] 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3105)
[StrictMode] 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2035)
[StrictMode] 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8585)
[StrictMode] 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1056)
[StrictMode] 	at android.view.Choreographer.doCallbacks(Choreographer.java:878)
[StrictMode] 	at android.view.Choreographer.doFrame(Choreographer.java:811)
[StrictMode] 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1041)
[StrictMode] 	at android.os.Handler.handleCallback(Handler.java:938)
[StrictMode] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[StrictMode] 	at android.os.Looper.loop(Looper.java:223)
[StrictMode] 	at android.app.ActivityThread.main(ActivityThread.java:7888)
[StrictMode] 	at java.lang.reflect.Method.invoke(Native Method)
[StrictMode] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[StrictMode] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)
[StrictMode] StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
[StrictMode] 	at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1924)
[StrictMode] 	at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:303)
[StrictMode] 	at android.renderscript.BaseObj.finalize(BaseObj.java:145)
[StrictMode] 	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
[StrictMode] 	at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
[StrictMode] 	at java.lang.Daemons$Daemon.run(Daemons.java:139)
[StrictMode] 	at java.lang.Thread.run(Thread.java:923)
[StrictMode] Caused by: java.lang.Throwable: Explicit termination method 'destroy' not called
[StrictMode] 	at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:259)
[StrictMode] 	at dalvik.system.CloseGuard.open(CloseGuard.java:230)
[StrictMode] 	at android.renderscript.Script.<init>(Script.java:344)
[StrictMode] 	at android.renderscript.ScriptIntrinsic.<init>(ScriptIntrinsic.java:29)
[StrictMode] 	at android.renderscript.ScriptIntrinsicBlur.<init>(ScriptIntrinsicBlur.java:30)
[StrictMode] 	at android.renderscript.ScriptIntrinsicBlur.create(ScriptIntrinsicBlur.java:50)
[StrictMode] 	at crc64994682affb61faca.ShadowView.n_onSizeChanged(Native Method)
[StrictMode] 	at crc64994682affb61faca.ShadowView.onSizeChanged(ShadowView.java:58)
[StrictMode] 	at android.view.View.sizeChange(View.java:23079)
[StrictMode] 	at android.view.View.setFrame(View.java:23031)
[StrictMode] 	at android.view.View.layout(View.java:22888)
[StrictMode] 	at crc64994682affb61faca.AndroidShadowsRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc64994682affb61faca.AndroidShadowsRenderer.onLayout(AndroidShadowsRenderer.java:48)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc643f46942d9dd1fff9.Platform_DefaultRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc643f46942d9dd1fff9.Platform_DefaultRenderer.onLayout(Platform_DefaultRenderer.java:75)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc643f46942d9dd1fff9.PageRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc643f46942d9dd1fff9.PageRenderer.onLayout(PageRenderer.java:75)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc64720bb2db43a66fe9.NavigationPageRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc64720bb2db43a66fe9.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:68)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:37)
[StrictMode] 	at crc643f46942d9dd1fff9.PlatformRenderer.n_onLayout(Native Method)
[StrictMode] 	at crc643f46942d9dd1fff9.PlatformRenderer.onLayout(PlatformRenderer.java:67)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1103)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] 	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
[StrictMode] 	at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] 	at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] 	at com.android.internal.policy.DecorView.onLayout(DecorView.java:892)
[StrictMode] 	at android.view.View.layout(View.java:22891)
[StrictMode] 	at android.view.ViewGroup.layout(ViewGroup.java:6476)
[StrictMode] 	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3664)
[StrictMode] 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3105)
[StrictMode] 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2035)
[StrictMode] 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8585)
[StrictMode] 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1056)
[StrictMode] 	at android.view.Choreographer.doCallbacks(Choreographer.java:878)
[StrictMode] 	at android.view.Choreographer.doFrame(Choreographer.java:811)
[StrictMode] 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1041)
[StrictMode] 	at android.os.Handler.handleCallback(Handler.java:938)
[StrictMode] 	at android.os.Handler.dispatchMessage(Handler.java:99)
[StrictMode] 	at android.os.Looper.loop(Looper.java:223)
[StrictMode] 	at android.app.ActivityThread.main(ActivityThread.java:7888)
[StrictMode] 	at java.lang.reflect.Method.invoke(Native Method)
[StrictMode] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
[StrictMode] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)

To Reproduce
Steps to reproduce the behavior:

  1. Enable Strict mode (in OnCreate(...))
var vmPolicy = new StrictMode.VmPolicy.Builder();
StrictMode.SetVmPolicy(vmPolicy.DetectAll().PenaltyLog().Build());
  1. Use the Shadow
       <shades:Shadows>
            <shades:Shadows.Shades>
                <shades:ImmutableShades>
                    <shades:Shade/>
                </shades:ImmutableShades>
            </shades:Shadows.Shades>
            <Label Text="Hello World"/>
        </shades:Shadows>

Screenshots (if applicable)
It renders fine, but the debugger slows down considerably when using multiple shadows (since multiple exceptions are being printed)
When hot-reload triggers, the exceptions are not being printed (presumably due to the cache?)

Support for android 4.4?

Will your amazing package work with android 4.4? There is no elevation property there, so i got curious. Thanks for the future reply!

System.InvalidCastException on Windows

Hey, it's me again! Wondering - this is a syncfusion issue or it is fixable by you somehow?
Platform (please complete the following information):

  • OS: Windows
  • Device: Windows PC
  • Sdk vervion: 10, 18362
  • Xamarin.Forms: Latest

Describe the bug
Description below, happens only on UWP, Android - fine, iOS - haven't tested but i guess it's ok.

To Reproduce
Steps to reproduce the behavior:
Install SFEffectsView and try to make it as a source for ShadowView:
<sh:Shadows...> <syncEffectsView:SfEffectsView...> <Frame.../> </syncEffectsView:SfEffectsView> </sh:Shadows>

Exceptions (if applicable)
Copy paste the exception and the stack trace

System.InvalidCastException: "Unable to cast object of type 'Syncfusion.XForms.UWP.EffectsView.SfEffectsViewRenderer' to type 'Windows.UI.Xaml.IUIElement10'."

How-To: offset (0,-15) but bottom padding causes shadow on the lower side

Platform (please complete the following information):

  • OS: Both
  • Device: iPhone 12 mini (simulator), HUAWEI P9 Lite (real device, model: VNS-L31)
  • Sdk vervion: iOS 14.5, Android 7.0 API Level 24
  • Xamarin.Forms: 5.0.0.2083
  • Sharpnado.Shadows: 1.2.0

Describe the bug
StackLayout Bottom Padding causes a shadow at the bottom dispite the fact the the Offset for the Shadow is set to X=0, Y=-15.

To Reproduce
Steps to reproduce the behavior:

<sh:Shadows
        Margin="0,0,0,20"
        CornerRadius="10"
        Shades="{sh:SingleShade Offset='0,-15',
                                Opacity=0.3,
                                Color=Black}">
        <ScrollView>
            <StackLayout Spacing="0">
                <StackLayout.Padding>
                    <OnPlatform x:TypeArguments="Thickness">
                        <On Platform="Android" Value="0,0,0,20" />
                        <On Platform="iOS" Value="0,0,0,20" />
                    </OnPlatform>
                </StackLayout.Padding>
                <Button
                    BackgroundColor="White"
                    BorderColor="Blue"
                    BorderWidth="1"
                    HeightRequest="60"
                    Text="Press me inside ScrollView"
                    TextColor="Black"
                    WidthRequest="60" />
            </StackLayout>
        </ScrollView>
 </sh:Shadows>

Droid
image

iOS
image

If set the bottom padding to zero the shadow is drawn as expected only in -Y direction.

<sh:Shadows
        Margin="0,0,0,20"
        CornerRadius="10"
        Shades="{sh:SingleShade Offset='0,-15',
                                Opacity=0.3,
                                Color=Black}">
        <ScrollView>
            <StackLayout Spacing="0">
                <StackLayout.Padding>
                    <OnPlatform x:TypeArguments="Thickness">
                        <On Platform="Android" Value="0,0,0,0" />
                        <On Platform="iOS" Value="0,0,0,0" />
                    </OnPlatform>
                </StackLayout.Padding>
                <Button
                    BackgroundColor="White"
                    BorderColor="Blue"
                    BorderWidth="1"
                    HeightRequest="60"
                    Text="Press me inside ScrollView"
                    TextColor="Black"
                    WidthRequest="60" />
            </StackLayout>
        </ScrollView>
 </sh:Shadows>

Droid
image

iOS
image

Java.Lang.OutOfMemoryError (latest version)

Platform (please complete the following information):

  • OS: Android 9
  • Sdk vervion: Android SDK 30
  • Xamarin.Forms: 4.8.0.1687

Describe the bug
the app crashes immediately after launch

To Reproduce
Steps to reproduce the behavior:

  1. Run app
  2. Turn off the screen, then turn on
  3. After a few seconds, the app crashes

Exception

Java.Lang.OutOfMemoryError: Exception of type 'Java.Lang.OutOfMemoryError' was thrown.
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <89755ea61d9c4ae0a40ce90b872c9e2d>:0 
  at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in <89755ea61d9c4ae0a40ce90b872c9e2d>:0 
  at Android.Graphics.Bitmap.CreateBitmap (System.Int32 width, System.Int32 height, Android.Graphics.Bitmap+Config config) [0x0005a] in <4658d344ef4b4a429f9058200bb1b31c>:0 
  at Sharpnado.Shades.Droid.ShadowView.CreateBitmap (Sharpnado.Shades.Droid.ShadowView+ShadeInfo shadeInfo) [0x00028] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Sharpnado.Shades.Droid.ShadowView+<>c__DisplayClass33_0.<InsertBitmap>b__1 () [0x00000] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Sharpnado.Shades.Droid.BitmapCache.Create (System.String hash, System.Func`1[TResult] create) [0x00000] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Sharpnado.Shades.Droid.BitmapCache.Add (System.String hash, System.Func`1[TResult] create) [0x0008f] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Sharpnado.Shades.Droid.ShadowView.InsertBitmap (Sharpnado.Shades.Shade shade) [0x0009c] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Sharpnado.Shades.Droid.ShadowView.RefreshBitmaps () [0x00048] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Sharpnado.Shades.Droid.ShadowView.OnSizeChanged (System.Int32 w, System.Int32 h, System.Int32 oldw, System.Int32 oldh) [0x0004d] in <85592c7dc63b4f07a7b6c3cca9a87732>:0 
  at Android.Views.View.n_OnSizeChanged_IIII (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 w, System.Int32 h, System.Int32 oldw, System.Int32 oldh) [0x00008] in <4658d344ef4b4a429f9058200bb1b31c>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.94(intptr,intptr,int,int,int,int)

Lib version 1.2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.