Skip to content

Commit

Permalink
Fix #39 Shadow binding stopped working in 1.2.0 version (worked in 1.…
Browse files Browse the repository at this point in the history
…1.0) and #36 Crash: ShadowView.CreateBitmap: java.lang.nullpointerException
  • Loading branch information
roubachof committed Jun 14, 2022
1 parent b92faa9 commit 58eaafb
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 288 deletions.
3 changes: 2 additions & 1 deletion Sample/ShadowsSample.Android/Resources/Resource.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Sample/ShadowsSample.Android/ShadowsSample.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
Expand All @@ -38,6 +37,8 @@
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<BundleAssemblies>false</BundleAssemblies>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
<AndroidDexTool>dx</AndroidDexTool>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -126,7 +127,7 @@
<Name>Shadows.Droid</Name>
</ProjectReference>
<ProjectReference Include="..\ShadowsSample\ShadowsSample.csproj">
<Project>{A5BE210F-0735-431E-9BF3-1F2875D3BA92}</Project>
<Project>{4A4B357C-63C2-4572-B25F-0CE9391B6766}</Project>
<Name>ShadowsSample</Name>
</ProjectReference>
</ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Sample/ShadowsSample/Styles/Shadows.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<Setter Property="CornerRadius" Value="10" />
<Setter Property="Shades">
<sh:ImmutableShades>
<sh:Shade BlurRadius="8"
<sh:Shade BlurRadius="15"
Opacity="1"
Offset="-10,-10"
Color="White" />
<sh:Shade BlurRadius="10"
<sh:Shade BlurRadius="15"
Opacity="1"
Offset="6, 6"
Offset="10, 10"
Color="#19000000" />
</sh:ImmutableShades>
</Setter>
Expand Down
2 changes: 1 addition & 1 deletion Shadows/AssemblyInfo.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<Copyright>Copyright © Sharpnado 2020</Copyright>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
<Company>Sharpnado</Company>
<Product>Shadows</Product>
<Description>Add as many custom shadows as you like to any Xamarin.Forms view (Android, iOS, UWP). Set Color, Opacity, Blur, and Offset for each shadow.</Description>
Expand Down
8 changes: 5 additions & 3 deletions Shadows/Shadows.Droid/ShadowView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected override void OnSizeChanged(int w, int h, int oldw, int oldh)
{
base.OnSizeChanged(w, h, oldw, oldh);

if (w <= MinimumSize || h <= MinimumSize)
if (w <= MinimumSize || h <= MinimumSize || _isDisposed)
{
return;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ protected override void OnDraw(Canvas canvas)
var stopWatch = new Stopwatch();
stopWatch.Start();
#endif
if (!_weakSource.TryGetTarget(out var source))
if (!_weakSource.TryGetTarget(out var source) || _renderScript.IsNullOrDisposed())
{
return;
}
Expand Down Expand Up @@ -207,7 +207,9 @@ private void RefreshBitmap(Shade shade)

private void InsertBitmap(Shade shade)
{
if (!_weakSource.TryGetTarget(out var source) || !HasMinimumSize(source))
if (!_weakSource.TryGetTarget(out var source)
|| !HasMinimumSize(source)
|| _renderScript.IsNullOrDisposed())
{
return;
}
Expand Down
1 change: 0 additions & 1 deletion Shadows/Shadows.Droid/Shadows.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<FileAlignment>512</FileAlignment>
<Deterministic>True</Deterministic>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<LangVersion>latest</LangVersion>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidUseAapt2>true</AndroidUseAapt2>
Expand Down
5 changes: 5 additions & 0 deletions Shadows/Shadows.iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
151 changes: 77 additions & 74 deletions Shadows/Shadows.iOS/Shadows.iOS.csproj
Original file line number Diff line number Diff line change
@@ -1,75 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{794C7268-3BCA-483B-9ADB-E7D8E5DCDE89}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{a52b8a63-bc84-4b47-910d-692533484892}</TemplateGuid>
<OutputType>Library</OutputType>
<RootNamespace>Sharpnado.Shades.iOS</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>Sharpnado.Shadows.iOS</AssemblyName>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<CodeAnalysisRuleSet>..\StyleCopRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>4.6.0.847</Version>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSBuildTasks">
<Version>1.5.0.235</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shadows\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="CALayerExtensions.cs" />
<Compile Include="iOSShadowsController.cs" />
<Compile Include="iOSShadowsController.PropertyChanged.cs" />
<Compile Include="iOSShadowsRenderer.cs" />
<Compile Include="ShadeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shadows\Shadows.csproj">
<Project>{793936A7-04DD-4C8F-A8C1-524CF432C905}</Project>
<Name>Shadows</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{794C7268-3BCA-483B-9ADB-E7D8E5DCDE89}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TemplateGuid>{a52b8a63-bc84-4b47-910d-692533484892}</TemplateGuid>
<OutputType>Library</OutputType>
<RootNamespace>Sharpnado.Shades.iOS</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>Sharpnado.Shadows.iOS</AssemblyName>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<CodeAnalysisRuleSet>..\StyleCopRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>4.6.0.847</Version>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSBuildTasks">
<Version>1.5.0.235</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shadows\AssemblyInfo.cs">
<Link>AssemblyInfo.cs</Link>
</Compile>
<Compile Include="CALayerExtensions.cs" />
<Compile Include="iOSShadowsController.cs" />
<Compile Include="iOSShadowsController.PropertyChanged.cs" />
<Compile Include="iOSShadowsRenderer.cs" />
<Compile Include="ShadeExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shadows\Shadows.csproj">
<Project>{793936A7-04DD-4C8F-A8C1-524CF432C905}</Project>
<Name>Shadows</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
Loading

0 comments on commit 58eaafb

Please sign in to comment.