├── .watchmanconfig ├── app.json ├── .babelrc ├── App.js ├── App.test.js ├── .gitignore ├── .eslintrc.js ├── src ├── Line.js ├── DashLine.js ├── Circle.js ├── Fan.js ├── FillRect.js ├── RadialGradientView.js ├── ArtText.js ├── Group.js ├── TransformView.js ├── LinearGradientView.js ├── index.js └── Wedge.js ├── package.json ├── .flowconfig └── README.md /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "expo": { 3 | "sdkVersion": "25.0.0" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["babel-preset-expo"], 3 | "env": { 4 | "development": { 5 | "plugins": ["transform-react-jsx-source"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Home from './src' 4 | 5 | export default class App extends React.Component { 6 | render() { 7 | return ( 8 | 9 | ); 10 | } 11 | } -------------------------------------------------------------------------------- /App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import App from './App'; 3 | 4 | import renderer from 'react-test-renderer'; 5 | 6 | it('renders without crashing', () => { 7 | const rendered = renderer.create().toJSON(); 8 | expect(rendered).toBeTruthy(); 9 | }); 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # expo 4 | .expo/ 5 | .idea/ 6 | 7 | # dependencies 8 | /node_modules 9 | 10 | # misc 11 | .env.local 12 | .env.development.local 13 | .env.test.local 14 | .env.production.local 15 | 16 | npm-debug.log* 17 | yarn-debug.log* 18 | yarn-error.log* 19 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "node": true, 4 | "es6": true 5 | }, 6 | "extends": "eslint:recommended", 7 | "parserOptions": { 8 | "ecmaFeatures": { 9 | "experimentalObjectRestSpread": true, 10 | "jsx": true 11 | }, 12 | "sourceType": "module" 13 | }, 14 | "plugins": [ 15 | "react" 16 | ], 17 | "rules": { 18 | "indent": [ 19 | "error", 20 | 4 21 | ], 22 | "linebreak-style": [ 23 | "error", 24 | "unix" 25 | ], 26 | "quotes": [ 27 | "error", 28 | "single" 29 | ], 30 | "semi": [ 31 | "error", 32 | "always" 33 | ] 34 | } 35 | }; -------------------------------------------------------------------------------- /src/Line.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | export default class Line extends React.Component{ 9 | 10 | static navigationOptions = { 11 | title: 'Line', 12 | }; 13 | 14 | render(){ 15 | 16 | const path = ART.Path(); 17 | path.moveTo(1,1); //将起始点移动到(1,1) 默认(0,0) 18 | path.lineTo(300,1); //连线到目标点(300,1) 19 | 20 | return( 21 | 22 | 23 | 24 | 25 | 26 | ) 27 | } 28 | } 29 | 30 | const styles = StyleSheet.create({ 31 | container: { 32 | flex: 1, 33 | backgroundColor: '#fff', 34 | alignItems: 'center', 35 | justifyContent: 'center', 36 | }, 37 | }); -------------------------------------------------------------------------------- /src/DashLine.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | const {Surface, Shape, Path} = ART; 9 | 10 | export default class DashLine extends React.Component{ 11 | 12 | static navigationOptions = { 13 | title: 'DashLine', 14 | }; 15 | 16 | render(){ 17 | 18 | const path = Path() 19 | .moveTo(1,1) 20 | .lineTo(300,1); 21 | 22 | return( 23 | 24 | 25 | 26 | 27 | 28 | ) 29 | } 30 | } 31 | 32 | const styles = StyleSheet.create({ 33 | container: { 34 | flex: 1, 35 | backgroundColor: '#fff', 36 | alignItems: 'center', 37 | justifyContent: 'center', 38 | }, 39 | }); -------------------------------------------------------------------------------- /src/Circle.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | const {Surface, Shape, Path} = ART; 9 | 10 | export default class Circle extends React.Component{ 11 | 12 | static navigationOptions = { 13 | title: 'Circle', 14 | }; 15 | 16 | render(){ 17 | 18 | const path = new Path() 19 | .moveTo(50,1) 20 | .arc(0,99,25) 21 | .arc(0,-99,25) 22 | .close(); 23 | 24 | 25 | return( 26 | 27 | 28 | 29 | 30 | 31 | ) 32 | } 33 | } 34 | 35 | const styles = StyleSheet.create({ 36 | container: { 37 | flex: 1, 38 | backgroundColor: '#fff', 39 | alignItems: 'center', 40 | justifyContent: 'center', 41 | }, 42 | }); -------------------------------------------------------------------------------- /src/Fan.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | const {Surface} = ART; 9 | import Wedge from './Wedge' 10 | 11 | export default class Fan extends React.Component{ 12 | 13 | static navigationOptions = { 14 | title: 'Fan', 15 | }; 16 | 17 | render(){ 18 | 19 | return( 20 | 21 | 22 | 29 | 30 | 31 | 32 | ) 33 | } 34 | } 35 | 36 | const styles = StyleSheet.create({ 37 | container: { 38 | flex: 1, 39 | backgroundColor: '#fff', 40 | alignItems: 'center', 41 | justifyContent: 'center', 42 | }, 43 | }); -------------------------------------------------------------------------------- /src/FillRect.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | const {Surface, Shape, Path} = ART; 9 | 10 | export default class FillRect extends React.Component{ 11 | 12 | static navigationOptions = { 13 | title: 'FillRect', 14 | }; 15 | 16 | render(){ 17 | 18 | const path = new Path() 19 | .moveTo(1,1) 20 | .lineTo(1,99) 21 | .lineTo(99,99) 22 | .lineTo(99,1) 23 | .close(); 24 | 25 | return( 26 | 27 | 28 | 29 | 30 | 31 | ) 32 | } 33 | } 34 | 35 | const styles = StyleSheet.create({ 36 | container: { 37 | flex: 1, 38 | backgroundColor: '#fff', 39 | alignItems: 'center', 40 | justifyContent: 'center', 41 | }, 42 | }); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "React-Native-ART-Sample", 3 | "version": "0.1.0", 4 | "private": true, 5 | "devDependencies": { 6 | "eslint": "^4.18.1", 7 | "eslint-plugin-react": "^7.7.0", 8 | "eslint-plugin-react-native": "^3.2.1", 9 | "jest-expo": "25.0.0", 10 | "react-native-scripts": "1.11.1", 11 | "react-test-renderer": "16.2.0" 12 | }, 13 | "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", 14 | "scripts": { 15 | "start": "react-native-scripts start", 16 | "eject": "react-native-scripts eject", 17 | "android": "react-native-scripts android", 18 | "ios": "react-native-scripts ios", 19 | "test": "node node_modules/jest/bin/jest.js", 20 | "lint": "eslint --ext .js ./src --fix" 21 | }, 22 | "jest": { 23 | "preset": "jest-expo" 24 | }, 25 | "dependencies": { 26 | "expo": "^25.0.0", 27 | "react": "16.2.0", 28 | "react-native": "0.52.0", 29 | "react-navigation": "^1.1.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/RadialGradientView.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | View, 4 | ART, StyleSheet 5 | } from 'react-native'; 6 | 7 | const {Surface, Shape, Path,RadialGradient} = ART; 8 | 9 | 10 | export default class RadialGradientView extends React.Component{ 11 | 12 | static navigationOptions = { 13 | title: 'Linear Gradient', 14 | }; 15 | 16 | render(){ 17 | 18 | const path = new Path() 19 | .moveTo(1,1) 20 | .lineTo(1,99) 21 | .lineTo(99,99) 22 | .lineTo(99,1) 23 | .close(); 24 | 25 | return( 26 | 27 | 28 | 29 | 30 | 31 | ) 32 | } 33 | } 34 | 35 | const styles = StyleSheet.create({ 36 | container: { 37 | flex: 1, 38 | backgroundColor: '#fff', 39 | alignItems: 'center', 40 | justifyContent: 'center', 41 | }, 42 | }); -------------------------------------------------------------------------------- /src/ArtText.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | const {Surface, Text, Path, LinearGradient} = ART; 9 | 10 | export default class ArtText extends React.Component{ 11 | 12 | static navigationOptions = { 13 | title: 'ArtText', 14 | }; 15 | 16 | render(){ 17 | 18 | return( 19 | 20 | 21 | 虚线文字 22 | 23 | 24 | 25 | 渐变文字 26 | 27 | 28 | ) 29 | } 30 | 31 | } 32 | 33 | const styles = StyleSheet.create({ 34 | container: { 35 | flex: 1, 36 | backgroundColor: '#fff', 37 | alignItems: 'center', 38 | justifyContent: 'center', 39 | }, 40 | }); -------------------------------------------------------------------------------- /src/Group.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet 6 | } from 'react-native' 7 | 8 | const {Surface, Shape,Text, Path,Group} = ART; 9 | 10 | export default class GroupView extends React.Component{ 11 | 12 | static navigationOptions = { 13 | title: 'Group', 14 | }; 15 | 16 | render(){ 17 | 18 | const pathRect = new Path() 19 | .moveTo(1,1) 20 | .lineTo(1,99) 21 | .lineTo(99,99) 22 | .lineTo(99,1) 23 | .close(); 24 | 25 | const pathCircle = new Path() 26 | .moveTo(50,1) 27 | .arc(0,99,25) 28 | .arc(0,-99,25) 29 | .close(); 30 | 31 | const pathText = new Path() 32 | .moveTo(40,5) 33 | .lineTo(40,99); 34 | 35 | 36 | return( 37 | 38 | 39 | 40 | 41 | 42 | Swipe 43 | 44 | 45 | 46 | ) 47 | } 48 | } 49 | 50 | const styles = StyleSheet.create({ 51 | container: { 52 | flex: 1, 53 | backgroundColor: '#fff', 54 | alignItems: 'center', 55 | justifyContent: 'center', 56 | }, 57 | }); -------------------------------------------------------------------------------- /src/TransformView.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { 3 | View, 4 | ART, 5 | StyleSheet, 6 | Button 7 | } from 'react-native' 8 | 9 | const {Surface,Transform,Shape,Path} = ART; 10 | 11 | export default class TransformView extends React.Component{ 12 | 13 | static navigationOptions = { 14 | title: 'Transform', 15 | }; 16 | 17 | 18 | // 构造 19 | constructor(props) { 20 | super(props); 21 | // 初始状态 22 | this.state = { 23 | rotation : 0 24 | }; 25 | } 26 | 27 | render(){ 28 | const path = new Path() 29 | .moveTo(1,1) 30 | .lineTo(1,99) 31 | .lineTo(99,99) 32 | .lineTo(99,1) 33 | .close(); 34 | 35 | const RING_TWO_ROTATE = new Transform().translate(50.000000, 89.000000).rotate(-240.000000).translate(-84.000000, -89.000000); 36 | 37 | return( 38 | 39 | 40 | 41 | 42 | 43 | 44 |