@@ -4,12 +4,12 @@ import min from 'lodash/min';
44import map from 'lodash/map' ;
55
66import { Theme } from '../types' ;
7- import styleConstructor from './style' ;
7+ import styleConstructor , { HOURS_SIDEBAR_WIDTH } from './style' ;
88import populateEvents , { HOUR_BLOCK_HEIGHT } from './Packer' ;
99import TimelineHours , { TimelineHoursProps } from './TimelineHours' ;
1010import EventBlock , { Event , PackedEvent } from './EventBlock' ;
11+ import NowIndicator from './NowIndicator' ;
1112
12- const LEFT_MARGIN = 60 - 1 ;
1313const { width : dimensionWidth } = Dimensions . get ( 'window' ) ;
1414
1515export interface TimelineProps {
@@ -50,6 +50,10 @@ export interface TimelineProps {
5050 * Render a custom event block
5151 */
5252 renderEvent ?: ( event : PackedEvent ) => JSX . Element ;
53+ /**
54+ * Whether to show now indicator
55+ */
56+ showNowIndicator ?: boolean ;
5357}
5458
5559const Timeline = ( props : TimelineProps ) => {
@@ -64,6 +68,7 @@ const Timeline = (props: TimelineProps) => {
6468 renderEvent,
6569 theme,
6670 scrollToFirst,
71+ showNowIndicator,
6772 eventTapped
6873 } = props ;
6974
@@ -72,7 +77,7 @@ const Timeline = (props: TimelineProps) => {
7277 const styles = useRef ( styleConstructor ( theme || props . styles , calendarHeight . current ) ) ;
7378
7479 const packedEvents = useMemo ( ( ) => {
75- const width = dimensionWidth - LEFT_MARGIN ;
80+ const width = dimensionWidth - HOURS_SIDEBAR_WIDTH ;
7681 return populateEvents ( events , width , start ) ;
7782 } , [ events , start ] ) ;
7883
@@ -123,7 +128,7 @@ const Timeline = (props: TimelineProps) => {
123128
124129 return (
125130 < View >
126- < View style = { { marginLeft : LEFT_MARGIN } } > { events } </ View >
131+ < View style = { { marginLeft : HOURS_SIDEBAR_WIDTH } } > { events } </ View >
127132 </ View >
128133 ) ;
129134 } ;
@@ -140,6 +145,7 @@ const Timeline = (props: TimelineProps) => {
140145 onBackgroundLongPressOut = { onBackgroundLongPressOut }
141146 />
142147 { renderEvents ( ) }
148+ { showNowIndicator && < NowIndicator styles = { styles . current } /> }
143149 </ ScrollView >
144150 ) ;
145151} ;
0 commit comments