Skip to content

Commit

Permalink
Add TouchBehavior (#1673)
Browse files Browse the repository at this point in the history
* init

* code style

* android bits

* code style

* dumb sample to test

* added a11y and initialization

* code style

* improved sample

* code style

* protect against NRE

* windows implementation

* code style

* Added comments to all public methods to enable builds without errors

* Missed some docs required for building

* Touch effect maui (#1326)

* Fixed some issues in Android implementation
* Added iOS implementation for TouchBehavior
* Reformatted code
* Removed duplicated extension methods

---------

Co-authored-by: Christian Rendl <cr@mutor.at>

* Bringing touch-effect up to date with main (#1383)

* Popup v6 windows (#1086)

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Shaun Lawrence <shaunrlawrence@gmail.com>

* ♻️ [Housekeeping] Fixed  GravatarImageSourceTests.TestDefaultStream (#1335)

* [housekeeping] Automated PR to fix formatting errors (#1327)

* Fix popup margin on iOS (#1329)

* Bump NuGet.Protocol from 6.6.1 to 6.7.0 in /samples (#1330)

* Use fully qualified namespace for Color reference in TextToColorGenerator (#1332)

* Use fully qualified namespace for Color reference in TextToColorGenerator to prevent collisions

This change should prevent "ambiguous reference" error to occur when other packages are included in a MAUI project that provide their own Color objects

* added global prefix to be safer

---------

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>

* Code cleanup and preparation for the next release (breaking changes) (#1324)

* Code cleanup and preparation for .net 8

* Update CompareConverter.shared.cs

* Revert global.json

* More CleanUps

* Remove redundant TrySetCanceled and rely on speech recognition result

* Update Formatting

---------

Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>

* Fix Gestures on Popup on ios (#1342)

* Fix Gestures on Popup on ios

* don't query type cast directly

* Code for AddLogicalChild (.NET 8)

* reduce changes

* setting the parent fixes the BindingContext of the view

* Revert "setting the parent fixes the BindingContext of the view"

This reverts commit 0a64b56.

* reduce changes

* simplify code

* fixing build

* assigned Element to contentPage.Parent

---------

Co-authored-by: pedrojesus <pedrojesus.cefet@gmail.com>

* `global.json`: Change `"rollForward": "latestMajor",` -> `"rollForward": "latestFeature"`. (#1338)

Update global.json

* Bump Microsoft.NET.Test.Sdk from 17.7.0 to 17.7.1 in /samples (#1348)

Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.0 to 17.7.1.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](microsoft/vstest@v17.7.0...v17.7.1)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 632 bug avatar view clipping on windows (#1344)

* Resolves issue on Windows where the splash screen icon is not found.

* Resolves an issue with the 'Ratings' sample for AvatarView.

* Spaces and not tabs

* Spaces and not tabs

* Changed MauiImage to point to Images folder.

* Changed splash for Windows to be Resize=False

* Typo in name of MauiImage

* Try to prevent locking.

* Bump Microsoft.CodeAnalysis from 4.6.0 to 4.7.0 in /samples (#1355)

* Bump Microsoft.CodeAnalysis.CSharp.Workspaces from 4.6.0 to 4.7.0 in /samples (#1357)

* Bump FluentAssertions from 6.11.0 to 6.12.0 in /samples (#1365)

* fix  IconTintColorBehavior  for Windows (#1370)

fix  IconTintColorBehavior  for windows

Co-authored-by: Oleksii <sokol@managed-code.com>

* Add `MemoryAnalyzer` roslyn analyzer (#1371)

* Add NuGet Package + Update `WarningsAsErrors`

* Fix MA0002

* Fix `MauiDrawingView`

* Fix `MauiPopup`

* Fix Naming

* return `null` for nullable references

* Use Ternary Operator

* `dotnet format`

* iOS popup fix with Shell or TabbedPage (#1343)

* Fix Issue #1256


Better fix

* Fixed Popup on Multiple Level Pages (#822)

---------

Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>

* [housekeeping] Automated PR to fix formatting errors (#1373)

* Bump Microsoft.NET.Test.Sdk from 17.7.1 to 17.7.2 in /samples (#1378)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Shaun Lawrence <shaunrlawrence@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: cat0363 <125236133+cat0363@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wolf <132034537+wolfgang-ironsoftware@users.noreply.github.com>
Co-authored-by: Thomas Stocker <thomas.stocker@gmail.com>
Co-authored-by: George Leithead <github@internetwideworld.com>
Co-authored-by: Sokol2001 <53799292+Sokol2001@users.noreply.github.com>
Co-authored-by: Oleksii <sokol@managed-code.com>
Co-authored-by: Andrey Onishchenko <100789522+cucumber-sp@users.noreply.github.com>

* Added MacOS and brought across the sample page style from XCT

* Added TouchBehavior Unit Tests

* Fixed issue with hover

* Fix Rebase Issues

Git didnt pick up all the changes and the rebase left some files in a wierd way. I have restored broken files to their state on main

* Manual fixes for rebase collisions

Some changes from the rebase had to be manually backed out by hand, I've restored the file from main which should be enough to revert the changes.

* Moved sample page to gallery

The sample page is now in the proper location, all of the shell wiring has been done. I have refactored the command code to live in the viewmodel and use the source generators. The sample isn't binding at this current time, I will have to investigate.

* Fixed behavior binding

The binding context wasnt being set on the platform behavior. We will need to understand the impact of this going forwards, see #795

* Fixed binding in sample

Updated to remove the binding context from the platform behavior, we use a relative binding to talk to the viewmodel now

* Added input transparency test case

There is now an example of the control design that fails to register inputs, even when transparency is opted into

* Fix issue with input transparency

The issue I discovered where iOS would not set input transparency if the first child was a layout has now been resolved.

* Fixed Parent Child Taps

There was an issue in the sample where when tapping the parent/child view inside the child, both commands would execute. I have fixed this aswell as making sure the other behaviors arent affected

* Fixed Hover

The hovering now works correctly, we missed one area to force the ui to update

* Fixed Ripple View Positioning

The ripple view now positions correctly when there are child views in a layout.

* Code styling

Removing private & internal everywhere it can be removed. Removed some unused properties and cleaned up some nullable bits

* Dotnet format

Ran dotnet format, only checked in files related to touch behavior

* Replaced Console with Trace

As requested in the code review

* Update GestureManager.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* Code review changes

Updating null checks to pattern matching, some tweaks & implementing suggestions from Pedro

* Code Review

- Use `static` when possible
- Use `TimeSpan` for Duration
- Properly Implement Async/Await
- Properly Dispose
- Use PatternMatching for Enum
- Move Primatives to CommunityToolkit.Maui.Core

* Remove duplicate `ColorTo` extension

* Fix Windows

The touch behavior was token by the cancellation token changes. I'm not sure if passing none is the best idea, we possibly need to generate a real one?

* Fixed unit tests

* Use `uint` for Duration

* Use `int` for Duration

* Add TouchBehaviorDefaults

* Update Unit Tests

* Remove duplicate calls to `ConfigureAwaitOptions.ForceYielding`

* `dotnet format`

* Add nullability to `PressedBackgroundColor`

* Remove Unused Internal Properties

* Resolve Windows Compiler Errors

* `dotnet format`

* Remove duplicate `splash.svg`

* Update formatting

* Update Formatting

* Fix Find + Replace Error

* Use Primary Constructors

* Fix find + replace error

* Update StatusBarBehavior.shared.cs

* Fix Splash Screen

* Fix LongPress Gesture

* Update Unit Tests

* Fix Build Errors on Windows

* `dotnet format`

* Fix duplicate SplashScreen

* Revert splashscreen svg

* Update CommunityToolkit.Maui.Sample.csproj

* Add Unit Tests for CurrentStateChanged

* Add `CanExecuteTest`

* Add Unit Tests

* Update src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/Touch/TouchBehavior.android.cs

Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>

* remove the ShouldUseNativeAnimation check in order to make it work

* throw ObjectDisposedException

* Big Fixes + Performance Improvements

* Remove `IsToggled`

* Update GestureManager.cs

* Rename `PulseCount` -> `RepeatAnimationCount`

* Prevent animations from happening immediately when the TouchBehavior is attached

* Rename `Normal` -> `Default`

* Cerate `ImageTouchBehavior`

* Move `SafeFireAndForgotExtensions`

* Update XML Documentation

* Fix Windows Build Errors

* Remove White Box

* `Normal` -> `Default`

* Fix Touch + Hover logic for ImageSource

* Remove `RepeatAnimationCount`

* Remove `RepeatAnimationCount`

* Fix `SetImageSource`

* `ContentVIew` -> `BoxView`

* Indicate Pressed and Released are Handled

Set e.Handled on PointerPressed and PointerReleased to stop passing to child controls on windows.

* Remove BoxView

* FIx Hover / Touch Logic in SetImageSource

* Refactor GestureManager, Add StateMachine tests

* Remove Unused + Duplicate Code

* Rename TouchBeahavior.methods.shared.cs

* Remove NativeAnimation Logic

* Remove NativeAnimation from Sample

* Fix Windows Build Errors

* Rename file

* Update ImageTouchBehaviorTests.cs

* Update ImageTouchBehaviorTests.cs

* Update ImageTouchBehaviorTests.cs

* Update ImageTouchBehaviorTests.cs

* Update ImageTouchBehaviorTests.cs

* Fix merge conflicts

* Fix build error

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
Co-authored-by: Kym Phillpotts <kphillpotts@gmail.com>
Co-authored-by: Christian Rendl <10274479+christianrr@users.noreply.github.com>
Co-authored-by: Christian Rendl <cr@mutor.at>
Co-authored-by: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com>
Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
Co-authored-by: Shaun Lawrence <shaunrlawrence@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: cat0363 <125236133+cat0363@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Wolf <132034537+wolfgang-ironsoftware@users.noreply.github.com>
Co-authored-by: Thomas Stocker <thomas.stocker@gmail.com>
Co-authored-by: George Leithead <github@internetwideworld.com>
Co-authored-by: Sokol2001 <53799292+Sokol2001@users.noreply.github.com>
Co-authored-by: Oleksii <sokol@managed-code.com>
Co-authored-by: Andrey Onishchenko <100789522+cucumber-sp@users.noreply.github.com>
Co-authored-by: Gerald Versluis <gerald@verslu.is>
  • Loading branch information
18 people authored Mar 27, 2024
1 parent eaf72cb commit d32fb23
Show file tree
Hide file tree
Showing 56 changed files with 5,419 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ csharp_style_namespace_declarations = file_scoped:error
# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
dotnet_diagnostic.CS4014.severity = error

# CS2012: ValueTask instances returned from member invocations are intended to be directly awaited. Attempts to consume a ValueTask multiple times or to directly access one's result before it's known to be completed may result in an exception or corruption. Ignoring such a ValueTask is likely an indication of a functional bug and may degrade performance.
dotnet_diagnostic.CS2012.severity = error

# CS1998 : This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
dotnet_diagnostic.CS1998.severity = error

# Remove explicit default access modifiers
dotnet_style_require_accessibility_modifiers = omit_if_default:error

Expand Down
1 change: 1 addition & 0 deletions samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public partial class AppShell : Shell
CreateViewModelMapping<SetFocusOnEntryCompletedBehaviorPage, SetFocusOnEntryCompletedBehaviorViewModel, BehaviorsGalleryPage, BehaviorsGalleryViewModel>(),
CreateViewModelMapping<StatusBarBehaviorPage, StatusBarBehaviorViewModel, BehaviorsGalleryPage, BehaviorsGalleryViewModel>(),
CreateViewModelMapping<TextValidationBehaviorPage, TextValidationBehaviorViewModel, BehaviorsGalleryPage, BehaviorsGalleryViewModel>(),
CreateViewModelMapping<TouchBehaviorPage, TouchBehaviorViewModel, BehaviorsGalleryPage, BehaviorsGalleryViewModel>(),
CreateViewModelMapping<UriValidationBehaviorPage, UriValidationBehaviorViewModel, BehaviorsGalleryPage, BehaviorsGalleryViewModel>(),
CreateViewModelMapping<UserStoppedTypingBehaviorPage, UserStoppedTypingBehaviorViewModel, BehaviorsGalleryPage, BehaviorsGalleryViewModel>(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\splash.svg" BaseSize="128,128" Color="#512BD4" Resize="false" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
Expand Down
3 changes: 2 additions & 1 deletion samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ static void RegisterViewsAndViewModels(in IServiceCollection services)
services.AddTransientWithShellRoute<RequiredStringValidationBehaviorPage, RequiredStringValidationBehaviorViewModel>();
services.AddTransientWithShellRoute<SelectAllTextBehaviorPage, SelectAllTextBehaviorViewModel>();
services.AddTransientWithShellRoute<SetFocusOnEntryCompletedBehaviorPage, SetFocusOnEntryCompletedBehaviorViewModel>();
services.AddTransientWithShellRoute<StatusBarBehaviorPage, StatusBarBehaviorViewModel>();
services.AddTransientWithShellRoute<TextValidationBehaviorPage, TextValidationBehaviorViewModel>();
services.AddTransientWithShellRoute<TouchBehaviorPage, TouchBehaviorViewModel>();
services.AddTransientWithShellRoute<UriValidationBehaviorPage, UriValidationBehaviorViewModel>();
services.AddTransientWithShellRoute<UserStoppedTypingBehaviorPage, UserStoppedTypingBehaviorViewModel>();
services.AddTransientWithShellRoute<StatusBarBehaviorPage, StatusBarBehaviorViewModel>();

// Add Converters Pages + ViewModels
services.AddTransientWithShellRoute<BoolToObjectConverterPage, BoolToObjectConverterViewModel>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>

<pages:BasePage
x:Class="CommunityToolkit.Maui.Sample.Pages.Behaviors.TouchBehaviorPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
xmlns:vm="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Behaviors"
x:Name="Page"
x:DataType="vm:TouchBehaviorViewModel"
x:TypeArguments="vm:TouchBehaviorViewModel">

<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="SectionHeader" TargetType="Label">
<Setter Property="Margin" Value="0,16,0,6" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="FontSize" Value="Large" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>

<ScrollView>
<VerticalStackLayout>

<Label HorizontalOptions="Center" HorizontalTextAlignment="Center"
FontSize="Body"
Text="{Binding TouchCount, StringFormat='Touches: {0}'}" />

<Label Style="{StaticResource SectionHeader}" Text="Image | Toggle" />
<Image HeightRequest="100" WidthRequest="100">
<Image.Behaviors>
<mct:ImageTouchBehavior
Command="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseTouchCountCommand}"
DefaultImageSource="button.png"
PressedImageSource="button_pressed.png" />
</Image.Behaviors>
</Image>

<Label Style="{StaticResource SectionHeader}" Text="Scale | Fade | Animated" />
<HorizontalStackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="Center">
<HorizontalStackLayout.Behaviors>
<mct:TouchBehavior
DefaultAnimationDuration="250"
DefaultAnimationEasing="{x:Static Easing.CubicInOut}"
Command="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseTouchCountCommand}"
PressedOpacity="0.6"
PressedScale="0.8" />
</HorizontalStackLayout.Behaviors>

<ContentView
HeightRequest="100"
WidthRequest="10"
BackgroundColor="Gold" />
<Label Text="The entire layout receives touches" VerticalOptions="Center" LineBreakMode="TailTruncation"/>
<ContentView
HeightRequest="100"
WidthRequest="10"
BackgroundColor="Gold" />
</HorizontalStackLayout>

<Label Style="{StaticResource SectionHeader}" Text="Long Press | Hover" />

<Label
FontSize="Body"
HorizontalOptions="CenterAndExpand"
Text="{Binding LongPressCount, StringFormat='Long press count: {0}'}"
Margin="0,0,0,6" />
<HorizontalStackLayout
Padding="20"
Background="Black"
HorizontalOptions="CenterAndExpand">
<HorizontalStackLayout.Behaviors>
<mct:TouchBehavior
Command="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseTouchCountCommand}"
HoveredBackgroundColor="{StaticResource Gray900}"
HoveredScale="1.2"
LongPressCommand="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseLongPressCountCommand}" />
</HorizontalStackLayout.Behaviors>
<Label
FontSize="Large"
Text="TITLE"
TextColor="White"
VerticalOptions="Start" />
</HorizontalStackLayout>

<Label Style="{StaticResource SectionHeader}" Text="Color | Rotation | Animated" />

<HorizontalStackLayout
Padding="20"
BackgroundColor="Gold"
HorizontalOptions="CenterAndExpand">

<HorizontalStackLayout.Behaviors>
<mct:TouchBehavior
DefaultAnimationDuration="500"
Command="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseTouchCountCommand}"
DefaultBackgroundColor="Gold"
PressedBackgroundColor="Orange"
PressedRotation="15" />

</HorizontalStackLayout.Behaviors>

<Label
FontSize="Large"
Text="TITLE"
TextColor="White" />
</HorizontalStackLayout>

<Label Style="{StaticResource SectionHeader}" Text="Image | Native" />
<Border StrokeThickness="1">
<Image
HeightRequest="100"
Source="button.png"
WidthRequest="100">
<Image.Behaviors>
<mct:TouchBehavior
Command="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseTouchCountCommand}" />
</Image.Behaviors>
</Image>
</Border>

<Label Style="{StaticResource SectionHeader}" Text="Nested effect" />

<ContentView
Padding="50"
Background="Yellow"
HeightRequest="200"
HorizontalOptions="Center"
WidthRequest="200">
<ContentView.Behaviors>
<mct:TouchBehavior
Command="{Binding Source={x:Reference Page}, Path=BindingContext.ParentClickedCommand}"/>
</ContentView.Behaviors>

<ContentView
BackgroundColor="Red"
HeightRequest="100"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="100">
<ContentView.Behaviors>
<mct:TouchBehavior
Command="{Binding Source={x:Reference Page}, Path=BindingContext.ChildClickedCommand}" />
</ContentView.Behaviors>
</ContentView>
</ContentView>

<Label Style="{StaticResource SectionHeader}" Text="Input transparency for nested layouts" />

<Border
Margin="20"
Padding="20,10"
BackgroundColor="Transparent"
StrokeShape="RoundRectangle, 10"
StrokeThickness="0">
<Border.Behaviors>
<mct:TouchBehavior
DefaultAnimationDuration="150"
DefaultAnimationEasing="{x:Static Easing.CubicInOut}"
Command="{Binding Source={x:Reference Page}, Path=BindingContext.IncreaseTouchCountCommand}"
PressedBackgroundColor="LightGray"
PressedOpacity="0.8"
PressedScale="0.9"
ShouldMakeChildrenInputTransparent="True" />
</Border.Behaviors>
<Grid
BackgroundColor="Transparent"
ColumnDefinitions="Auto, *"
ColumnSpacing="10">
<Ellipse
BackgroundColor="#A4CF5B"
HeightRequest="40"
WidthRequest="40" />
<VerticalStackLayout Grid.Column="1" VerticalOptions="Center">
<Label FontSize="20" Text="Lorem Ipsum" />
<Label FontSize="12"
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam gravida, sapien in volutpat ornare, magna dui condimentum dui, quis egestas tellus leo non nulla. Quisque sit amet neque dapibus, congue justo non, dapibus dolor." />
</VerticalStackLayout>
</Grid>
</Border>
</VerticalStackLayout>
</ScrollView>
</pages:BasePage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CommunityToolkit.Maui.Sample.ViewModels.Behaviors;

namespace CommunityToolkit.Maui.Sample.Pages.Behaviors;

public partial class TouchBehaviorPage : BasePage<TouchBehaviorViewModel>
{
public TouchBehaviorPage(TouchBehaviorViewModel viewModel)
: base(viewModel)
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage x:Class="CommunityToolkit.Maui.Sample.Pages.Views.PopupPositionPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Sample.Models;
using CommunityToolkit.Maui.Sample.Models;
using CommunityToolkit.Maui.Sample.ViewModels.Views;
using CommunityToolkit.Maui.Sample.Views.Popups;
using CommunityToolkit.Maui.Views;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ public class BehaviorsGalleryViewModel() : BaseGalleryViewModel(
SectionModel.Create<AnimationBehaviorViewModel>(nameof(AnimationBehavior), "Perform animation when a specified UI element event is triggered"),
SectionModel.Create<SelectAllTextBehaviorViewModel>(nameof(SelectAllTextBehavior), "Select all text inside the Entry or Editor control."),
SectionModel.Create<IconTintColorBehaviorViewModel>(nameof(IconTintColorBehavior), "Tint an icon with the selected color."),
SectionModel.Create<StatusBarBehaviorViewModel>(nameof(StatusBarBehavior), "Change the Status Bar color.")
]);
SectionModel.Create<StatusBarBehaviorViewModel>(nameof(StatusBarBehavior), "Change the Status Bar color."),
SectionModel.Create<TouchBehaviorViewModel>(nameof(TouchBehavior), "Alter a views appearance when responding to touch events (normal, pressed, hovered, long press).")
])
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace CommunityToolkit.Maui.Sample.ViewModels.Behaviors;

public partial class TouchBehaviorViewModel : BaseViewModel
{
[ObservableProperty]
int touchCount, longPressCount;

static Task DisplayAlert(string title, CancellationToken token)
=> Shell.Current.DisplayAlert(title, null, "Ok").WaitAsync(token);

[RelayCommand]
static Task ParentClicked(CancellationToken token)
=> DisplayAlert("Parent Clicked", token);

[RelayCommand]
static Task ChildClicked(CancellationToken token)
=> DisplayAlert("Child Clicked", token);

[RelayCommand]
void IncreaseTouchCount()
{
TouchCount++;
}

[RelayCommand]
void IncreaseLongPressCount()
{
LongPressCount++;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<mct:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CommunityToolkit.Maui.Sample.Views.Popups.XamlBindingPopup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CommunityToolkit.Maui.Core.Extensions;
using CommunityToolkit.Maui.Core.Extensions;
using CommunityToolkit.Maui.Core.Views;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.ComponentModel;

namespace CommunityToolkit.Maui.Core;

/// <summary>
/// Default Values for ImageTouchBehavior/>
/// </summary>
public static class ImageTouchBehaviorDefaults
{
/// <summary>
/// Default Value for TouchBehavior <see cref="DefaultBackgroundImageSource"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const object? DefaultBackgroundImageSource = null;

/// <summary>
/// Default Value for TouchBehavior <see cref="HoveredBackgroundImageSource"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const object? HoveredBackgroundImageSource = null;

/// <summary>
/// Default Value for TouchBehavior <see cref="PressedBackgroundImageSource"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const object? PressedBackgroundImageSource = null;

/// <summary>
/// Default Value for TouchBehavior <see cref="DefaultBackgroundImageAspect"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const Aspect DefaultBackgroundImageAspect = Aspect.AspectFit;

/// <summary>
/// Default Value for TouchBehavior <see cref="HoveredBackgroundImageAspect"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const Aspect HoveredBackgroundImageAspect = Aspect.AspectFit;

/// <summary>
/// Default Value for TouchBehavior <see cref="PressedBackgroundImageAspect"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const Aspect PressedBackgroundImageAspect = Aspect.AspectFit;

/// <summary>
/// Default Value for TouchBehavior <see cref="ShouldSetImageOnAnimationEnd"/>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public const bool ShouldSetImageOnAnimationEnd = false;
}
Loading

0 comments on commit d32fb23

Please sign in to comment.