Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Elevator evergreen content #2318

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/css/elevator_v2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
@import "v2/elevator/footer";
@import "v2/lcd_common/route_pill";

.evergreen-content-image__container,
.evergreen-content-image__image {
width: 100%;
height: 100%;
}

body {
margin: 0;
font-family: Inter;
Expand Down
12 changes: 9 additions & 3 deletions lib/screens/v2/candidate_generator/elevator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator do

alias Screens.V2.CandidateGenerator
alias Screens.V2.CandidateGenerator.Elevator.Closures, as: ElevatorClosures
alias Screens.V2.CandidateGenerator.Widgets.Evergreen
alias Screens.V2.Template.Builder
alias Screens.V2.WidgetInstance.{Footer, NormalHeader}
alias ScreensConfig.Screen
Expand All @@ -27,10 +28,15 @@ defmodule Screens.V2.CandidateGenerator.Elevator do
def candidate_instances(
config,
now \\ DateTime.utc_now(),
elevator_closure_instances_fn \\ &ElevatorClosures.elevator_status_instances/1
elevator_closure_instances_fn \\ &ElevatorClosures.elevator_status_instances/1,
evergreen_content_instances_fn \\ &Evergreen.evergreen_content_instances/2
) do
[header_instance(config, now), footer_instance(config)] ++
elevator_closure_instances_fn.(config)
Enum.concat([
header_instance(config, now),
footer_instance(config),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to how this works. header_ and footer_instance return a single widget struct, which is not an enumerable, and Enum.concat/1 expects an enum of enums. Doing the equivalent of this call in IEx results in an error:

iex(1)> Enum.concat([:a, :b, [:c, :d], [:e, :f]])
** (Protocol.UndefinedError) protocol Enumerable not implemented for :a of type Atom
    (elixir 1.15.7) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.15.7) lib/enum.ex:166: Enumerable.reduce/3
    (elixir 1.15.7) lib/enum.ex:4387: anonymous fn/3 in Enum.concat_enum/1
    (elixir 1.15.7) lib/enum.ex:2510: Enum."-concat_enum/1-lists^foldl/2-1-"/3
    (elixir 1.15.7) lib/enum.ex:2510: Enum.concat_enum/1
    iex:1: (file)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫥

elevator_closure_instances_fn.(config),
evergreen_content_instances_fn.(config, now)
])
end

def audio_only_instances(_widgets, _config), do: []
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/v2/candidate_generator/widgets/evergreen.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ defmodule Screens.V2.CandidateGenerator.Widgets.Evergreen do
alias Screens.V2.WidgetInstance.EvergreenContent
alias ScreensConfig.Screen
alias ScreensConfig.V2.EvergreenContentItem
alias ScreensConfig.V2.{BusEink, BusShelter, Dup, GlEink, PreFare}
alias ScreensConfig.V2.{BusEink, BusShelter, Dup, Elevator, GlEink, PreFare}

def evergreen_content_instances(
%Screen{app_params: %app{evergreen_content: evergreen_content}} = config,
now \\ DateTime.utc_now()
)
when app in [BusEink, BusShelter, Dup, GlEink, PreFare] do
when app in [BusEink, BusShelter, Dup, Elevator, GlEink, PreFare] do
Enum.map(evergreen_content, &evergreen_content_instance(&1, config, now))
end

Expand Down