module View.Header ( renderHeader ) where import Signal exposing (Address) import Dict import TransitRouter import Route exposing (..) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) import Model exposing (Model) import Model.Translations exposing (getMessage) import Action exposing (..) import Model.View exposing (..) import View.Icon exposing (renderIcon) import View.Click exposing (clickTo) renderHeader : Address Action -> Model -> Html renderHeader address model = header [] ( [ div [ class "title" ] [ text (getMessage "SharedCost" model.translations) ] ] ++ let item route name = a ( [ classList [ ("item", True) , ("current", TransitRouter.getRoute model == route) ] ] ++ clickTo route ) [ text (getMessage name model.translations) ] in case model.view of LoggedInView { me, users } -> [ item Home "PaymentsTitle" , item Income "Income" , item Stat "Statistics" , div [ class "nameSignOut" ] [ div [ class "name" ] [ Dict.get me users |> Maybe.map .name |> Maybe.withDefault "" |> text ] , button [ class "signOut item" , onClick address SignOut ] [ renderIcon "power-off" ] ] ] _ -> [] )