Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.0.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnimationCancellation", "AnimationCancellation\AnimationCancellation.csproj", "{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Release|Any CPU.Build.0 = Release|Any CPU
{4AE8913C-E1C9-4E9E-B410-3C034ABE6EFB}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DCD6A0DD-E16D-4518-9EAF-E3DD9CB9A645}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net11.0-android;net11.0-ios;net11.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net11.0-windows10.0.19041.0</TargetFrameworks>

<OutputType>Exe</OutputType>
<RootNamespace>AnimationCancellation</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>

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

<!-- App Identifier -->
<ApplicationId>com.companyname.animationcancellation</ApplicationId>

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

<WindowsPackageType>None</WindowsPackageType>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">17.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</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.png" Resize="True" BaseSize="300,185" />

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

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(DotNetVersion)" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AnimationCancellation"
x:Class="AnimationCancellation.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace AnimationCancellation;

public partial class App : Application
{
public App()
{
InitializeComponent();
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new MainPage())
{
Title = "Animation Cancellation - .NET MAUI 11"
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global using Microsoft.Maui.Controls;
global using Microsoft.Maui.Controls.Xaml;
global using Microsoft.Maui.Controls.Shapes;
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AnimationCancellation.MainPage"
Title="Animation cancellation"
BackgroundColor="#F0F2F5">

<ScrollView>
<VerticalStackLayout Padding="20,40" Spacing="20">

<Label Text="Animation cancellation"
FontSize="28"
FontAttributes="Bold"
TextColor="#512BD4"
HorizontalOptions="Center" />

<Label Text="The async animation methods on ViewExtensions now accept a CancellationToken. Pass a token, then cancel it to abort the animation cleanly without waiting for it to finish."
FontSize="14"
TextColor="#666666"
HorizontalTextAlignment="Center"
Margin="0,0,0,10" />

<Border StrokeShape="RoundRectangle 12"
StrokeThickness="0"
BackgroundColor="White"
Padding="20">
<VerticalStackLayout Spacing="16">

<Image x:Name="LogoImage"
Source="dotnet_bot.png"
HeightRequest="180"
Aspect="AspectFit" />

<Label x:Name="StatusLabel"
Text="Ready."
FontSize="14"
TextColor="#333333"
HorizontalOptions="Center" />

<HorizontalStackLayout Spacing="10" HorizontalOptions="Center">
<Button x:Name="FadeButton"
Text="Fade out (5s)"
BackgroundColor="#512BD4"
TextColor="White"
Clicked="OnFadeClicked" />
<Button x:Name="CancelButton"
Text="Cancel"
BackgroundColor="#D32F2F"
TextColor="White"
IsEnabled="False"
Clicked="OnCancelClicked" />
<Button Text="Reset"
BackgroundColor="#888888"
TextColor="White"
Clicked="OnResetClicked" />
</HorizontalStackLayout>

</VerticalStackLayout>
</Border>

<Label Text="Try this:"
FontSize="16"
FontAttributes="Bold"
TextColor="#333333"
Margin="0,10,0,0" />

<Label Text="1. Tap Fade out (5s) to start a long fade.&#10;2. Tap Cancel before the fade finishes."
FontSize="13"
TextColor="#666666" />

</VerticalStackLayout>
</ScrollView>

</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace AnimationCancellation;

public partial class MainPage : ContentPage
{
CancellationTokenSource? _cts;

public MainPage()
{
InitializeComponent();
}

// <docregion_fade_with_token>
async void OnFadeClicked(object? sender, EventArgs e)
{
_cts?.Cancel();
_cts = new CancellationTokenSource();

FadeButton.IsEnabled = false;
CancelButton.IsEnabled = true;
StatusLabel.Text = "Fading...";

// FadeToAsync returns Task<bool>: true means the animation was
// canceled, false means it ran to completion. The method does not
// throw on cancellation.
bool canceled = await LogoImage.FadeToAsync(0, 5000, Easing.SinIn, _cts.Token);

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (macos-26)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (macos-26)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

Check failure on line 25 in 11.0/UserInterface/Animation/AnimationCancellation/AnimationCancellation/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

No overload for method 'FadeToAsync' takes 4 arguments

StatusLabel.Text = canceled
? $"Canceled at opacity {LogoImage.Opacity:F2}."
: "Faded out.";

FadeButton.IsEnabled = true;
CancelButton.IsEnabled = false;
}

void OnCancelClicked(object? sender, EventArgs e)
{
_cts?.Cancel();
}
// </docregion_fade_with_token>

void OnResetClicked(object? sender, EventArgs e)
{
_cts?.Cancel();
LogoImage.Opacity = 1;
StatusLabel.Text = "Ready.";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.Logging;

namespace AnimationCancellation;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

#if DEBUG
builder.Logging.AddDebug();
#endif

return builder.Build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;

namespace AnimationCancellation
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Android.App;
using Android.Runtime;

namespace AnimationCancellation
{
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Foundation;

namespace AnimationCancellation
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?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>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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>
<key>UIDeviceFamily</key>
<array>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using ObjCRuntime;
using UIKit;

namespace AnimationCancellation
{
public class Program
{
static void Main(string[] args)
{
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<maui:MauiWinUIApplication
x:Class="AnimationCancellation.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:AnimationCancellation.WinUI">

</maui:MauiWinUIApplication>
Loading
Loading