From af9465f928f28344aa59a407adb21e5ac047a0f9 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Thu, 19 Mar 2015 00:55:50 +0100 Subject: Adding a Ringing state that animate the color, does not ring a sound for the moment --- src/Update/UpdateTimer.elm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Update/UpdateTimer.elm') diff --git a/src/Update/UpdateTimer.elm b/src/Update/UpdateTimer.elm index e4671d9..c147d23 100644 --- a/src/Update/UpdateTimer.elm +++ b/src/Update/UpdateTimer.elm @@ -6,6 +6,7 @@ module Update.UpdateTimer import Time (Time) import Model.Timer (..) +import Model.TimerState (..) import Model.Id (..) type TimerAction = @@ -20,19 +21,22 @@ updateTimer action timer = case action of Restart -> { timer - | isRunning <- True - , currentTime <- initTime timer.initialTime + | currentTime <- initTime timer.initialTime + , state <- Running } Pause -> + { timer | state <- Idle } + ToggleRunning -> { timer - | isRunning <- False + | state <- + if timer.currentTime > 0 && timer.state == Idle + then Running + else Idle } - ToggleRunning -> - { timer | isRunning <- timer.currentTime > 0.0 && not timer.isRunning } Stop -> { timer - | isRunning <- False - , currentTime <- initTime timer.initialTime + | currentTime <- initTime timer.initialTime + , state <- Idle } SetTime time -> let augmentedTime = time + 999 -- cgit v1.2.3