A music player that connects to your cloud/distributed storage.

Add ability to select a different background image

+140 -17
+9
src/App/Settings/Ports.elm
··· 1 + port module Settings.Ports exposing (..) 2 + 3 + import Settings.Types exposing (..) 4 + 5 + 6 + -- 💡 7 + 8 + 9 + port storeApplicationSettings : Model -> Cmd msg
+30
src/App/Settings/State.elm
··· 1 + module Settings.State exposing (..) 2 + 3 + import Settings.Ports as Ports 4 + import Settings.Types exposing (..) 5 + import Types as TopLevel exposing (ProgramFlags) 6 + 7 + 8 + -- 💧 9 + 10 + 11 + initialModel : ProgramFlags -> Model 12 + initialModel flags = 13 + flags.settings.application 14 + 15 + 16 + 17 + -- 🔥 18 + 19 + 20 + update : Msg -> Model -> ( Model, Cmd TopLevel.Msg ) 21 + update msg model = 22 + case msg of 23 + SetBackgroundImage filename -> 24 + let 25 + newModel = 26 + { model | backgroundImage = filename } 27 + in 28 + (!) 29 + newModel 30 + [ Ports.storeApplicationSettings newModel ]
+16
src/App/Settings/Types.elm
··· 1 + module Settings.Types exposing (..) 2 + 3 + -- Messages 4 + 5 + 6 + type Msg 7 + = SetBackgroundImage String 8 + 9 + 10 + 11 + -- Model 12 + 13 + 14 + type alias Model = 15 + { backgroundImage : String 16 + }
+47 -11
src/App/Settings/View.elm
··· 1 1 module Settings.View exposing (..) 2 2 3 + import Color 3 4 import Html exposing (..) 4 5 import Html.Attributes exposing (..) 6 + import Html.Events exposing (onInput) 5 7 import Material.Icons.Action as Icons 8 + import Material.Icons.Navigation as Icons 6 9 import Material.Icons.Image as Icons 7 10 import Navigation.View as Navigation 11 + import Settings.Types 8 12 import Types exposing (Model, Msg(..)) 9 13 import Utils exposing (cssClass) 10 14 import Variables exposing (colorDerivatives) ··· 12 16 13 17 -- Styles 14 18 19 + import Form.Styles as FormStyles 15 20 import Styles exposing (Classes(..)) 16 21 17 22 ··· 40 45 ------------------------------------ 41 46 , div 42 47 [ cssClass ContentBox ] 43 - [ h1 44 - [] 45 - [ text "Settings" ] 46 - , div 47 - [ cssClass EmptyState ] 48 - [ Icons.panorama_wide_angle colorDerivatives.text 16 49 - , div 50 - [] 51 - [ text "Coming soon" 52 - ] 53 - ] 48 + [ h1 [] [ text "Settings" ] 49 + , Html.map SettingsMsg (theForm model) 54 50 ] 55 51 ] 52 + 53 + 54 + theForm : Model -> Html Settings.Types.Msg 55 + theForm model = 56 + Html.form 57 + [ style 58 + [ ( "max-width", "350px" ) ] 59 + ] 60 + [ label 61 + [] 62 + [ text "Background image" ] 63 + , div 64 + [ cssClass FormStyles.SelectBox ] 65 + [ select 66 + [ onInput Settings.Types.SetBackgroundImage ] 67 + (List.map 68 + (\( val, lbl ) -> 69 + option 70 + [ selected (val == model.settings.backgroundImage) 71 + , value val 72 + ] 73 + [ text lbl ] 74 + ) 75 + backgroundImages 76 + ) 77 + , Icons.expand_more (Color.greyscale 0.325) 20 78 + ] 79 + ] 80 + 81 + 82 + backgroundImages : List ( String, String ) 83 + backgroundImages = 84 + [ ( "1.jpg", "Option 1" ) 85 + , ( "2.jpg", "Option 2" ) 86 + , ( "3.jpg", "Option 3" ) 87 + , ( "4.jpg", "Option 4 (default)" ) 88 + , ( "5.jpg", "Option 5" ) 89 + , ( "6.jpg", "Option 6" ) 90 + , ( "7.jpg", "Option 7" ) 91 + ]
+6
src/App/State.elm
··· 20 20 import Equalizer.State as Equalizer 21 21 import Queue.State as Queue 22 22 import Routing.State as Routing 23 + import Settings.State as Settings 23 24 import Sources.State as Sources 24 25 import Tracks.State as Tracks 25 26 ··· 59 60 , equalizer = Equalizer.initialModel flags 60 61 , queue = Queue.initialModel flags 61 62 , routing = Routing.initialModel location 63 + , settings = Settings.initialModel flags 62 64 , sources = Sources.initialModel flags 63 65 , tracks = Tracks.initialModel flags 64 66 } ··· 155 157 Routing.update sub model.routing 156 158 |> mapModel (\x -> { model | routing = x }) 157 159 |> handleRouteTransitions sub model 160 + 161 + SettingsMsg sub -> 162 + Settings.update sub model.settings 163 + |> mapModel (\x -> { model | settings = x }) 158 164 159 165 SourcesMsg sub -> 160 166 Sources.update sub model.sources
+5 -1
src/App/Types.elm
··· 14 14 import Equalizer.Types as Equalizer 15 15 import Queue.Types as Queue 16 16 import Routing.Types as Routing 17 + import Settings.Types as Settings 17 18 import Sources.Types as Sources 18 19 import Tracks.Types as Tracks 19 20 ··· 34 35 | EqualizerMsg Equalizer.Msg 35 36 | QueueMsg Queue.Msg 36 37 | RoutingMsg Routing.Msg 38 + | SettingsMsg Settings.Msg 37 39 | SourcesMsg Sources.Msg 38 40 | TracksMsg Tracks.Msg 39 41 -- Children, Pt. 2 ··· 76 78 , equalizer : Equalizer.Model 77 79 , queue : Queue.Model 78 80 , routing : Routing.Model 81 + , settings : Settings.Model 79 82 , sources : Sources.Model 80 83 , tracks : Tracks.Model 81 84 } ··· 101 104 102 105 103 106 type alias Settings = 104 - { equalizer : Equalizer.Settings 107 + { application : Settings.Model 108 + , equalizer : Equalizer.Settings 105 109 , queue : Queue.Settings 106 110 , tracks : Tracks.Settings 107 111 }
+19
src/App/View.elm
··· 141 141 style [] 142 142 ] 143 143 [] 144 + 145 + -- 146 + -- Background image 147 + -- 148 + , div 149 + [ cssClass BackgroundImage 150 + , style 151 + [ ( "background-image" 152 + , "url(images/Background/" ++ model.settings.backgroundImage ++ ")" 153 + ) 154 + , case model.settings.backgroundImage of 155 + "1.jpg" -> 156 + ( "background-position", "center 30%" ) 157 + 158 + _ -> 159 + ( "background-position", "center bottom" ) 160 + ] 161 + ] 162 + [] 144 163 ] 145 164 146 165
+3 -3
src/Css/Styles.elm
··· 83 83 -- <body> 84 84 ------------------------------------------------------ 85 85 , body 86 - [ backgroundColor (hex "#000") 86 + [ backgroundColor (hex "#02070E") 87 + , backgroundImage (url "/images/ep_naturalblack_pattern.jpg") 87 88 , color (cssColor colorDerivatives.text) 88 89 , defaultFont 89 90 , fontSize (Css.rem 1) ··· 103 104 -- > Not on the <body> for a reason. 104 105 ------------------------------------------------------ 105 106 , class BackgroundImage 106 - [ backgroundImage (url "images/Background/4.jpg") 107 - , backgroundPosition bottom 107 + [ backgroundPosition bottom 108 108 , backgroundSize cover 109 109 110 110 -- For: 1.jpg
+5
src/Js/elm-loader.js
··· 39 39 function initializeFlags(params) { 40 40 return { 41 41 settings: { 42 + application: Object.assign( 43 + { backgroundImage: "4.jpg" }, 44 + loadSettings("application") 45 + ), 42 46 equalizer: Object.assign( 43 47 { low: 0, mid: 0, high: 0, volume: 1 }, 44 48 loadSettings("equalizer") ··· 181 185 app.ports.storeTracks.subscribe(v => storeData("tracks", v)); 182 186 app.ports.storeFavourites.subscribe(v => storeData("favourites", v)); 183 187 188 + app.ports.storeApplicationSettings.subscribe(s => saveSettings("application", s)); 184 189 app.ports.storeEqualizerSettings.subscribe(s => saveSettings("equalizer", s)); 185 190 app.ports.storeQueueSettings.subscribe(s => saveSettings("queue", s)); 186 191 app.ports.storeTracksSettings.subscribe(s => saveSettings("tracks", s));
-2
src/Static/Html/Proxy.html
··· 33 33 </noscript> 34 34 </div> 35 35 36 - <div class="BackgroundImage"></div> 37 - 38 36 <script> 39 37 // insert loader 40 38 document.getElementById("elm-container").innerHTML =
src/Static/Images/ep_naturalblack_pattern.jpg

This is a binary file and will not be displayed.

src/Static/Images/ep_naturalblack_pattern.png

This is a binary file and will not be displayed.