1.0.20 • Published 2 years ago

react-native-node-view v1.0.20

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Screenshots

How To Use

Install

npm i react-native-node-view

Import

import NodeView from 'react-native-node-view';

Examples

Simple

<NodeView
	nodesGroups={[
		{ nodes: [{ id: '1', lineTo: ['2', '3'], onPress: id => console.log(id) }] },
		{ nodes: [{ id: '2' }, { id: '3' }] },
	]}
/>

Inside view

<View style={{ width: 300, height: 300, alignSelf: 'center', borderWidth: 1, borderRadius: 10, borderColor: 'gray' }}>
	<NodeView
		nodesGroups={[
			{ nodes: [{ id: '1', lineTo: ['2', '3'], onPress: id => console.log(id) }] },
			{ nodes: [{ id: '2' }, { id: '3' }] },
		]}
	/>
</View>

With delete operation

const [nodesGroups, setNodesGroups] = useState([
	{
		nodes: [{ id: '1', lineTo: ['2', '3'], onPress: (id: string) => console.log(id) }],
	},
	{
		nodes: [{ id: '2' }, { id: '3' }],
	},
]);

return (
	<View
		style={{
			flex: 1,
			justifyContent: 'center',
			backgroundColor: 'white',
		}}>
		<NodeView
			enablePan={true}
			enableZoom={true}
			containerStyle={{ borderWidth: 0 }}
			onDeleteNode={(id, oldState, newState) => setNodesGroups(newState)}
			nodesGroups={nodesGroups}
		/>
	</View>
);

API

nodesGroups Object

Prop NameDescriptionTyperequired
nodesGroupsList of Node objectsArray true
containerStyleStyle of the node view containerViewStylefalse
lineStyleStyle for each line of the node viewLinePropsfalse
onDeleteNodeOn deleting node(id: string, oldState: Array, newState: Array) => voidfalse
onLongPressListener for node long press(id: string) => voidfalse
maxZoomMax zoomnumber1.5
minZoomMin zoomnumber0.5
maxPanMax movement for pan gesturenumber100
minPanMin movement for pan gesturenumber-100
enablePanEnable pan gesturebooleanfalse
enableZoomEnable pinch gesturebooleanfalse
deleteNodeViewStyleDelete node container styleViewStylefalse
deleteNodeLineStyleDelete node line container styleViewStylefalse
enableDeleteModeStyle for each line of the node viewbooleantrue

Node Object

Prop NameDescriptionTyperequired
idThe id of the nodestringtrue
lineToList of all the lines to draw to each node by idlistfalse
childCustom component to useJSX.Elementfalse
onPressOn press listener(id: string) => voidfalse

Supported

Tested on Android and IOS with expo sdk 41

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.11

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.9

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago