Disable voting once revealed

This commit is contained in:
Correl Roush 2020-05-18 21:59:42 -04:00
parent ae42bccd9c
commit 4e8ac6f8d2

View file

@ -233,7 +233,7 @@ viewRoom device model =
column [ width fill, spacing 20 ] column [ width fill, spacing 20 ]
[ viewPlayers (Dict.values model.room.players) model.showVotes [ viewPlayers (Dict.values model.room.players) model.showVotes
, el [ width (fillPortion 3), alignTop ] <| , el [ width (fillPortion 3), alignTop ] <|
viewCards myVote viewCards model myVote
, moderatorTools model , moderatorTools model
] ]
@ -242,7 +242,7 @@ viewRoom device model =
[ row [ row
[ width fill ] [ width fill ]
[ el [ width (fillPortion 3), alignTop ] <| [ el [ width (fillPortion 3), alignTop ] <|
viewCards myVote viewCards model myVote
, column [ width (fillPortion 1), alignTop, spacing 50 ] <| , column [ width (fillPortion 1), alignTop, spacing 50 ] <|
[ viewPlayers (Dict.values model.room.players) model.showVotes [ viewPlayers (Dict.values model.room.players) model.showVotes
, moderatorTools model , moderatorTools model
@ -273,9 +273,19 @@ navBar { title, playerName } =
] ]
viewCards : Maybe String -> Element Msg viewCards : Model -> Maybe String -> Element Msg
viewCards selected = viewCards model selected =
let let
enabled =
not model.showVotes
selectedColor =
if enabled then
UI.colors.selected
else
UI.colors.disabled
card value = card value =
Input.button Input.button
[ width (px 100) [ width (px 100)
@ -287,13 +297,18 @@ viewCards selected =
, Border.rounded 10 , Border.rounded 10
, Background.color <| , Background.color <|
if selected == Just value then if selected == Just value then
UI.colors.selected selectedColor
else else
UI.colors.background UI.colors.background
, Font.size 50 , Font.size 50
] ]
{ onPress = Just (Vote value) { onPress =
if enabled then
Just (Vote value)
else
Nothing
, label = el [ centerX, centerY ] (text value) , label = el [ centerX, centerY ] (text value)
} }
in in