robinmanuelthiel / swipecards

Tinder-like swipe control for Xamarin.Forms
MIT License
129 stars 24 forks source link

Button click event not working #9

Open esolzDotnet opened 6 years ago

esolzDotnet commented 6 years ago

I have placed a button inside the card.But the click event is not working. what to do?

robinmanuelthiel commented 6 years ago

Yeah, currently the control sucks all touch inputs to make the swiping work. It's quite dirty. You can take a look at it in the CardStackView.xaml.

<?xml version="1.0" encoding="UTF-8" ?>
<ContentView
    x:Class="SwipeCards.Controls.CardStackView"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    Padding="20">

    <Grid>
        <RelativeLayout x:Name="CardStack" />

        <!--
            HACK: The TouchObserber is a terrible hack, so let me explain the problem
            On Android, Child elements observe touch events and don't pass them to the sender.
            So when attaching the PanGestureRecognizer to the parent view, it won't fire, when dragging the child.
            To fix this temporary, I added this transparent view on top of all others and attach the PanGestureRecognizer to it.
            A custom view renderer with an "IgnoreTouch" property might be a smarter solution...
        -->
        <BoxView x:Name="TouchObserber" BackgroundColor="Transparent" />
    </Grid>
</ContentView>

It's the only way to get it running on Android currently. Do you have any idea?

DottorPagliaccius commented 6 years ago

Do you have any idea?

I do, just remove the BoxView. I have no problem at all on Android, the only issue I had is when I added buttons inside the card, sometimes tap and pan gesture confilct due to a bug in android.

If you want have a look at my fork https://github.com/DottorPagliaccius/swipecards