Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add VictoryNativeBrushLine component #2077

Merged
merged 3 commits into from
Feb 14, 2022

Conversation

zibs
Copy link
Contributor

@zibs zibs commented Jan 29, 2022

This brings VictoryBrushLine parity to victory-native.

The implementation is a combination of techniques used in victory-native’s VictoryContainer, Portal, and the standard way of bringing components to RN.

Ultimately we still wrap the component with wrapCoreComponent, but before doing so we:

  1. Extend the the component and override its render method so that it renders a valid react-native-svg component (much like how Portal is done).
  2. Remap the relevant static defaultEvents to their native equivalents e.g onTouchStart -> onMouseDown (I feel like I'm kind of hacking this, and there's a better way to do so?)
  3. Create a set of PanResponders like in the native VictoryContainer that will respond to the touch start/move/end events that are attached to each brush line.

Adds typings/smoke-test
Adds docs/screen to RN demo app

Resolves #2072

This actually requires #2071 to function correctly on Android due to the touch events issue.

Screen.Recording.2022-01-28.at.4.56.29.PM.mov
Screen.Recording.2022-01-28.at.4.57.13.PM.mov

nit - I think this just got carried over during a copy/paste.
This brings `VictoryBrushLine` parity to `victory-native`.

The implementation is a combination of techniques used in `victory-native`’s `VictoryContainer`, `Portal`, and the standard way of bringing components to RN.

Ultimately we still wrap the component with `wrapCoreComponent`, but before doing so we:

1. Extend the the component and override its render method so that it renders a valid `react-native-svg` component (much like how `Portal` is done).
2. Remap the relevant `static defaultEvents` to their native equivalents e.g `onTouchStart -> onMouseDown` (I feel like I'm kind of hacking this, and there's a better way to do so?)
3. Create a set of `PanResponders` like in the native `VictoryContainer` that will respond to the touch start/move/end events that are attached to each brush line.

Adds typings/smoke-test

Docs to come in future commit
@zibs zibs marked this pull request as ready for review January 31, 2022 20:34
This adds a `VictoryBrushLine` examples screen to the native app. It copies/converts the existing web examples into native.

(also fixes prettier error that caused CI to fail in previous commit)

Update brush-line-screen.tsx
@zibs zibs force-pushed the zibs/native-victory-brush-line branch from 598abc7 to 0f86f1f Compare February 1, 2022 19:01
@becca-bailey becca-bailey self-requested a review February 2, 2022 19:02
Copy link
Contributor

@becca-bailey becca-bailey left a comment

Choose a reason for hiding this comment

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

This looks good to me! I think the only comment I have is that eventually we want to move away from extending classes for victory-native components, because this makes it harder to change the base components. In my perfect world, we would use composition to pass in alternate props for victory-native rather than extending a class. HOWEVER, this is outside the scope for this change, and we can continue using this syntax until we're able to prioritize updating this pattern across the board.

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.

VictoryBrushLine in React Native
2 participants