/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
ScrollView,
PixelRatio,
TouchableHighlight,
TouchableOpacity,
Animated,
Easing
} from 'react-native';
import {
Svg,
Circle,
Line
} from 'react-native-art-svg';
import * as examples from './examples';
import Modal from 'react-native-root-modal';
const hairline = 1 / PixelRatio.get();
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
paddingTop: 20,
alignItems: 'center',
overflow: 'hidden'
},
content: {
alignSelf: 'stretch',
alignItems: 'center',
borderTopWidth: hairline,
borderTopColor: '#ccc',
borderBottomWidth: hairline,
borderBottomColor: '#ccc'
},
welcome: {
padding: 10,
color: '#f60',
fontSize: 18,
fontWeight: 'bold'
},
link: {
marginHorizontal: 10,
alignSelf: 'stretch'
},
title: {
marginLeft: 10
},
cell: {
height: 30,
paddingHorizontal: 10,
alignSelf: 'stretch',
alignItems: 'center',
flexDirection: 'row',
borderTopWidth: hairline,
borderTopColor: '#ccc',
marginTop: -hairline,
backgroundColor: 'transparent'
},
modal: {
top: 0,
right: 0,
bottom: 0,
left: 0,
backgroundColor: 'rgba(0, 0, 0, 0.2)'
},
close: {
position: 'absolute',
right: 20,
top: 40
},
scroll: {
position: 'absolute',
top: 30,
right: 10,
bottom: 20,
left: 10,
backgroundColor: '#fff'
},
scrollContent: {
borderTopWidth: hairline,
borderTopColor: '#ccc'
},
example: {
paddingVertical: 25,
alignSelf: 'stretch',
alignItems: 'center',
borderBottomWidth: hairline,
borderBottomColor: '#ccc'
},
sampleTitle: {
marginHorizontal: 15,
fontSize: 16,
color: '#666'
}
});
const names = ['Svg', 'Stroking', 'Path', 'Line', 'Rect', 'Polygon', 'Polyline', 'Circle', 'Ellipse', 'G', 'Text', 'Use', 'Gradients'];
class ArtSvgExample extends Component {
constructor() {
super(...arguments);
this.state = {
modal: false,
scale: new Animated.Value(0)
};
}
getSamples = (samples) => {
return samples.map((Sample, i) =>
{Sample.title}
);
};
show = (name) => {
if (this.state.modal) {
return;
}
let example = examples[name];
if (example) {
let samples = example.samples;
this.state.scale.setValue(0);
Animated.spring(this.state.scale, {
toValue: 1
}).start();
this.setState({
modal: true,
content:
{this.getSamples(samples)}
});
}
};
hide = () => {
this.state.scale.setValue(1);
Animated.timing(this.state.scale, {
toValue: 0,
easing: Easing.in(Easing.back(2))
}).start(({finished}) => finished && this.setState({
modal: false,
content: null
}));
};
getExamples = () => {
return names.map(name => {
var icon;
let example = examples[name];
if (example) {
icon = example.icon;
}
return this.show(name)}
>
{icon}
{name}
});
};
render() {
return
{this.state.content}
SVG by ART!
{this.getExamples()}
;
}
}
AppRegistry.registerComponent('ArtSvgExample', () => ArtSvgExample);