Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Add LongPressCompleted event to TouchEffect #1064

Merged
merged 1 commit into from
Mar 13, 2021
Merged
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,12 @@
using System;

namespace Xamarin.CommunityToolkit.Effects
{
public class LongPressCompletedEventArgs : EventArgs
{
internal LongPressCompletedEventArgs(object? parameter)
=> Parameter = parameter;

public object? Parameter { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ internal void HandleLongPress(TouchEffect sender)
{
sender.HandleUserInteraction(TouchInteractionStatus.Completed);
sender.LongPressCommand?.Execute(sender.LongPressCommandParameter ?? sender.CommandParameter);
sender.RaiseLongPressCompleted();
});

if (Device.IsInvokeRequired)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public event EventHandler<TouchCompletedEventArgs> Completed
remove => weakEventManager.RemoveEventHandler(value);
}

public event EventHandler<LongPressCompletedEventArgs> LongPressCompleted
{
add => weakEventManager.AddEventHandler(value);
remove => weakEventManager.RemoveEventHandler(value);
}

public static readonly BindableProperty IsAvailableProperty = BindableProperty.CreateAttached(
nameof(IsAvailable),
typeof(bool),
Expand Down Expand Up @@ -1156,6 +1162,9 @@ internal void RaiseHoverStatusChanged()
internal void RaiseCompleted()
=> weakEventManager.RaiseEvent(Element, new TouchCompletedEventArgs(CommandParameter), nameof(Completed));

internal void RaiseLongPressCompleted()
=> weakEventManager.RaiseEvent(Element, new LongPressCompletedEventArgs(LongPressCommandParameter ?? CommandParameter), nameof(LongPressCompleted));

internal void ForceUpdateState(bool animated = true)
{
if (Element == null)
Expand Down