Something went wrong. Try again.
A music player that connects to your cloud/distributed storage. forked from tokono.ma/diffuse
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186module UI.Adjunct exposing (..)
import Keyboardimport Maybe.Extra as Maybeimport Returnimport UI.Alfred.State as Alfredimport UI.Audio.State as Audioimport UI.Commands.State as Commandsimport UI.Common.State as Commonimport UI.Interface.State exposing (hideOverlay)import UI.Page as Pageimport UI.Playlists.Page as Playlistsimport UI.Playlists.State as Playlistsimport UI.Queue.Page as Queueimport UI.Queue.State as Queueimport UI.Settings.Page as Settingsimport UI.Sources.Page as Sourcesimport UI.Tracks.State as Tracksimport UI.Types exposing (..)
-- 📣
keyboardInput : Keyboard.Msg -> ManagerkeyboardInput msg model = (\m -> let skip = Return.singleton m in if m.focusedOnInput && Maybe.isNothing model.alfred then case m.pressedKeys of [ Keyboard.Escape ] -> hideOverlay m
_ -> skip
else if Maybe.isJust model.alfred then case m.pressedKeys of [ Keyboard.ArrowDown ] -> Alfred.selectNext m
[ Keyboard.ArrowUp ] -> Alfred.selectPrevious m
[ Keyboard.Enter ] -> Alfred.runSelectedAction m
[ Keyboard.Escape ] -> hideOverlay m
-- Meta key -- [ Keyboard.Character "K", Keyboard.Meta ] -> Commands.showPalette m
-- Ctrl key -- [ Keyboard.Character "K", Keyboard.Control ] -> Commands.showPalette m
[ Keyboard.Character "L", Keyboard.Control ] -> Playlists.assistWithSelectingPlaylist m
_ -> skip
else case m.pressedKeys of [ Keyboard.Character "[", Keyboard.Control ] -> Queue.rewind m
[ Keyboard.Character "]", Keyboard.Control ] -> Queue.shift m
[ Keyboard.Character "{", Keyboard.Shift, Keyboard.Control ] -> case m.nowPlaying of Just { duration, item, playbackPosition } -> case duration of Just d -> Audio.seek { trackId = (Tuple.second item.identifiedTrack).id , progress = (playbackPosition - 10) / d } m
Nothing -> Return.singleton m
Nothing -> Return.singleton m
[ Keyboard.Character "}", Keyboard.Shift, Keyboard.Control ] -> case m.nowPlaying of Just { duration, item, playbackPosition } -> case duration of Just d -> Audio.seek { trackId = (Tuple.second item.identifiedTrack).id , progress = (playbackPosition + 10) / d } m
Nothing -> Return.singleton m
Nothing -> Return.singleton m
-- Meta key -- [ Keyboard.Character "K", Keyboard.Meta ] -> Commands.showPalette m
-- Ctrl key -- [ Keyboard.Character "K", Keyboard.Control ] -> Commands.showPalette m
[ Keyboard.Character "L", Keyboard.Control ] -> Playlists.assistWithSelectingPlaylist m
[ Keyboard.Character "N", Keyboard.Control ] -> Tracks.scrollToNowPlaying m
[ Keyboard.Character "P", Keyboard.Control ] -> Audio.playPause m
[ Keyboard.Character "R", Keyboard.Control ] -> Queue.toggleRepeat m
[ Keyboard.Character "S", Keyboard.Control ] -> Queue.toggleShuffle m
-- [ Keyboard.Character "1", Keyboard.Control ] -> Common.changeUrlUsingPage Page.Index m
[ Keyboard.Character "2", Keyboard.Control ] -> Common.changeUrlUsingPage (Page.Playlists Playlists.Index) m
[ Keyboard.Character "3", Keyboard.Control ] -> Common.changeUrlUsingPage (Page.Queue Queue.Index) m
[ Keyboard.Character "8", Keyboard.Control ] -> Common.changeUrlUsingPage (Page.Sources Sources.Index) m
[ Keyboard.Character "9", Keyboard.Control ] -> Common.changeUrlUsingPage (Page.Settings Settings.Index) m
-- [ Keyboard.Escape ] -> if Maybe.isJust m.contextMenu then Return.singleton { m | contextMenu = Nothing }
else if Maybe.isJust m.confirmation then Return.singleton { m | confirmation = Nothing }
else if Maybe.isJust m.alfred then Return.singleton { m | alfred = Nothing }
else if Maybe.isJust m.selectedCover then Return.singleton { m | selectedCover = Nothing }
else case m.page of Page.Playlists Playlists.Index -> Return.singleton { m | page = Page.Index }
Page.Playlists _ -> Return.singleton { m | page = Page.Playlists Playlists.Index }
Page.Queue _ -> Return.singleton { m | page = Page.Index }
_ -> skip
_ -> skip ) { model | pressedKeys = Keyboard.update msg model.pressedKeys }