Skip to content

Commit bf255b1

Browse files
committed
Move the code to root folder
1 parent 0adc996 commit bf255b1

File tree

20 files changed

+5287
-387
lines changed

20 files changed

+5287
-387
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react-native"]
3+
}

.eslintcache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"/Users/morant84/Work/react-native-nested-listview/example/index.android.js":{"size":178,"mtime":1506461733000,"hashOfConfig":"18q17kc","results":{"filePath":"/Users/morant84/Work/react-native-nested-listview/example/index.android.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}},"/Users/morant84/Work/react-native-nested-listview/example/index.ios.js":{"size":178,"mtime":1506461736000,"hashOfConfig":"18q17kc","results":{"filePath":"/Users/morant84/Work/react-native-nested-listview/example/index.ios.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}},"/Users/morant84/Work/react-native-nested-listview/example/ExampleApp.js":{"size":2151,"mtime":1507097693000,"hashOfConfig":"18q17kc","results":{"filePath":"/Users/morant84/Work/react-native-nested-listview/example/ExampleApp.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}},"/Users/morant84/Work/react-native-nested-listview/index.js":{"size":1963,"mtime":1507071227000,"hashOfConfig":"18q17kc","results":{"filePath":"/Users/morant84/Work/react-native-nested-listview/index.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}},"/Users/morant84/Work/react-native-nested-listview/index.test.js":{"size":3703,"mtime":1507012094000,"hashOfConfig":"18q17kc","results":{"filePath":"/Users/morant84/Work/react-native-nested-listview/index.test.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}},"/Users/morant84/Work/react-native-nested-listview/NodeView.js":{"size":1790,"mtime":1507071227000,"hashOfConfig":"18q17kc","results":{"filePath":"/Users/morant84/Work/react-native-nested-listview/NodeView.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}}}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flow-typed

.eslintrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"parser": "babel-eslint",
3+
"parserOptions": {
4+
"sourceType": "module",
5+
"ecmaFeatures": {
6+
"jsx": true
7+
}
8+
},
9+
"plugins": ["react", "react-native", "flowtype"],
10+
"extends": [
11+
"plugin:react/recommended",
12+
"plugin:react-native/all",
13+
"plugin:flowtype/recommended"
14+
],
15+
"rules": {
16+
"react-native/no-color-literals": 0
17+
}
18+
}

.flowconfig

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
11+
.*/node_modules/*
12+
13+
; Ignore duplicate module providers
14+
; For RN Apps installed via npm, "Libraries" folder is inside
15+
; "node_modules/react-native" but in the source repo it is in the root
16+
.*/Libraries/react-native/React.js
17+
.*/Libraries/react-native/ReactNative.js
18+
19+
[include]
20+
21+
[libs]
22+
node_modules/react-native/Libraries/react-native/react-native-interface.js
23+
node_modules/react-native/flow
24+
flow/
25+
flow-typed
26+
27+
[options]
28+
emoji=true
29+
30+
module.system=haste
31+
32+
munge_underscores=true
33+
34+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
35+
36+
suppress_type=$FlowIssue
37+
suppress_type=$FlowFixMe
38+
suppress_type=$FixMe
39+
40+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
41+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
42+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
43+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
44+
45+
unsafe.enable_getters_and_setters=true
46+
47+
[version]

NodeView.js

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,80 @@
11
/* @flow */
22

33
import React from 'react'
4-
import {TouchableOpacity, View} from 'react-native'
5-
6-
const NodeView = ({
7-
getChildren,
8-
node,
9-
renderNode,
10-
renderChildrenNode,
11-
onLayout,
12-
onNodePressed,
13-
}: {
14-
getChildren: Function,
15-
node: any,
16-
nodeStyle?: any,
17-
onLayout?: Function,
18-
onNodePressed: Function,
19-
renderNode: Function,
20-
renderChildrenNode: Function,
21-
}) => {
22-
const children = getChildren(node)
23-
24-
return (
25-
<View onLayout={onLayout}>
26-
<TouchableOpacity onPress={() => onNodePressed(node)}>
27-
{renderNode()}
28-
</TouchableOpacity>
29-
{node.opened && children
30-
? <View>
31-
{children.map(renderChildrenNode)}
32-
</View>
33-
: null}
34-
</View>
35-
)
4+
import {
5+
TouchableWithoutFeedback,
6+
View,
7+
FlatList,
8+
type Props,
9+
type State,
10+
} from 'react-native'
11+
12+
export type Node = {
13+
id: string,
14+
hidden: boolean,
15+
opened: boolean,
3616
}
3717

38-
export default NodeView
18+
export default class NodeView extends React.PureComponent<Props, State> {
19+
props: {
20+
generateIds: Function,
21+
getChildren: Function,
22+
getChildrenName: Function,
23+
node: Node,
24+
level: number,
25+
onNodePressed: Function,
26+
renderNode: Function,
27+
renderChildrenNode: Function,
28+
}
29+
30+
componentWillMount = () => {
31+
this.setState({
32+
node: this.props.node,
33+
})
34+
}
35+
36+
onNodePressed = () => {
37+
this.setState({
38+
node: {
39+
...this.state.node,
40+
opened: !this.state.node.opened,
41+
},
42+
})
43+
44+
this.props.onNodePressed(this.state.node)
45+
}
46+
47+
renderChildren = (item: Node, level: number) => {
48+
return (
49+
<NodeView
50+
getChildrenName={this.props.getChildrenName}
51+
node={item}
52+
level={level + 1}
53+
onNodePressed={this.props.onNodePressed}
54+
renderNode={this.props.renderNode}
55+
/>
56+
)
57+
}
58+
59+
render() {
60+
const rootChildrenName = this.props.getChildrenName(this.state.node)
61+
const rootChildren = this.state.node[rootChildrenName]
62+
63+
return (
64+
<View>
65+
{!this.state.node.hidden ? (
66+
<TouchableWithoutFeedback onPress={this.onNodePressed}>
67+
{this.props.renderNode(this.state.node, this.props.level)}
68+
</TouchableWithoutFeedback>
69+
) : null}
70+
{this.state.node.opened && rootChildren ? (
71+
<FlatList
72+
data={rootChildren}
73+
renderItem={({item}) => this.renderChildren(item, this.props.level)}
74+
keyExtractor={item => item.id}
75+
/>
76+
) : null}
77+
</View>
78+
)
79+
}
80+
}

example/ExampleApp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type Props,
1010
type State,
1111
} from 'react-native'
12-
import NestedListView from './nestedListView'
12+
import NestedListView from 'react-native-nested-listview'
1313

1414
const generateXNumItems = (numItems, prefix) => {
1515
const items = []

example/__tests__/index.android.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

example/__tests__/index.ios.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)