From 973a039b54327df74396605410ea9abe19c8a4e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Sep 2016 21:21:11 +0200 Subject: Upgrade to elm 0.17.1 --- src/Timer/Update.elm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/Timer/Update.elm (limited to 'src/Timer/Update.elm') diff --git a/src/Timer/Update.elm b/src/Timer/Update.elm new file mode 100644 index 0000000..31e8a43 --- /dev/null +++ b/src/Timer/Update.elm @@ -0,0 +1,56 @@ +module Timer.Update exposing + ( updateTimer + ) + +import Time exposing (Time) + +import Model.Id exposing (..) + +import Timer.Model exposing (..) +import Timer.Model.State exposing (..) +import Timer.Msg exposing (..) + +updateTimer : Msg -> Timer -> Timer +updateTimer msg timer = + case msg of + + Rename name -> + { timer | name = Just name } + + Pause -> + { timer | state = Idle } + + ToggleRunning -> + { timer + | state = + if timer.time > 0 && timer.state == Idle + then Running + else Idle + } + + Stop -> + { timer + | time = timer.initialTime + , state = Idle + } + + SetTime time -> + { timer + | initialTime = time + , time = time + } + + SubstractTime time -> + if timer.state == Running + then + let newTime = timer.time - time + in if newTime <= 0.0 + then + { timer + | time = 0.0 + , state = Ringing + } + else + { timer | time = newTime } + else + timer -- cgit v1.2.3