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

TouchEffect (Press & Hover visual handling) + LongPress #566

Merged
merged 6 commits into from
Nov 27, 2020

Conversation

AndreiMisiukevich
Copy link
Contributor

@AndreiMisiukevich AndreiMisiukevich commented Nov 18, 2020

Description of Change

Moving TouchEffect from https://github.com/AndreiMisiukevich/TouchEffect to XCT

Nov-25-2020 16-32-34

Bugs Fixed

API Changes

https://github.com/AndreiMisiukevich/TouchEffect/blob/master/README.md

Behavioral Changes

None

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Updated documentation

Copy link
Contributor

@pictos pictos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dude, this is huge work, well done! I didn't run the code, since it's a Draft PR, but I did a look into the code and suggest some modifications. Please let me know what do you think.

@XamarinCommunityToolkitBot

A new build for this PR has been completed. As a result a NuGet has been created which allows you to verify this fix or try out the new feature! Download here

@AndreiMisiukevich AndreiMisiukevich marked this pull request as ready for review November 19, 2020 01:03
@jfversluis
Copy link
Member

Haha wow that bot has been crazy here 😆 sorry about that!

@jfversluis
Copy link
Member

C'monnnnn GitHub! Not all those delete entries. Then I might as well just left them there 🤦

@XamarinCommunityToolkitBot

A new build for this PR has been completed. As a result a NuGet has been created which allows you to verify this fix or try out the new feature! Download here

@pictos
Copy link
Contributor

pictos commented Nov 21, 2020

@AndreiMisiukevich we merged a huge change, can you solve the conflicts?

@XamarinCommunityToolkitBot

A new build for this PR has been completed. As a result a NuGet has been created which allows you to verify this fix or try out the new feature! Download here

@XamarinCommunityToolkitBot

A new build for this PR has been completed. As a result a NuGet has been created which allows you to verify this fix or try out the new feature! Download here

@XamarinCommunityToolkitBot

A new build for this PR has been completed. As a result a NuGet has been created which allows you to verify this fix or try out the new feature! Download here

@XamarinCommunityToolkitBot

A new build for this PR has been completed. As a result a NuGet has been created which allows you to verify this fix or try out the new feature! Download here

@SagarPanwala
Copy link

@AndreiMisiukevich I'm not criticizing, I wanted this from long time, but is this good in terms of performance as well?

@AndreiMisiukevich
Copy link
Contributor Author

@AndreiMisiukevich I'm not criticizing, I wanted this from long time, but is this good in terms of performance as well?

I think it's not bad (I have never received any complaints) :)

@sethom
Copy link

sethom commented Jan 14, 2021

Love this project. Great work! Quick question.. I'm using an old version of TouchView (4.0.21). I'm using the Completed event to detect when the touch stops. Is there an event that fires now when the view is first touched or some way for me to do that?

@AndreiMisiukevich
Copy link
Contributor Author

Hello, yes it exists) You still can add TouchEffect as a regular effect and use its Completed event.

@sethom
Copy link

sethom commented Jan 14, 2021

Andrei.. The completed event fires at the end of the touch. How do I detected when touch starts? There's not "Started" or "Pressed" counterpart to Completed event that I am able to find.

@AndreiMisiukevich
Copy link
Contributor Author

Andrei.. The completed event fires at the end of the touch. How do I detected when touch starts? There's not "Started" or "Pressed" counterpart to Completed event that I am able to find.

You can use StateChanged event e.g.

@sethom
Copy link

sethom commented Jan 14, 2021

Thanks..

@haavamoa
Copy link

haavamoa commented Mar 4, 2021

Really nice work❤ I have a question: When you add a touch effect on a item of a list, the item's touch effect reacts when I scroll the list. This feels unnatural as I didn't really mean to "tap" it, but I tapped it to be able to scroll. Is there a way to turn this off somehow? 🤔

@AndreiMisiukevich
Copy link
Contributor Author

@haavamoa I can imagine only one possible solution. Add a new property that will manage delay before animation start...

@haavamoa
Copy link

haavamoa commented Mar 4, 2021

@haavamoa I can imagine only one possible solution. Add a new property that will manage delay before animation start...

Hm, yeah. But won't that also delay the tap when I want to tap it and not scroll? 🤔

