1.0.10 • Published 4 years ago

react-native-flat-tree v1.0.10

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-native-flat-tree

flat-tree for react native

Install

yarn add react-native-flat-tree

Shortcuts

open

Usage

import FlatTree from 'react-native-flat-tree'
import Icon from "react-native-vector-icons/FontAwesome";
...
const treeData = [
	{
		name: 'root0', uuid: '0', children: [
			{name: 'child0', uuid: '00'},
			{
				name: 'child1', uuid: '010', children: []
			},
			{
				name: 'child2', uuid: '011', children: [
					{name: 'child20', uuid: '0110'},
					{name: 'child20', uuid: '0111'},
					{name: 'child20', uuid: '0112'},
				]
			},
		],
	},
	{
		name: 'root1', uuid: '1',
	},
];
for (let i = 0; i < 100; i++) {
	treeData[0].children[1].children.push({name: 'child1' + i, uuid: '0100_' + i},)
}

const listEmptyView = ({text = 'No Items'}) => {
	return (
		<View style={styles.emptyWrapper}>
			<Text style={styles.emptyText}>{text}</Text>
		</View>
	);
};

export default () => {
	return (
		<FlatTree data={treeData} itemStyle={styles.itemStyle}  style={styles.container}
		          renderItem={item => <Text style={{color: COLOR.textPrimary}}>{item.name}</Text>}
		          arrowRight={<Icon name="caret-right" color={COLOR.textPrimary}/>}
		          arrowDown={<Icon name="caret-down" color={COLOR.textPrimary}/>}
		          onPressItem={item => console.log(item.name)}
		          listEmptyView={listEmptyView}
		/>
	);
}
...

Props

proptyperequireddefault
dataArraytrue
styleanyfalse
onPressItem(item)=>voidfalse
renderItemreact-nodetrue
filter(item, index, data)=>booleanfalse
itemStyleanyfalse
arrowRightreact-nodefalse+
arrowDownreact-nodefalse-
listEmptyViewreact-nodefalsebuiltin
indentDistancenumberfalse15
childrenFieldstringfalse'children'
highlightCurrentbooleanfalsefalse
itemHighlightStyleanyfalse
1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago