Skip to content

Commit

Permalink
Merge pull request #13 from imclerran/fix-adaptive-nav-prompt
Browse files Browse the repository at this point in the history
Fix bug in adaptive control prompt which caused it to require excess …
  • Loading branch information
imclerran authored Jun 5, 2024
2 parents afd3bc6 + b0d9050 commit 8e6be81
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/View.roc
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ controlPromptsShortDict =
controlsPromptStr : Model -> Str
controlsPromptStr = \model ->
actions = Controller.getActions model
promptsDict = if model.screen.width // Num.toI32 (List.len actions) < 16 then controlPromptsShortDict else controlPromptsDict
actionStrs =
Controller.getActions model
|> List.map \action ->
Dict.get promptsDict action |> Result.withDefault ""
|> List.dropIf (\str -> Str.isEmpty str)
" $(Str.joinWith actionStrs " | ") "
longStr = buildControlPromptStr actions controlPromptsDict
if Num.toI32 (Str.countUtf8Bytes longStr) <= model.screen.width - 6 then
" $(longStr) "
else
" $(buildControlPromptStr actions controlPromptsShortDict) "

buildControlPromptStr : List UserAction, Dict UserAction Str -> Str
buildControlPromptStr = \actions, promptsDict ->
actions
|> List.map \action ->
Dict.get promptsDict action |> Result.withDefault ""
|> List.dropIf (\str -> Str.isEmpty str)
|> Str.joinWith " | "

## Generate the list of functions to draw the platform select page.
renderPlatformSelect : Model -> List Core.DrawFn
Expand Down

0 comments on commit 8e6be81

Please sign in to comment.