Skip to content

Commit

Permalink
toggles play/pause image on timer, adds text to buttons, pauses timer…
Browse files Browse the repository at this point in the history
… on navigation to info

relates #149
  • Loading branch information
lucymk committed Apr 6, 2018
1 parent 75fcd48 commit c908666
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/elm/State.elm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ update msg model =
NavigateToStimInfo ->
{ model | stimInfoDestination = model.view }
! []
:> update (NavigateTo StimInfo)
:> update (ifThenElse (model.view == StimTimer) (ChangeViewFromTimer StimInfo) (NavigateTo StimInfo))

ChangeSkinColour ->
{ model | skinColour = toggleSkinColour model } ! [ changeSkinColour ( (toggleSkinColour model |> skinColourToHexValue), ".is-selected" ) ]
Expand Down
32 changes: 28 additions & 4 deletions src/elm/Views/StimTimer.elm
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ stimTimer model =
[ span [] [ text <| (formatTimeFirstDigits (floor <| model.counter / 60)) ++ ":" ]
, span [] [ text <| formatTimeSecondDigits (rem (round model.counter) 60) ]
]
, div [ class "mh7 flex justify-between mb5" ]
[ img [ onClick <| AdjustTimer Restart, src "./assets/StimTimer/timer_replay_btn.svg" ] []
, img [ onClick <| AdjustTimer Start, src "./assets/StimTimer/timer_play_btn.svg" ] []
, img [ onClick <| AdjustTimer Pause, src "./assets/StimTimer/timer_pause_btn.svg" ] []
, div [ class "mh7 flex justify-around mb5" ]
[ div [ class "h4 flex flex-column justify-between" ]
[ img [ onClick <| AdjustTimer Restart, src "./assets/StimTimer/timer_replay_btn.svg" ] []
, p [] [ text "Restart" ]
]
, displayPlayOrPause model.timerStatus
]
, img [ class "mb4", src "./assets/StimTimer/white_divider_zigzag_thin.svg" ] []
, div []
Expand All @@ -56,3 +58,25 @@ formatTimeFirstDigits time =
formatTimeSecondDigits : Int -> String
formatTimeSecondDigits time =
ifThenElse ((String.length <| toString time) == 1) (toString time ++ "0") (toString time)


displayPlayOrPause : TimerStatus -> Html Msg
displayPlayOrPause timerstatus =
case timerstatus of
Started ->
div [ class "h4 flex flex-column justify-between" ]
[ img [ onClick <| AdjustTimer Pause, src "./assets/StimTimer/timer_pause_btn.svg" ] []
, p [] [ text "Pause" ]
]

Stopped ->
div [ class "h4 flex flex-column justify-between" ]
[ img [ onClick <| AdjustTimer Start, src "./assets/StimTimer/timer_play_btn.svg" ] []
, p [] [ text "Start" ]
]

Paused ->
div [ class "h4 flex flex-column justify-between" ]
[ img [ onClick <| AdjustTimer Start, src "./assets/StimTimer/timer_play_btn.svg" ] []
, p [] [ text "Start" ]
]

0 comments on commit c908666

Please sign in to comment.