Skip to content

Commit

Permalink
Refine Sample project.
Browse files Browse the repository at this point in the history
  • Loading branch information
microspaze committed Apr 16, 2024
1 parent aafcd96 commit b53873a
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 10 deletions.
27 changes: 27 additions & 0 deletions FFImageLoading.Sample.Droid.Nuget.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Droid.Nuget", "samples\Sample\Sample.Droid.Nuget.csproj", "{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}.Release|Any CPU.Build.0 = Release|Any CPU
{3958DC96-3E5B-4D89-BC3F-8E6634FF5766}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BF56189-8DC5-41A9-9440-3C7B9F57E151}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion samples/Sample/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public App()

//Issue #3 Reproduce Sample
//Set MainPage by Page with CachedImage may cause ImageService NRE
//MainPage = new BasicPage();
//MainPage = new SimpleGifPage();

var m = new MenuPage();
MainPage = new NavigationPage(m);
Expand Down
34 changes: 27 additions & 7 deletions samples/Sample/Pages/SimpleGifPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,42 @@
x:Class="Sample.SimpleGifPage"
Title="Simple Gif">
<ContentPage.Content>
<ScrollView>
<StackLayout Spacing="10" BackgroundColor="LightGray">
<Button Text="Change GIF" Clicked="OnChangeClicked"/>

<Label Text="GIF without Transformations Render by Image and System" HorizontalOptions="Center" />
<Image WidthRequest="150" IsAnimationPlaying="True" Source="{Binding ImageUrl}"></Image>
<Image WidthRequest="200" HeightRequest="100"
IsAnimationPlaying="True" BackgroundColor="AliceBlue"
Aspect="AspectFit" Source="{Binding ImageUrl}"></Image>

<Label Text="GIF without Transformations Render by CachedImage and System" HorizontalOptions="Center" />
<ffimageloading:CachedImage WidthRequest="150" Source="{Binding ImageUrl}">
<ffimageloading:CachedImage WidthRequest="200" HeightRequest="100"
x:Name="cachedImage"
LoadingPlaceholder="loading2.gif"
ErrorPlaceholder="error.png"
BackgroundColor="AliceBlue"
Aspect="AspectFit" Source="{Binding ImageUrl}">
</ffimageloading:CachedImage>

<Label Text="GIF with DownSampleSize or Transformations Render by CachedImage and FFImageLoading.Maui" HorizontalOptions="Center" />
<ffimageloading:CachedImage WidthRequest="150" Source="{Binding ImageUrl}">
<Label Text="GIF without Transformations Render by CachedImageView and System" HorizontalOptions="Center" />
<ffimageloading:CachedImageView WidthRequest="200" HeightRequest="100"
x:Name="cachedImageView"
LoadingPlaceholder="loading2.gif"
ErrorPlaceholder="error.png"
Success="OnLoadSuccess"
SuccessCommand="{Binding SuccessCommand}"
Padding="5" Stroke="Red" StrokeThickness="1" BackgroundColor="AliceBlue"
Aspect="AspectFit" Source="{Binding ImageUrl}">
</ffimageloading:CachedImageView>

<!--<Label Text="GIF with DownSampleSize or Transformations Render by CachedImage and FFImageLoading.Maui" HorizontalOptions="Center" />
<ffimageloading:CachedImage x:Name="cachedImage" HorizontalOptions="Center" Aspect="AspectFit" Source="{Binding ImageUrl}" BackgroundColor="AliceBlue" HeightRequest="100">
<ffimageloading:CachedImage.Transformations>
<fftransformations:CircleTransformation/>
</ffimageloading:CachedImage.Transformations>
</ffimageloading:CachedImage>

<Button Text="Change GIF" Clicked="OnChangeClicked"/>
</ffimageloading:CachedImage>-->
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
6 changes: 6 additions & 0 deletions samples/Sample/Pages/SimpleGifPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ protected override void OnAppearing()

private void OnChangeClicked(object sender, EventArgs e)
{
//Console.Write(cachedImageView.ImageView.Width);
viewModel.Reload();
}

private void OnLoadSuccess(object sender, FFImageLoading.Maui.CachedImageEvents.SuccessEventArgs e)
{
Console.WriteLine("CachedImageView load success!");
}
}
}
17 changes: 15 additions & 2 deletions samples/Sample/Pages/SimpleGifPageModel.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@

