Skip to content

Commit

Permalink
MAUI Support (#29)
Browse files Browse the repository at this point in the history
* MAUI support

* updated gitignore

* change package name for nuget

* updated readme

* trying to create package
  • Loading branch information
roubachof authored Mar 18, 2023
1 parent fe4c93c commit d6a6604
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,5 @@ FakesAssemblies/
*.plg

# Visual Studio 6 workspace options file
*.opt
*.opt
.DS_Store
83 changes: 83 additions & 0 deletions Maui.Skeleton/Maui.Skeleton.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>

<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseMaui>true</UseMaui>

<AssemblyName>Sharpnado.HorusSkeleton.Maui</AssemblyName>
<RootNamespace>Maui.Skeleton</RootNamespace>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyFileVersion>2.0.0.0</AssemblyFileVersion>
<Version>2.0.0.0</Version>
<PackOnBuild>true</PackOnBuild>
<NeutralLanguage>en</NeutralLanguage>
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
<LangVersion>latest</LangVersion>

<PackageProjectUrl>https://github.com/roubachof/Maui.Skeleton/tree/master</PackageProjectUrl>
<RepositoryUrl>https://github.com/roubachof/Maui.Skeleton/tree/master</RepositoryUrl>
<PackageIconUrl>https://raw.githubusercontent.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/master/icon.png</PackageIconUrl>
<PackageTags>maui, .net maui, xamarin, ios, android, xamarin.forms, plugin, component, skeleton, loader, loading, indicator, activity, activityindicator, horus</PackageTags>
<PackageReleaseNotes>First .Net MAUI (.net 6) release \o/</PackageReleaseNotes>
<Title>Skeleton component for .Net MAUI</Title>
<Summary>Skeleton component for .Net MAUI</Summary>
<Description>The new loading approach for cool apps in .Net MAUI</Description>
<Owners>AgustinBonillaHorus, Jean-Marie Alfonsi</Owners>
<Authors>Horus, Jean-Marie Alfonsi</Authors>
<Copyright>Copyright 2023 Horus and Sharpnado</Copyright>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType />
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\AnimationTypes.cs">
<Link>Animations\AnimationTypes.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\BaseAnimation.cs">
<Link>Animations\BaseAnimation.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\BeatAnimation.cs">
<Link>Animations\BeatAnimation.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\FadeAnimation.cs">
<Link>Animations\FadeAnimation.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\HorizontalShakeAnimation.cs">
<Link>Animations\HorizontalShakeAnimation.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\IAnimation.cs">
<Link>Animations\IAnimation.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Animations\VerticalShakeAnimation.cs">
<Link>Animations\VerticalShakeAnimation.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Extensions\DefaultAnimationExtension.cs">
<Link>Extensions\DefaultAnimationExtension.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Extensions\ViewExtensions.cs">
<Link>Extensions\ViewExtensions.cs</Link>
</Compile>
<Compile Include="..\Xamarin.Forms.Skeleton\Skeleton.cs">
<Link>Skeleton.cs</Link>
</Compile>
</ItemGroup>


</Project>
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Xamarin.Forms.Skeleton
# Sharpnado.HorusSkeleton.Maui && Xamarin.Forms.Skeleton
<img src="https://raw.githubusercontent.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/master/icon.png" width="128">

The latest trend for loading approaches in Xamarin Forms apps. Skeleton can be easily implemented on each view contained in your Xaml.
The latest trend for loading approaches in MAUI and Xamarin Forms apps. Skeleton can be easily implemented on each view contained in your Xaml.

## Sample
<img src="https://github.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/blob/master/screenshots/Skeleton_general.gif" width="300">

## Setup
* Available on NuGet: [Sharpnado.HorusSkeleton.Maui](https://www.nuget.org/packages/Sharpnado.HorusSkeleton.Maui/) [![NuGet](https://img.shields.io/nuget/v/Sharpnado.HorusSkeleton.Maui.svg?label=NuGet)](https://www.nuget.org/packages/Sharpnado.HorusSkeleton.Maui/)
* Available on NuGet: [Xamarin.Forms.Skeleton](https://www.nuget.org/packages/Xamarin.Forms.Skeleton/) [![NuGet](https://img.shields.io/nuget/v/Xamarin.Forms.Skeleton.svg?label=NuGet)](https://www.nuget.org/packages/Xamarin.Forms.Skeleton/)
* Install into your Core and Client projects.

Expand All @@ -17,6 +18,7 @@ The latest trend for loading approaches in Xamarin Forms apps. Skeleton can be e
|Xamarin.iOS|iOS 8+|
|Xamarin.Android|API 16+|
|Xamarin.Forms|>= 4.0.0.425677|
|.net6 MAUI|ALL|

## API Usage

Expand Down Expand Up @@ -119,6 +121,12 @@ Add the following properties to set a loading animation with a specific backgrou


## Demo

Warning: The sample app hasn't been ported to maui.
If you want to see and example of skeleton implementation, checkout retronado.maui:
https://github.com/roubachof/Sharpnado.TaskLoaderView

Else, for xamarin.forms:
https://github.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/tree/master/SkeletonExample

## Roadmap
Expand Down
6 changes: 5 additions & 1 deletion Xamarin.Forms.Skeleton/Animations/AnimationTypes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Xamarin.Forms.Skeleton.Animations
#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public enum AnimationTypes
{
Expand Down
4 changes: 4 additions & 0 deletions Xamarin.Forms.Skeleton/Animations/BaseAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System.Threading.Tasks;

#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public abstract class BaseAnimation : IAnimation
{
Expand Down
6 changes: 4 additions & 2 deletions Xamarin.Forms.Skeleton/Animations/BeatAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Threading.Tasks;

#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public class BeatAnimation : BaseAnimation
{
Expand Down
6 changes: 4 additions & 2 deletions Xamarin.Forms.Skeleton/Animations/FadeAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Threading.Tasks;

#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public class FadeAnimation : BaseAnimation
{
Expand Down
6 changes: 4 additions & 2 deletions Xamarin.Forms.Skeleton/Animations/HorizontalShakeAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Threading.Tasks;

#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public class HorizontalShakeAnimation : BaseAnimation
{
Expand Down
6 changes: 5 additions & 1 deletion Xamarin.Forms.Skeleton/Animations/IAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Xamarin.Forms.Skeleton.Animations
#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public interface IAnimation
{
Expand Down
7 changes: 4 additions & 3 deletions Xamarin.Forms.Skeleton/Animations/VerticalShakeAnimation.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Threading.Tasks;

#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Animations
#else
namespace Xamarin.Forms.Skeleton.Animations
#endif
{
public class VerticalShakeAnimation : BaseAnimation
{
Expand Down
10 changes: 10 additions & 0 deletions Xamarin.Forms.Skeleton/Extensions/DefaultAnimationExtension.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
using System;

#if NET6_0_OR_GREATER
using Maui.Skeleton.Animations;
#else
using Xamarin.Forms.Skeleton.Animations;
using Xamarin.Forms.Xaml;
#endif


#if NET6_0_OR_GREATER
namespace Maui.Skeleton
#else
namespace Xamarin.Forms.Skeleton
#endif
{
[ContentProperty(nameof(Source))]
public sealed class DefaultAnimationExtension : IMarkupExtension<BaseAnimation>
Expand Down
11 changes: 9 additions & 2 deletions Xamarin.Forms.Skeleton/Extensions/ViewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
using System.Collections.Generic;
using System.Linq;

#if NET6_0_OR_GREATER
using Microsoft.Maui.Controls.Internals;
#else
using Xamarin.Forms.Internals;
#endif

#if NET6_0_OR_GREATER
namespace Maui.Skeleton.Extensions
#else
namespace Xamarin.Forms.Skeleton.Extensions
#endif
{
internal static class ViewExtensions
{
Expand Down
36 changes: 30 additions & 6 deletions Xamarin.Forms.Skeleton/Skeleton.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
using System;
using System.Linq;
#if NET6_0_OR_GREATER
using Maui.Skeleton.Animations;
using Maui.Skeleton.Extensions;
#else
using Xamarin.Forms.Skeleton.Animations;
using Xamarin.Forms.Skeleton.Extensions;
#endif


#if NET6_0_OR_GREATER
namespace Maui.Skeleton
#else
namespace Xamarin.Forms.Skeleton
#endif
{
public static class Skeleton
{
Expand Down Expand Up @@ -95,10 +105,13 @@ private static void OnIsBusyChanged(BindableObject bindable, bool newValue)
}
}

static void HandleIsBusyChanged(BindableObject bindable, bool isBusyNewValue){if (!(bindable is View))
static void HandleIsBusyChanged(BindableObject bindable, bool isBusyNewValue)
{
if (!(bindable is View))
return;

var view = (View)bindable;if (isBusyNewValue)
var view = (View)bindable;
if (isBusyNewValue)
{
if (GetHide(bindable))
{
Expand All @@ -118,7 +131,9 @@ private static void OnIsBusyChanged(BindableObject bindable, bool newValue)
SetBackgroundColor(view);

RunAnimation(view);
}}else
}
}
else
{
if (GetHide(bindable))
{
Expand All @@ -139,21 +154,22 @@ private static void OnIsBusyChanged(BindableObject bindable, bool newValue)
RestoreTextColor(view);
}
}
}}
}
}

private static void SetLayoutChilds(Layout layout)
{
if (layout.Children != null && layout.Children.Count > 0)
{
layout.Children.ToList().ForEach(x => x.SetValue(VisualElement.OpacityProperty, 0));
layout.Children.ToList().ForEach(x => ((View)x).SetValue(VisualElement.OpacityProperty, 0));
}
}

private static void RestoreLayoutChilds(Layout layout)
{
if (layout.Children != null && layout.Children.Count > 0)
{
layout.Children.ToList().ForEach(x => x.SetValue(VisualElement.OpacityProperty, 1));
layout.Children.ToList().ForEach(x => ((View)x).SetValue(VisualElement.OpacityProperty, 1));
}
}

Expand Down Expand Up @@ -193,13 +209,21 @@ private static void SetTextColor(View view)
{
hasDynamic = hasDynamic || label.HasDynamicColorOnProperty(Label.TextColorProperty);
SetOriginalTextColor(label, label.TextColor);
#if NET6_0_OR_GREATER
label.TextColor = Colors.Transparent;
#else
label.TextColor = Color.Transparent;
#endif
}
else if (view is Button button)
{
hasDynamic = hasDynamic || button.HasDynamicColorOnProperty(Button.TextColorProperty);
SetOriginalTextColor(button, button.TextColor);
#if NET6_0_OR_GREATER
button.TextColor = Colors.Transparent;
#else
button.TextColor = Color.Transparent;
#endif
}

SetUseDynamicTextColor(view, hasDynamic);
Expand Down

0 comments on commit d6a6604

Please sign in to comment.