HomeOur TeamContact

Custom Timeline Listview

By Utkarsh Lubal
Published in List
April 15, 2023
1 min read
Custom Timeline Listview

Table Of Contents

01
Introduction
02
Installation
03
Example
04
Tutorial

Introduction

Timeline component for React Native App work for Android and iOS

Configuration

Data Object:
PropertyTypeDefaultDescription
timestringnullevent time
titlestringnullevent title
descriptionstringnullevent description
lineWidthintsame as lineWidth of ‘Timeline’event line width
lineColorstringsame as lineColor of ‘Timeline’event line color
circleSizeintsame as circleSize of ‘Timeline’event circle size
circleColorstringsame as circleColor of ‘Timeline’event circle color
dotColorstringsame as dotColor of ‘Timeline’event dot color (innerCircle = ‘dot’)
iconobj(image source)same as icon of ‘Timeline’event icon (innerCircle = ‘color’)

Timeline:

PropertyTypeDefaultDescription
datadata objectnulltimeline data
innerCirclestringnulltimeline mode : ‘none’, ‘dot’, ‘icon’
separatorbooltruerender separator line of events
columnFormatstring‘single-left’can be ‘single-column-left’, ‘single-column-right’, ‘two-column’
lineWidthint2timeline line width
lineColorstring‘#007AFF’timeline line color
circleSizeint16timeline circle size
circleColorstring‘#007AFF’timeline circle color
dotColorstring‘white’timeline dot color (innerCircle = ‘dot’)
iconobj(image source)nulltimeline icon (innerCircle = ‘color’)
styleobjectnullcustom styles of Timeline container
listViewStyleobjectnullcustom styles of inner ListView
timeStyleobjectnullcustom styles of event time
titleStyleobjectnullcustom styles of event title
descriptionStyleobjectnullcustom styles of event description
iconStyleobjectnullcustom styles of event icon
separatorStyleobjectnullcustom styles of separator
rowContainerStyleobjectnullcustom styles of event container
timeContainerStyleobjectnullcustom styles of container of event time
detailContainerStyleobjectnullcustom styles of container of event title and event description
onEventPressfunction(event)nullfunction to be invoked when event was pressed
renderTimefunction(rowData, sectionID, rowID)nullcustom render event time
renderDetailfunction(rowData, sectionID, rowID)nullcustom render event title and event description
renderCirclefunction(rowData, sectionID, rowID)nullcustom render circle
renderFullLineboolfalserender event border on last timeline item
optionsobjectnullListView properties
showTimebooleantrueTime container options

Installation

npm i react-native-timeline-listview --save

Example

import React, { Component } from 'react';
import { StyleSheet, View,Image,Text } from 'react-native';
import Timeline from 'react-native-timeline-flatlist';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.data = [
     {time: '09:00', title: 'Archery Training', description: 'The Beginner Archery and Beginner Crossbow course does not require you to bring any equipment, since everything you need will be provided for the course. ',lineColor:'#009688'},
      {time: '10:45', title: 'Play Badminton', description: 'Badminton is a racquet sport played using racquets to hit a shuttlecock across a net.'},
      {time: '12:00', title: 'Lunch', },
      {time: '14:00', title: 'Watch Soccer', description: 'Team sport played between two teams of eleven players with a spherical ball. ',lineColor:'#009688'},
      {time: '16:30', title: 'Go to Fitness center', description: 'Look out for the Best Gym & Fitness Centers around me :)'}
    ];
  }

  render() {
    return (
      <View style={styles.container}>
        <Timeline 
          style={styles.list}
          data={this.data}
          circleSize={20}
          circleColor='rgb(45,156,219)'
          lineColor='rgb(45,156,219)'
          timeContainerStyle={{minWidth:52, marginTop: -5}}
          timeStyle={{textAlign: 'center', backgroundColor:'#ff9797', color:'white', padding:5, borderRadius:13}}
          descriptionStyle={{color:'gray'}}
          options={{
            style:{paddingTop:5}
            }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  paddingTop:65,
    backgroundColor:'white'
  },
  list: {
    flex: 1,
    marginTop:20,
  },
  title:{
    fontSize:16,
    fontWeight: 'bold'
  },
  descriptionContainer:{
    flexDirection: 'row',
    paddingRight: 50
  },
  image:{
    width: 50,
    height: 50,
    borderRadius: 25
  },
  textDescription: {
    marginLeft: 10,
    color: 'black'
  }
});

Tutorial

Coming Soon…


Previous Article
Easy Toast
Utkarsh Lubal

Utkarsh Lubal

Full Stack Developer

Related Posts

Basic Timeline Listview
Basic Timeline Listview
April 15, 2023
1 min

Quick Links

Advertise with usAbout UsContact Us

Social Media