@@ -3,6 +3,7 @@ import { createGlobalStyle } from 'styled-components';
33
44// containers
55import SplitPane from '../container/SplitPane.jsx' ;
6+ import TimeSlider from '../container/TimeSlider.jsx' ;
67
78// left pane = events, right pane = details
89import Events from '../container/Events.jsx' ;
@@ -30,7 +31,6 @@ const GlobalStyle = createGlobalStyle`
3031 }
3132` ;
3233
33-
3434class App extends Component {
3535 constructor ( props ) {
3636 super ( props ) ;
@@ -39,15 +39,19 @@ class App extends Component {
3939 data : [ ] ,
4040 isPlaying : false ,
4141 isRecording : false ,
42+ isSearching : false ,
43+ isPlayingIndex : 0 ,
4244 } ;
45+
4346 this . port = null ;
44- this . isPlayingIndex = 0 ;
4547 this . addActionToView = this . addActionToView . bind ( this ) ;
4648 this . toTheFuture = this . toTheFuture . bind ( this ) ;
4749 this . toThePast = this . toThePast . bind ( this ) ;
4850 this . setIsPlaying = this . setIsPlaying . bind ( this ) ;
4951 this . setIsRecording = this . setIsRecording . bind ( this ) ;
5052 this . actionInPlay = this . actionInPlay . bind ( this ) ;
53+ this . handleBarChange = this . handleBarChange . bind ( this ) ;
54+ this . searchChange = this . searchChange . bind ( this ) ;
5155 }
5256
5357 componentDidMount ( ) {
@@ -71,10 +75,11 @@ class App extends Component {
7175
7276 // functionality to change 'play' button to 'stop'
7377 setIsPlaying ( ) {
74- if ( this . isPlayingIndex === this . state . data . length - 1 ) {
75- this . isPlayingIndex = 0 ;
78+ if ( this . state . isPlayingIndex > this . state . data . length - 1 ) {
79+ this . setState ( { isPlayingIndex : 0 } ) ;
7680 }
7781
82+ console . log ( 'isplaying' ) ;
7883 let { isPlaying } = this . state ;
7984 isPlaying = ! isPlaying ;
8085 this . setState ( { isPlaying } ) ;
@@ -93,14 +98,17 @@ class App extends Component {
9398 }
9499
95100 actionInPlay ( ) {
96- this . isPlayingIndex ++ ;
101+ let { isPlayingIndex } = this . state ;
102+ if ( isPlayingIndex >= this . state . data . length - 1 ) isPlayingIndex = 0 ;
103+
104+ this . setState ( { isPlayingIndex : isPlayingIndex + 1 } ) ;
105+ const { id, action, state } = this . state . data [ isPlayingIndex + 1 ] ;
97106
98- const { id, action, state } = this . state . data [ this . isPlayingIndex ] ;
99107 setTimeout ( ( ) => {
100108 this . setState ( ( prev , props ) => {
101- return { ...prev , id, action, state }
109+ return { ...prev , id, action, state } ;
102110 } ) ;
103- if ( this . state . isPlaying && this . isPlayingIndex < this . state . data . length - 1 ) {
111+ if ( this . state . isPlaying && isPlayingIndex + 1 < this . state . data . length - 1 ) {
104112 this . actionInPlay ( ) ;
105113 } else {
106114 this . setState ( { isPlaying : false } ) ;
@@ -121,6 +129,25 @@ class App extends Component {
121129 } ) ;
122130 }
123131
132+ // filter search bar results
133+ // *** NOT FINISHED ***
134+ searchChange ( e ) {
135+ const { data } = this . state ;
136+ console . log ( data ) ;
137+ }
138+
139+ // time travel bar change
140+ handleBarChange ( e ) {
141+ const { data } = this . state ;
142+ const { id, action, state } = data [ e . target . value ] ;
143+
144+ this . setState ( {
145+ id,
146+ action,
147+ state,
148+ isPlayingIndex : parseInt ( e . target . value ) ,
149+ } ) ;
150+ }
124151
125152 // function to travel to the FUTURE
126153 toTheFuture ( ) {
@@ -141,6 +168,7 @@ class App extends Component {
141168 }
142169
143170 render ( ) {
171+ console . log ( this . state . isPlayingIndex ) ;
144172 const {
145173 action,
146174 id,
@@ -163,10 +191,6 @@ class App extends Component {
163191 addAction = { this . addActionToView }
164192 toTheFuture = { this . toTheFuture }
165193 toThePast = { this . toThePast }
166- isPlaying = { isPlaying }
167- isRecording = { isRecording }
168- setIsPlaying = { this . setIsPlaying }
169- setIsRecording = { this . setIsRecording }
170194 activeEventId = { id }
171195 />
172196 ) }
@@ -179,6 +203,17 @@ class App extends Component {
179203 />
180204 ) }
181205 />
206+ < TimeSlider
207+ data = { data }
208+ toTheFuture = { this . toTheFuture }
209+ toThePast = { this . toThePast }
210+ isPlaying = { isPlaying }
211+ isPlayingIndex = { this . state . isPlayingIndex }
212+ isRecording = { isRecording }
213+ setIsPlaying = { this . setIsPlaying }
214+ setIsRecording = { this . setIsRecording }
215+ handleBarChange = { this . handleBarChange }
216+ />
182217 </ >
183218 ) ;
184219 }
0 commit comments