Skip to content

Commit

Permalink
Added tap listeners (command and event)
Browse files Browse the repository at this point in the history
bump 1.0.5
  • Loading branch information
AndreiMisiukevich committed Mar 24, 2019
1 parent f18f6ef commit ec12cf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ExpandableView.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>ExpandableView</id>
<version>1.0.4</version>
<version>1.0.5</version>
<title>ExpandableView</title>
<authors>Andrei Misiukevich</authors>
<owners>Andrei Misiukevich</owners>
Expand Down
13 changes: 13 additions & 0 deletions ExpandableView/ExpandableView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Xamarin.Forms;
using System.Windows.Input;

namespace Expandable
{
Expand All @@ -9,6 +10,8 @@ public class ExpandableView : StackLayout

public event EventHandler<StatusChangedEventArgs> 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);
Expand Down Expand Up @@ -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;
Expand All @@ -59,6 +64,8 @@ public ExpandableView()
{
Command = new Command(() =>
{
Command?.Execute(null);
Tapped?.Invoke();
if (!IsTouchToExpandEnabled)
{
return;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ec12cf7

Please sign in to comment.