tvl-depot/website/sandbox/learnpianochords/src/Main.elm
William Carroll d134db700f Support a FlashCard before showing the notes that comprise a chord
My much anticipated feature: first prompt the user for a name of a chord, then
show the user that chord.

Cascading changes:
I changed the "Tap to practice" overlayButton's opacity from 30% to 100% because
pausing when showFlashCard is True causes the two piece

TIL:
You can batch Elm Subscriptions using the Sub.batch function.

What I haven't learned yet:
How to best handle rotating screens for mobile devices (i.e. portrait
vs. landscape modes). In time...

What's left?
- Support sound
- Support a fine-tune section of the preferences
- Support tablet and web browser variants
- Ask users for the "I chord" instead of asking "C major Root position"
- More styling (of course)
2020-04-19 15:32:20 +01:00

44 lines
982 B
Elm

module Main exposing (main)
import Browser
import Html exposing (..)
import Misc
import Overview
import Practice
import Preferences
import State
import Time exposing (..)
subscriptions : State.Model -> Sub State.Msg
subscriptions model =
if model.isPaused then
Sub.none
else
Sub.batch
[ Time.every (model.tempo * 2 |> Misc.bpmToMilliseconds |> toFloat) (\_ -> State.ToggleFlashCard)
, Time.every (model.tempo |> Misc.bpmToMilliseconds |> toFloat) (\_ -> State.NextChord)
]
view : State.Model -> Html State.Msg
view model =
case model.view of
State.Preferences ->
Preferences.render model
State.Practice ->
Practice.render model
State.Overview ->
Overview.render model
main =
Browser.element
{ init = \() -> ( State.init, Cmd.none )
, subscriptions = subscriptions
, update = State.update
, view = view
}