@AndreiMisiukevich
Copy link
Contributor Author

@haavamoa I can imagine only one possible solution. Add a new property that will manage delay before animation start...

Hm, yeah. But won't that also delay the tap when I want to tap it and not scroll? 🤔

reasonable)

Well, I think that's impossible (

@haavamoa
Copy link

haavamoa commented Mar 6, 2021

@haavamoa I can imagine only one possible solution. Add a new property that will manage delay before animation start...

Hm, yeah. But won't that also delay the tap when I want to tap it and not scroll? 🤔

reasonable)

Well, I think that's impossible (

Maybe subscribe to scrolled event and detach / disable the touch effect for the items only when it's scrolled would work. 🤔

@AlleSchonWeg
Copy link

Hi @haavamoa , @AndreiMisiukevich
is it possible to solve the touch on scrolling issue with a GestureDetector (https://stackoverflow.com/questions/24202671/scroll-listview-in-ontouch-method) ?
So, if scrolling is detected then cancel the touch effect. 🤔

@AndreiMisiukevich
Copy link
Contributor Author

Hey @AlleSchonWeg
Set xct:TouchEffect.DisallowTouchThreshold="1" or maybe 5

@AlleSchonWeg
Copy link

Hi @AndreiMisiukevich,

tested the setting, but nothing changed:

<BindableLayout.ItemTemplate>
								<DataTemplate>
									<frames:myFrame xct:TouchEffect.DisallowTouchThreshold="1" xct:TouchEffect.NativeAnimation="True">
										<frames:myFrame.GestureRecognizers>
											<TapGestureRecognizer x:DataType="viewmodels:model"
																  Tapped="abcde"
																  CommandParameter="{Binding .}" />
									
										</frames:myFrame.GestureRecognizers>
									</frames:myFrame>
								</DataTemplate>
							</BindableLayout.ItemTemplate>

@AndreiMisiukevich
Copy link
Contributor Author

@AlleSchonWeg hm, I guess you should fill a ticket.
Do you have an idea how to fix that?

@AlleSchonWeg
Copy link

AlleSchonWeg commented May 4, 2021

@AndreiMisiukevich
For testing i created a
gestureDetector = new GestureDetector(new YourGestureDetector()); in the OnAttached method like the StackOverflow sample link above.
and then in void OnTouch(object? sender, AView.TouchEventArgs e) i tested the event:

			if (gestureDetector.OnTouchEvent(e.Event) && e.Event?.ActionMasked != MotionEventActions.Down)
			{
				//you have detected the gesture you were looking for
				//Do something about it
				System.Diagnostics.Debug.WriteLine("sdsadad");
				return;
				//return true; //because you want to notify that you handled the event so it won't propogare further (optional, depending on what behavior you want)   
			}
	internal class YourGestureDetector : GestureDetector.SimpleOnGestureListener
	{
		//always return true in OnDown
		public override bool OnDown(MotionEvent? e)
		{
			return true;
		}

		public override bool OnScroll(MotionEvent? e1, MotionEvent? e2, float distanceX, float distanceY)
		{
			return true;
		}

		public override bool OnFling(MotionEvent? e1, MotionEvent? e2, float velocityX, float velocityY)
		{
			return true;
		}
	}

If i use my test scrollview:

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="100" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="AUTO" />
                </Grid.ColumnDefinitions>
                <ScrollView Orientation="Both"
                            Grid.Column="0"
                            Grid.Row="0">
                    <StackLayout Orientation="Horizontal"
                                 Spacing="10">
                        <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                        <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                        <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                        <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                        <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                        <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                                         <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                                         <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                                         <Label Text="TITLE"
                               TextColor="Black"
                               xct:TouchEffect.NativeAnimation="True"
                               FontSize="Large" />
                    </StackLayout>
                </ScrollView>
            </Grid>

The scroll gesture is detected. But i have no plan, how your effect works. Perhaps you could take my sample and modify it for your effect?

@AndreiMisiukevich
Copy link
Contributor Author

Can you raise a separate ticket with the described problem @AlleSchonWeg ?

@AlleSchonWeg
Copy link

@AndreiMisiukevich
Done: #1261

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Down and Up gesture Long tap gesture behaviour [Enhancement] TouchEffect