thegamenicorus / react-native-timeline-listview

Timeline component for React Native App
https://www.npmjs.com/package/react-native-timeline-listview
MIT License
1.17k stars 184 forks source link

Render Circle displays icons to far right of 2 column #64

Open shubhamverma27 opened 5 years ago

shubhamverma27 commented 5 years ago

I am trying to display a custom view which includes an icon for the circle using renderCircle in a single column left. I can see that my custom view is being rendered. The only issue is that the custom circle is being rendered to the far right of the screen instead of down the middle line that is rendered. Do I maybe need to change more styles or is this a bug?

bhaskardabhi commented 5 years ago

Same is happening for me.

alihaider123go commented 4 years ago

Same for me.

jspizziri commented 3 years ago

In case people are still struggling with this the answer is "Yes". You do need to add some additional style, as the native _renderCircle method manually positions the circles relative to other dimensions.

The renderCircle function you pass into the component is bound to the component. So you can do something like this:

<Timeline
  data={data}
  renderCircle={function (item, index) {
    let circleSize = 9;
    if ([some criteria to identify your custom circle]) {
      return (
        <View
          style={{
            width: circleSize,
            height: circleSize,
            backgroundColor: 'blue',
            right: this.state.width - circleSize / 2 - (lineWidth - 1) / 2,
          }}
        />
      );
    }

    return this._renderCircle(item, index);
  }}
/>