using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace Sample
{
public partial class SimpleGifPageModel : ObservableObject
{
//TODO: loading3.gif takes long time for parsing in GifHelper.cs
private static int _imageUrlIndex = 0;
private static readonly string[] _imageUrls = ["tenor.gif", "cat.gif", "duck.gif", "letter3d.gif", "loading2.gif", "loading3.gif"];
private static readonly string[] _imageUrls = ["tenor.gif", "no_avatar.png", "cat.gif", "lake.webp", "duck.gif", "letter3d.gif", "loading2.gif", "loading3.gif"];

public void Reload()
public ICommand SuccessCommand { get; set; }

public SimpleGifPageModel()
{
SuccessCommand = new RelayCommand(() =>
{
Console.WriteLine("CachedImageView command success!");
});
}


public void Reload()
{
ImageUrl = _imageUrls[_imageUrlIndex];
_imageUrlIndex++;
Expand Down
139 changes: 139 additions & 0 deletions samples/Sample/Sample.Droid.Nuget.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Sample</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<UseInterpreter>true</UseInterpreter>

<!-- Display name -->
<ApplicationTitle>Sample</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.i7chi.ffimagesample</ApplicationId>
<ApplicationIdGuid>96efed10-1559-4cef-8f0f-4b9c19662fa0</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Configurations>Debug;Release</Configurations>
<Platforms>Device;Simulator;AnyCPU</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<MtouchFastDev>true</MtouchFastDev>
<IOSDebugOverWiFi>true</IOSDebugOverWiFi>
<MtouchDebug>true</MtouchDebug>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Device' ">
<MtouchDebug>true</MtouchDebug>
<IOSDebugOverWiFi>true</IOSDebugOverWiFi>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
<!--DEBUG ON DEVICE-->
<!--<RuntimeIdentifier Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">ios-arm64</RuntimeIdentifier>-->
<!--<RuntimeIdentifier Condition="'$(Configuration)|$(Platform)'=='Release|Device'">ios-arm64</RuntimeIdentifier>-->
<!--<RuntimeIdentifier Condition="'$(Configuration)|$(Platform)'=='Debug|Device'">ios-arm64</RuntimeIdentifier>-->
<!--DEBUG ON SIMULATOR-->
<RuntimeIdentifier Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">iossimulator-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(Configuration)|$(Platform)'=='Debug|Simulator'">iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|Device'">
<ApplicationTitle>FFImage</ApplicationTitle>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|Simulator'">
<ApplicationTitle>FFImage</ApplicationTitle>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
<ApplicationTitle>FFImage</ApplicationTitle>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|Device'">
<ApplicationTitle>FFImage</ApplicationTitle>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|Simulator'">
<ApplicationTitle>FFImage</ApplicationTitle>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
<ApplicationTitle>FFImage</ApplicationTitle>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<MauiImage Update="Resources\Images\no_avatar_4x.png" BaseSize="89,89" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="Platforms\Android\Resources\drawable-hdpi\lake1.webp" />
<None Remove="Platforms\Android\Resources\drawable-mdpi\lake2.webp" />
<None Remove="Platforms\Android\Resources\drawable-xhdpi\lake3.webp" />
<None Remove="Platforms\Android\Resources\drawable-xxhdpi\lake4.webp" />
<None Remove="Platforms\Android\Resources\drawable-xxxhdpi\lake5.webp" />
<None Remove="Resources\Raw\svg001raw.svg" />
<None Remove="svg001.svg" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Platforms\Android\Resources\drawable-hdpi\lake1.webp" />
<AndroidResource Include="Platforms\Android\Resources\drawable-mdpi\lake2.webp" />
<AndroidResource Include="Platforms\Android\Resources\drawable-xhdpi\lake3.webp" />
<AndroidResource Include="Platforms\Android\Resources\drawable-xxhdpi\lake4.webp" />
<AndroidResource Include="Platforms\Android\Resources\drawable-xxxhdpi\lake5.webp" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<PackageReference Include="FFImageLoading.Maui" Version="1.1.5" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="replace.svg" />
<EmbeddedResource Include="sample.svg" />
<EmbeddedResource Include="svg001.svg" />
<EmbeddedResource Include="tenor.gif" />

<MauiImage Update="Resources/Images/error.png" Resize="False" />
<MauiImage Update="Resources/Images/loading.png" Resize="False" />
<MauiAsset Include="sample.svg" Resize="False">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</MauiAsset>
<MauiImage Update="Resources/Images/ic_star_black_24dp.png" BaseSize="24,24" />
</ItemGroup>
</Project>

0 comments on commit b53873a

Please sign in to comment.