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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310module Themes.Sunrise.Queue.View exposing (view)
import Chunky exposing (..)import Commonimport Conditional exposing (..)import Html exposing (Html, text)import Html.Attributes exposing (href)import Html.Lazy as Lazyimport Iconsimport Material.Icons.Round as Iconsimport Material.Icons.Types exposing (Coloring(..))import Queue exposing (..)import Themes.Sunrise.Kit as Kitimport Themes.Sunrise.Listimport Themes.Sunrise.Navigation as Navigationimport UI.DnD as DnDimport UI.Navigation exposing (..)import UI.Page as Pageimport UI.Queue.Page as Queue exposing (Page(..))import UI.Queue.Types exposing (..)import UI.Sources.Pageimport UI.Types as UI exposing (..)
-- 🗺
view : Queue.Page -> UI.Model -> Html UI.Msgview page model = case page of History -> Lazy.lazy2 historyView model.playedPreviously model.dnd
Index -> Lazy.lazy3 futureView model.playingNext model.selectedQueueItem model.dnd
-- 🗺 ░░ FUTURE
futureView : List Queue.Item -> Maybe Queue.Item -> DnD.Model Int -> Html UI.MsgfutureView playingNext selectedQueueItem dnd = Kit.receptacle { scrolling = not (DnD.isDragging dnd) } [ ----------------------------------------- -- Navigation ----------------------------------------- Navigation.local [ ( Icon Icons.arrow_back , Label Common.backToIndex Hidden , NavigateToPage Page.Index ) , ( Icon Icons.history , Label "History" Shown , NavigateToPage (Page.Queue History) ) , ( Icon Icons.clear , Label "Clear" Shown , PerformMsg (QueueMsg Clear) ) , ( Icon Icons.more_horiz , Label "Menu" Hidden , PerformMsgWithMouseEvent (QueueMsg << ShowFutureNavigationMenu) ) ]
----------------------------------------- -- Content ----------------------------------------- , if List.isEmpty playingNext then chunk [ "relative" ] [ chunk [ "absolute", "left-0", "top-0" ] [ Kit.canister [ Kit.h1 "Up next" ] ] ]
else Kit.canister [ Kit.h1 "Up next" , playingNext |> List.indexedMap (futureItem selectedQueueItem) |> Themes.Sunrise.List.view (Themes.Sunrise.List.Draggable { model = dnd , toMsg = UI.DnD } ) |> chunky [ "mt-3" ] ]
-- , if List.isEmpty playingNext then Kit.centeredContent [ slab Html.a [ href (Page.toString <| Page.Sources UI.Sources.Page.New) ] [ "text-inherit", "block", "opacity-30" ] [ Icons.music_note 64 Inherit ] , slab Html.a [ href (Page.toString <| Page.Sources UI.Sources.Page.New) ] [ "text-inherit", "block", "leading-normal", "mt-2", "opacity-40", "text-center" ] [ text "Nothing here yet," , lineBreak , text "add some music first." ] ]
else nothing ]
futureItem : Maybe Item -> Int -> Queue.Item -> Themes.Sunrise.List.Item UI.MsgfutureItem selectedQueueItem idx item = let ( identifiers, track ) = item.identifiedTrack
isSelected = selectedQueueItem |> Maybe.map (.identifiedTrack >> Tuple.first >> .indexInList) |> (==) (Just identifiers.indexInList)
iconFn = if item.manualEntry then identity
else Icons.wrapped subtleFutureIconClasses in { label = inline [ "block" , "truncate"
-- , if item.manualEntry || isSelected then "text-inherit"
else "text-base05"
-- Dark mode ------------ , if item.manualEntry || isSelected then "dark:text-inherit"
else "dark:text-base04" ] [ inline [ "inline-block" , "mr-2" , "opacity-60" , "text-xs" ] [ text (String.fromInt <| idx + 1), text "." ] , case track.tags.artist of Just artist -> text (artist ++ " - " ++ track.tags.title)
Nothing -> text track.tags.title ] , actions = [ -- Remove --------- { icon = if item.manualEntry then iconFn Icons.remove_circle_outline
else iconFn Icons.not_interested , msg = { index = idx, item = item } |> RemoveItem |> QueueMsg |> always |> Just , title = ifThenElse item.manualEntry "Remove" "Ignore" }
-- Menu ------- , { icon = iconFn Icons.more_vert , msg = Just (QueueMsg << ShowFutureMenu item { index = idx }) , title = "Menu" } ] , msg = Just (QueueMsg <| Select item) , isSelected = isSelected }
subtleFutureIconClasses : List StringsubtleFutureIconClasses = [ "text-gray-500"
-- Dark mode ------------ , "dark:text-base02" ]
-- 🗺 ░░ HISTORY
historyView : List Queue.Item -> DnD.Model Int -> Html UI.MsghistoryView playedPreviously dnd = Kit.receptacle { scrolling = not (DnD.isDragging dnd) } [ ----------------------------------------- -- Navigation ----------------------------------------- Navigation.local [ ( Icon Icons.arrow_back , Label Common.backToIndex Hidden , NavigateToPage Page.Index ) , ( Icon Icons.update , Label "Up next" Shown , NavigateToPage (Page.Queue Index) ) ]
----------------------------------------- -- Content ----------------------------------------- , if List.isEmpty playedPreviously then chunk [ "relative" ] [ chunk [ "absolute", "left-0", "top-0" ] [ Kit.canister [ Kit.h1 "History" ] ] ]
else Kit.canister [ Kit.h1 "History" , playedPreviously |> List.reverse |> List.indexedMap historyItem |> Themes.Sunrise.List.view Themes.Sunrise.List.Normal |> chunky [ "mt-3" ] ]
-- , if List.isEmpty playedPreviously then Kit.centeredContent [ chunk [ "opacity-30" ] [ Icons.music_note 64 Inherit ] , chunk [ "leading-normal", "mt-2", "opacity-40", "text-center" ] [ text "Nothing here yet," , lineBreak , text "play some music first." ] ]
else nothing ]
historyItem : Int -> Queue.Item -> Themes.Sunrise.List.Item UI.MsghistoryItem idx ({ identifiedTrack } as item) = let ( _, track ) = identifiedTrack in { label = inline [ "block", "truncate" ] [ inline [ "inline-block", "text-xs", "mr-2" ] [ text (String.fromInt <| idx + 1), text "." ] , case track.tags.artist of Just artist -> text (artist ++ " - " ++ track.tags.title)
Nothing -> text track.tags.title ] , actions = [ { icon = Icons.more_vert , msg = Just (QueueMsg << ShowHistoryMenu item) , title = "Menu" } ] , msg = Nothing , isSelected = False }