1
1
import { React , View , Button , BackButton , Modal , Card } from 'reapp-kit' ;
2
- import divStyle from '../styles.js ' ;
2
+ import divStyle , { paint } from '../styles' ;
3
3
4
- const paint = divStyle . paint ;
4
+ require ( 'velocity-animate/velocity.ui' ) ;
5
+
6
+ import { VelocityTransitionGroup , velocityHelpers } from 'velocity-react' ;
5
7
6
8
import * as _ from 'ramda' ;
7
9
import { getLocalJSON , setLocalJSON , addToHistory } from '../simpleStorage' ;
8
- import { get , onlyIf , logger } from '../../ramdahelpers.js' ;
9
-
10
-
10
+ import { get , onlyIf , logger , prettyTime } from '../../ramdahelpers.js' ;
11
+ import { speakers , tickers } from './convo/Transition'
11
12
12
13
13
-
14
- const CTG = React . addons . CSSTransitionGroup ;
14
+ console . log ( Velocity . RegisterEffect ) ;
15
15
16
16
17
17
@@ -24,9 +24,11 @@ const addTime = _.over(_.lensProp('currentSpeech'), _.add(1));
24
24
25
25
26
26
27
-
28
-
29
-
27
+ class Clock extends React . Component {
28
+ render ( ) {
29
+ return < div style = { divStyle . bottomSpacing } > < b > { this . props . speaker } has held the floor for { prettyTime ( this . props . elapsed ) } </ b > </ div >
30
+ }
31
+ }
30
32
31
33
32
34
@@ -35,35 +37,15 @@ const addTime = _.over(_.lensProp('currentSpeech'), _.add(1));
35
37
const instructions = ( speakers ) => {
36
38
let nums = _ . map ( get ( 'currentSpeech' ) , ( speakers ) ) ;
37
39
if ( _ . reduce ( _ . add , 0 , nums ) == 0 )
38
- return < h1 > Click on a Participant To Track The Time They Spend Speaking</ h1 >
40
+ return < p > Click on a Participant To Track The Time They Spend Speaking</ p >
39
41
}
40
42
41
43
42
44
43
45
44
46
// ::int -> string
45
- const prettyTime = ( timeinSec ) => {
46
-
47
- let hours = ( timeinSec > 3600 ) ? parseInt ( timeinSec / 3600 ) : 0 ;
48
- timeinSec = timeinSec - ( hours * 3600 ) ;
49
- let minutes = ( timeinSec > 60 ) ? parseInt ( timeinSec / 60 ) : 0 ;
50
- let seconds = timeinSec % 60 ;
51
-
52
- let val = `${ seconds } seconds`
53
- if ( minutes > 0 ) val = `${ minutes } minutes` . concat ( " " , val ) ;
54
- if ( hours > 0 ) val = `${ hours } hours` . concat ( " " , val ) ;
55
- return val ;
56
- }
57
-
58
-
59
-
60
47
61
48
62
- class Clock extends React . Component {
63
- render ( ) {
64
- return < div style = { divStyle . bottomSpacing } > < b > { this . props . speaker } has held the floor for { prettyTime ( this . props . elapsed ) } </ b > </ div >
65
- }
66
- }
67
49
68
50
69
51
export default class TalkerApp extends React . Component {
@@ -159,37 +141,27 @@ export default class TalkerApp extends React.Component {
159
141
160
142
let alt = ( this . state . ticking ) ? < Button color = "red" onTap = { this . pause } > Pause</ Button > : < Button color = "green" onTap = { this . resume } > Resume</ Button >
161
143
162
- const percentSpeaking = ( speaker ) => {
163
- return ( speaker . currentSpeech > 0 ) ? ( speaker . currentSpeech / this . state . currentSpeech ) * 100 : 0 ;
164
- }
144
+
165
145
166
146
const backButton =
167
147
< BackButton onTap = { this . save } />
168
148
169
149
return (
170
150
171
151
< View { ...this . props } title = "Conversation" titleLeft = { backButton } >
172
- < CTG >
173
- { instructions ( this . state . speakers ) }
174
- < b > Conversation Length: { prettyTime ( this . state . currentSpeech ) } </ b >
175
- < b > Time in Silence: { prettyTime ( this . state . silence ) } </ b >
176
-
177
- { this . state . speakers . map ( s => {
178
152
179
- let ticker = ( s . speaking ) ? < Clock speaker = { s . name } elapsed = { s . currentSpeech } /> : < div style = { { marginBottom : 12 } } /> ;
153
+
154
+ < div style = { divStyle . centerDiv } >
155
+ < b > Conversation Length: { prettyTime ( this . state . currentSpeech ) } </ b >
156
+ < b > Time in Silence: { prettyTime ( this . state . silence ) } </ b >
157
+ { instructions ( this . state . speakers ) }
158
+ </ div >
180
159
181
- return ( < div >
182
- < Button style = { { marginBottom : 10 } } onTap = { this . speak . bind ( this , s ) } > { s . name }
183
- < div style = { Object . assign ( divStyle . outline , { height : 15 , borderRadius : 5 , marginTop : 5 , marginBottom : 4 , minWidth : 70 } ) } >
184
- < div style = { Object . assign ( { } , { height : "100%" , width : `${ percentSpeaking ( s ) } %` , backgroundColor : ( percentSpeaking ( s ) < 80 ) ? 'green' : 'red' } ) } > </ div >
185
- </ div >
186
- </ Button >
187
- { ticker }
188
- </ div >
189
- ) } ) }
160
+ { this . state . speakers . map ( s => {
161
+ return < Speaker total = { this . state . currentSpeech } speak = { this . speak } s = { s } count = { this . state . speakers . length } />
162
+ } ) }
190
163
< br />
191
164
{ alt }
192
- </ CTG >
193
165
</ View >
194
166
) ;
195
167
}
@@ -199,3 +171,49 @@ export default class TalkerApp extends React.Component {
199
171
200
172
201
173
174
+
175
+
176
+ class Speaker extends React . Component {
177
+
178
+
179
+
180
+ render ( ) {
181
+ let total = this . props . total ;
182
+ let s = this . props . s ;
183
+
184
+ const perc = ( a , b ) => ( a > 0 ) ? ( a / b ) * 100 : 0 ;
185
+
186
+
187
+
188
+
189
+
190
+ //let ticker = (s.speaking)? <Clock speaker={s.name} elapsed={s.currentSpeech} /> : <div style={{marginBottom: 12}}/>;
191
+
192
+ return ( < div style = { { marginBottom : 10 } } >
193
+ < Button style = { { height : `${ ( 400 / this . props . count ) } ` } } onTap = { this . props . speak . bind ( this , s ) } >
194
+ { s . name }
195
+ < div
196
+ style = { Object . assign (
197
+ divStyle . outline ,
198
+ { height : 15 ,
199
+ borderRadius : 5 ,
200
+ marginTop : 5 ,
201
+ marginBottom : 4 ,
202
+ minWidth : 70 } ) } >
203
+ < div style = { Object . assign ( { } ,
204
+ { height : "100%" ,
205
+ width : `${ perc ( s . currentSpeech , total ) } %` ,
206
+ backgroundColor : ( perc ( s . currentSpeech , total ) < 80 ) ? 'green' : 'red' } ) } >
207
+ </ div >
208
+ </ div >
209
+ < div style = { { margin : 2 , borderRadius : 5 , padding : 5 , color : ( s . speaking ) ? 'red' : null } } >
210
+ { prettyTime ( s . currentSpeech ) }
211
+ </ div >
212
+ </ Button >
213
+ </ div >
214
+ ) ;
215
+ }
216
+ }
217
+
218
+
219
+
0 commit comments