2020-04-11 00:03:01 +02:00
|
|
|
module Main exposing (main)
|
|
|
|
|
|
|
|
import Browser
|
|
|
|
import Html exposing (..)
|
2020-04-18 15:58:16 +02:00
|
|
|
import Misc
|
|
|
|
import Overview
|
|
|
|
import Practice
|
|
|
|
import Preferences
|
|
|
|
import State
|
2020-04-11 17:09:11 +02:00
|
|
|
import Time exposing (..)
|
2020-04-11 00:03:01 +02:00
|
|
|
|
2020-04-11 11:45:42 +02:00
|
|
|
|
2020-04-18 15:58:16 +02:00
|
|
|
subscriptions : State.Model -> Sub State.Msg
|
|
|
|
subscriptions model =
|
|
|
|
if model.isPaused then
|
2020-04-12 17:43:34 +02:00
|
|
|
Sub.none
|
|
|
|
|
|
|
|
else
|
2020-04-19 16:32:20 +02:00
|
|
|
Sub.batch
|
|
|
|
[ Time.every (model.tempo * 2 |> Misc.bpmToMilliseconds |> toFloat) (\_ -> State.ToggleFlashCard)
|
|
|
|
, Time.every (model.tempo |> Misc.bpmToMilliseconds |> toFloat) (\_ -> State.NextChord)
|
|
|
|
]
|
2020-04-13 23:39:15 +02:00
|
|
|
|
2020-04-17 14:35:33 +02:00
|
|
|
|
2020-04-18 15:58:16 +02:00
|
|
|
view : State.Model -> Html State.Msg
|
2020-04-13 23:39:15 +02:00
|
|
|
view model =
|
|
|
|
case model.view of
|
2020-04-18 15:58:16 +02:00
|
|
|
State.Preferences ->
|
|
|
|
Preferences.render model
|
|
|
|
|
|
|
|
State.Practice ->
|
|
|
|
Practice.render model
|
2020-04-13 23:39:15 +02:00
|
|
|
|
2020-04-18 15:58:16 +02:00
|
|
|
State.Overview ->
|
|
|
|
Overview.render model
|
2020-04-13 23:39:15 +02:00
|
|
|
|
|
|
|
|
2020-04-11 00:03:01 +02:00
|
|
|
main =
|
2020-04-12 17:43:34 +02:00
|
|
|
Browser.element
|
2020-04-18 15:58:16 +02:00
|
|
|
{ init = \() -> ( State.init, Cmd.none )
|
2020-04-12 17:43:34 +02:00
|
|
|
, subscriptions = subscriptions
|
2020-04-18 15:58:16 +02:00
|
|
|
, update = State.update
|
2020-04-12 17:43:34 +02:00
|
|
|
, view = view
|
|
|
|
}
|