From ec12cf771864104d0c96433b66a179b3a7dca8cb Mon Sep 17 00:00:00 2001 From: Andrei Misiukevich Date: Sun, 24 Mar 2019 03:37:55 +0300 Subject: [PATCH] Added tap listeners (command and event) bump 1.0.5 --- ExpandableView.nuspec | 2 +- ExpandableView/ExpandableView.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ExpandableView.nuspec b/ExpandableView.nuspec index d6022b6..2237c35 100644 --- a/ExpandableView.nuspec +++ b/ExpandableView.nuspec @@ -2,7 +2,7 @@ ExpandableView - 1.0.4 + 1.0.5 ExpandableView Andrei Misiukevich Andrei Misiukevich diff --git a/ExpandableView/ExpandableView.cs b/ExpandableView/ExpandableView.cs index 684ec6f..052bd18 100644 --- a/ExpandableView/ExpandableView.cs +++ b/ExpandableView/ExpandableView.cs @@ -1,5 +1,6 @@ using System; using Xamarin.Forms; +using System.Windows.Input; namespace Expandable { @@ -9,6 +10,8 @@ public class ExpandableView : StackLayout public event EventHandler StatusChanged; + public event Action Tapped; + public static readonly BindableProperty PrimaryViewProperty = BindableProperty.Create(nameof(PrimaryView), typeof(View), typeof(ExpandableView), null, propertyChanged: (bindable, oldValue, newValue) => { (bindable as ExpandableView).SetPrimaryView(oldValue as View); @@ -46,6 +49,8 @@ public class ExpandableView : StackLayout public static readonly BindableProperty StatusProperty = BindableProperty.Create(nameof(Status), typeof(ExpandStatus), typeof(ExpandableView), default(ExpandStatus), BindingMode.OneWayToSource); + public static readonly BindableProperty CommandProperty = BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(ExpandableView), default(ICommand)); + private readonly TapGestureRecognizer _defaultTapGesture; private bool _shouldIgnoreAnimation; private double _lastVisibleHeight = -1; @@ -59,6 +64,8 @@ public ExpandableView() { Command = new Command(() => { + Command?.Execute(null); + Tapped?.Invoke(); if (!IsTouchToExpandEnabled) { return; @@ -134,6 +141,12 @@ public ExpandStatus Status set => SetValue(StatusProperty, value); } + public ICommand Command + { + get => GetValue(CommandProperty) as ICommand; + set => SetValue(CommandProperty, value); + } + public View SecondaryView { get => _secondaryView;