Skip to content

iOS + Android: Unify onDrag snap API#196

Merged
rotemmiz merged 9 commits into
wix-incubator:masterfrom
mkuczera:FIX-fix-target-snap-id
Nov 4, 2018
Merged

iOS + Android: Unify onDrag snap API#196
rotemmiz merged 9 commits into
wix-incubator:masterfrom
mkuczera:FIX-fix-target-snap-id

Conversation

@mkuczera

Copy link
Copy Markdown
Contributor

Fixes Issue #165
Update PROPS Readme
Set proper intent

Michael Kuczera added 2 commits March 23, 2018 17:56
@mkuczera

Copy link
Copy Markdown
Contributor Author

@rotemmiz this would be the first PR regarding the splitting of the huge one. Can you verify?

@rotemmiz

Copy link
Copy Markdown
Contributor

There's still much noise in this PR, lots of auto formatting. It's very hard to track changes and review this way 😣

@mkuczera

Copy link
Copy Markdown
Contributor Author

check. removed the noise. sorry, VSCode was messing up, even on the .md files

@mkuczera

mkuczera commented Apr 3, 2018

Copy link
Copy Markdown
Contributor Author

any update @rotemmiz ?

@rotemmiz rotemmiz changed the title Fix fix target snap iOS: Fix target snap Apr 3, 2018
Comment thread lib/ios/Interactable/InteractableView.m Outdated
state ?: [NSNull null], @"state",
deltaFromOrigin.x ?: 0, @"x",
deltaFromOrigin.y ?: 0, @"y",
targetSnapPointId ?: [NSNull null], @"targetSnapPointId",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, assuming that the user hasn't provided an id, end returns null instead of an empty string ? was even able to return an empty string before or did it crash ?

@mkuczera mkuczera Apr 4, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The crash was based on the circumstance that an Interactable View got no SnapPoints. iOS was crashing then (Getting -id- of not present -point- Object)
I´m glad for discussion if we should either just fix the crash and provide an empty string if no id is provided, or just adapt the "not present" value.
Also i just looked up that i didn´t check Android Start Event. There we are sending an empty string on Start, but an undefined value on end if no -id- is provided.

So we can adapt the previous behaviour and just send out on Android also the empty string
OR
Send out on Start an undefined value, on End undefined if not present or String if present on both platforms

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most important is that we align the expected behavior on both platforms. If the Android behavior is working as expected let's just copy it on iOS, empty string is falsy in JS anyway.

@mkuczera

mkuczera commented Apr 4, 2018

Copy link
Copy Markdown
Contributor Author

Okay, i just pushed the changes. The Issue #165 was also appearing on android.
So every event is now returning an empty string if no id is provided. Also if no snapPoints are set.
Before Android was returning null for targetSnapPointId if nothing was provided. Changed this to empty string.
Please be aware: Even when no SnapPoints are provided, we are returning a start and end event on drag with empty string and no usable x and y value. But maybe we can just clear this up after this PR

@mkuczera mkuczera mentioned this pull request Apr 9, 2018
@mkuczera

Copy link
Copy Markdown
Contributor Author

@rotemmiz just a ping, sorry for disturbing you. want to proceed, but the next PR`s would be based on unify and the detox test is based on the snapPoint fix

@mkuczera

Copy link
Copy Markdown
Contributor Author

resolved merge conflicts @rotemmiz

</View>
<Interactable.View
snapPoints={[{x: -140, y: -250}, {x: 140, y: -250}, {x: -140, y: 250}, {x: 140, y: 250}]}
snapPoints={[{x: -140, y: -250, id: 'testId'}, {x: 140, y: -250}, {x: -140, y: 250}, {x: 140, y: 250}]}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This project is really hard to test , that's one of the reasons we are having hard time with maintenance.
How did you test that id really works as expected on both platforms?
Kinda unrelated to this PR:
We may need to define some sort of way to test the API. Maybe with a special test app (in this repo) that asserts on the API behavior in runtime. We can drive it using Detox. It won't be able to "feel" the correctness of the physics, but at least it will have some sort of coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, yap, i experienced the same. Testing the results is really depending on the feeling of the interaction. But at least the callbacks are testable pretty good. I began with testing (merged manually this fix in the detox test branch) and also with the travis testing already.
For this purpose i enhanced the playground views. So in the onDrag example the following situations are tested:

  • TestId provided and visible
  • TestId not provided and element not visible
  • No SnapPoints provided and no crash

You can see the basic test implementations here:
https://github.com/mkuczera/react-native-interactable/commits/implement-tests

As i said: I would begin with the callbacks to be testable. Beside of that i´m currently setting up the travis enviroment also for android. For iOS it´s ready.

@mkuczera

Copy link
Copy Markdown
Contributor Author

hey, what´s the current status @rotemmiz @ButtersHub

@rotemmiz rotemmiz changed the title iOS: Fix target snap iOS + Android: Unify onDrag snap API May 3, 2018
@rotemmiz rotemmiz merged commit 438a8fa into wix-incubator:master Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants