Axemasta.Maui.TouchEffect 1.1.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Axemasta.Maui.TouchEffect --version 1.1.8                
NuGet\Install-Package Axemasta.Maui.TouchEffect -Version 1.1.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Axemasta.Maui.TouchEffect" Version="1.1.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Axemasta.Maui.TouchEffect --version 1.1.8                
#r "nuget: Axemasta.Maui.TouchEffect, 1.1.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Axemasta.Maui.TouchEffect as a Cake Addin
#addin nuget:?package=Axemasta.Maui.TouchEffect&version=1.1.8

// Install Axemasta.Maui.TouchEffect as a Cake Tool
#tool nuget:?package=Axemasta.Maui.TouchEffect&version=1.1.8                

This repository has been unarchived and updated to target .NET 9 due to a number of breaking changed over in maui which render TouchBehavior not fit for use. The aim is to backport the MCT verion to this library, and then reintroduce it to the MCT. Hopefully when that is done this repository can be archives for good!

Maui.TouchEffect

NuGet Shield

Maui port of TouchEffect from Xamarin Community Toolkit

The originalaim of this library is to provide temporary support for the touch effect without having to take a dependency on XCT's MauiCompat library. My results of using the compat library have been extremely tempramental, alot of the times the touch effect does not work and due to the packages target framework (net6) & age (2 years old) I figured a new port would be the best option. Currently there is TouchBehavior available as part of the maui community toolkit however it is not stable due to a number of maui platform bugs regarding behaviors, and the maui team are unwilling to address these issues.

This library supports the following platforms:

Platform Supported
iOS
Android
Mac Catalyst
Windows
Tizen

Currently there is only iOS and Android, I plan to port to Mac Catalyst & Windows and also have as much as the code here mirror MCT as possible. At that point I will PR this back into the MCT and see what happens.

Install

  • Install Maui.TouchEffect package

  • In your MauiProgram.cs, call UseMauiTouchEffect:

    var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
    ++          .UseMauiTouchEffect()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                });
    

Usage

See the samples app from this project, it is a port of the TouchEffectPage from the XCT samples app.

<img src="assets/Sample_Demonstration.gif" alt="Sample app included with this project" width="500">

Declare xmlns:

xmlns:touch="http://axemasta.com/schemas/2023/toucheffect"

The api has been updated to match the naming conventions seen in MCT, this will help porting between the versions easier

<StackLayout
    touch:TouchEffect.AnimationDuration="250"
    touch:TouchEffect.AnimationEasing="{x:Static Easing.CubicInOut}"
    touch:TouchEffect.Command="{Binding Command, Source={x:Reference Page}}"
    touch:TouchEffect.PressedOpacity="0.6"
    touch:TouchEffect.PressedScale="0.8"
    HorizontalOptions="CenterAndExpand"
    Orientation="Horizontal">
    <BoxView
        HeightRequest="20"
        WidthRequest="20"
        Color="Gold" />
    <Label Text="The entire layout receives touches" />
    <BoxView
        HeightRequest="20"
        WidthRequest="20"
        Color="Gold" />
</StackLayout>

Native Animation

I have got this somewhat working again.

iOS

This provides extra opacity & touch feedback, its hard to see the value in this feature currently

Android

This provides ripples on touches. There are some wierd interactions when views have nested TouchEffects so be careful when applying them to complicated views.

Acknowlegements

This code is ported from:

Product Compatible and additional computed target framework versions.
.NET net9.0-android35.0 is compatible.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst18.0 is compatible.  net9.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0-android35.0

    • No dependencies.
  • net9.0-ios18.0

    • No dependencies.
  • net9.0-maccatalyst18.0

    • No dependencies.
  • net9.0-windows10.0.19041

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.15 94 1/7/2025
1.1.12 78 1/7/2025
1.1.10 65 1/7/2025
1.1.8 73 1/7/2025
1.1.0 64 1/7/2025