From 1e0107f9eaf0f7d2b4aeaa046bac9751f2f06208 Mon Sep 17 00:00:00 2001 From: Horcrux Date: Sat, 11 Jun 2016 00:50:25 +0800 Subject: [PATCH] Add touchable examples --- Example/examples.js | 4 +- Example/examples/TouchEvents.js | 92 +++++++++++++++++++++++++++++++++ Example/main.js | 2 +- 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 Example/examples/TouchEvents.js diff --git a/Example/examples.js b/Example/examples.js index e8f46b19..da57257a 100644 --- a/Example/examples.js +++ b/Example/examples.js @@ -14,6 +14,7 @@ import * as Symbol from './examples/Symbol'; import * as Gradients from './examples/Gradients'; import * as Clipping from './examples/Clipping'; import * as Image from './examples/Image'; +import * as TouchEvents from './examples/TouchEvents'; export { Svg, @@ -31,5 +32,6 @@ export { Symbol, Gradients, Clipping, - Image + Image, + TouchEvents }; diff --git a/Example/examples/TouchEvents.js b/Example/examples/TouchEvents.js new file mode 100644 index 00000000..049e1fd4 --- /dev/null +++ b/Example/examples/TouchEvents.js @@ -0,0 +1,92 @@ +import React, { + Component +} from 'react'; + +import Svg, { + Circle, + Path, + Rect +} from 'react-native-svg'; + +class PressExample extends Component { + static title = 'Press on the red circle and long press on rectangle to trigger the events'; + + render () { + return + alert('Press on Circle')} + /> + alert('Long press on Rect')} + /> + + ; + } +} + +class HoverExample extends Component { + static title = 'Hover the svg path'; + constructor () { + super(...arguments); + this.state = { + hover: false + }; + } + + toggle = () => { + this.setState({hover: !this.state.hover}); + }; + + render () { + return + + ; + } + +} + +const icon = + + +; + +const samples = [ + PressExample, + HoverExample +]; + +export { + icon, + samples +}; diff --git a/Example/main.js b/Example/main.js index 73872541..60333ec3 100644 --- a/Example/main.js +++ b/Example/main.js @@ -110,7 +110,7 @@ const styles = StyleSheet.create({ } }); -const names = ['Svg', 'Stroking', 'Path', 'Line', 'Rect', 'Polygon', 'Polyline', 'Circle', 'Ellipse', 'G', 'Text', 'Use', 'Symbol', 'Gradients', 'Clipping', 'Image']; +const names = ['Svg', 'Stroking', 'Path', 'Line', 'Rect', 'Polygon', 'Polyline', 'Circle', 'Ellipse', 'G', 'Text', 'Use', 'Symbol', 'Gradients', 'Clipping', 'Image', 'TouchEvents']; class SvgExample extends Component { constructor() {