Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add two icons "+" and "-" in NestedListView #245

Closed
nammiharika opened this issue Feb 26, 2020 · 3 comments
Closed

How to add two icons "+" and "-" in NestedListView #245

nammiharika opened this issue Feb 26, 2020 · 3 comments

Comments

@nammiharika
Copy link

Describe the bug
I am using this module and it's working fine. I want to display the "+" and "-" icons in NestedListView. I already displayed "+" icon in NestedRow. Once user clicks on row it turns to "-" icon. How can i change "+" to "-" icon in NestedRow.

To Reproduce
Steps to reproduce the behavior:

  1. Click on NestedRow.
  2. "+" icon changed to "-" icon.

Expected behavior
I want to show both "+" and "-" icons. Because NestedRow is extended it changes to "-" icon
Screenshots

ezgif com-video-to-gif

@fjmorant
Copy link
Owner

fjmorant commented Mar 5, 2020

Hi @nammiharika ,

Sorry for my late reply to this message, it would be super simple:

<NestedListView
  data={data}
  getChildrenName={(node) => 'items'}
  onNodePressed={(node) => alert('Selected node')}
  renderNode={(node, level) => (
    <NestedRow
      level={level}
      style={styles.row}
    >
      <Text>{node.title}</Text>
    </NestedRow>
  )}
/>

the parameter nodehas an attribute called opened then you can change the icon (or text) depending on this param.

I hope I could answer your question

@nammiharika
Copy link
Author

nammiharika commented Mar 6, 2020

Hi @fjmorant, thank you for your reply.

Where to give opened key in NestedListView

Here is my code...

<NestedListView
            data={data}
            getChildrenName={node => 'categories'}
            onNodePressed={node =>
              console.log('Selected node11___________', node.categories.length)
            }
            renderNode={(node, level) => {
              // console.log('level___________', level);
              return (
                <View
                  style={{
                    flexDirection: 'row',
                    height: 40,
                    // backgroundColor: 'lightblue',
                    alignItems: 'center',
                    borderColor: 'grey',
                    borderBottomWidth: 1,
                  }}>
                  <NestedRow level={level} style={{color: 'black'}}>
                    <Text>{node.title}</Text>
                  </NestedRow>
                  <Image
                    source={require('@Images/plus.png')}
                    style={{height: 15, width: 15, marginRight: 15}}
                  />
                </View>
              );
            }}
          />

@iagows
Copy link

iagows commented Aug 21, 2020

Hi @fjmorant, thank you for your reply.

Where to give opened key in NestedListView

Here is my code...

<NestedListView
            data={data}
            getChildrenName={node => 'categories'}
            onNodePressed={node =>
              console.log('Selected node11___________', node.categories.length)
            }
            renderNode={(node, level) => {
              // console.log('level___________', level);
              return (
                <View
                  style={{
                    flexDirection: 'row',
                    height: 40,
                    // backgroundColor: 'lightblue',
                    alignItems: 'center',
                    borderColor: 'grey',
                    borderBottomWidth: 1,
                  }}>
                  <NestedRow level={level} style={{color: 'black'}}>
                    <Text>{node.title}</Text>
                  </NestedRow>
                  <Image
                    source={require('@Images/plus.png')}
                    style={{height: 15, width: 15, marginRight: 15}}
                  />
                </View>
              );
            }}
          />

After <Text>{node.title}</Text>, try adding <Text>{node.opened ? '-':'+'}</Text>

@fjmorant fjmorant closed this as completed Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants