Skip to content
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
5 changes: 4 additions & 1 deletion lib/kati/calendars/airings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ defmodule Kati.Calendars.Airings do
title: String.t(),
meta: String.t(),
seed: String.t() | nil,
episodes: pos_integer(),
time: String.t(),
at: DateTime.t() | nil,
now?: boolean()
Expand Down Expand Up @@ -247,7 +248,8 @@ defmodule Kati.Calendars.Airings do
location: nil,
title: row.title,
meta: row.meta,
seed: row.seed
seed: row.seed,
episodes: Map.get(row, :episodes, 1)
}
end
end
Expand Down Expand Up @@ -296,6 +298,7 @@ defmodule Kati.Calendars.Airings do
title: (cached && cached.title) || gettext("Untitled"),
meta: episode_line(first, length(aired)),
seed: cached && cached.poster_path,
episodes: length(aired),
time: if(at, do: Kati.Locale.time(Kati.Time.in_zone(at, zone)), else: gettext("All day")),
at: at,
now?: false
Expand Down
83 changes: 76 additions & 7 deletions lib/kati/screens/day.ex
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,16 @@ defmodule Kati.Screens.Day do
{date, Kati.Calendars.Today.occurrences(date) ++ Kati.Calendars.Airings.occurrences(date)}
end

@doc """
Coming back from a show or an event opened from here: the day is read again,
keeping the chip and the open groups, so a title removed there is gone here.
"""
@impl true
def handle_kati(:resumed, _payload, socket),
do: {:noreply, Kati.Screens.Day.show(socket, socket.assigns.date)}

def handle_kati(_topic, _payload, socket), do: {:noreply, socket}

@doc false
def content(assigns) do
date = assigns.date
Expand All @@ -278,7 +288,7 @@ defmodule Kati.Screens.Day do
<Column fill_width={true} padding_left={21} padding_right={21}>
{Kati.Screens.Day.header(date, clusters, length(all_day))}
{Kati.Screens.Day.chips(filter, Kati.Screens.Day.counts(assigns))}
{Kati.Screens.Day.all_day_block(all_day)}
{Kati.Screens.Day.all_day_block(all_day, assigns.open_groups)}
</Column>
<Column
fill_width={true}
Expand All @@ -305,19 +315,60 @@ defmodule Kati.Screens.Day do
[{"All", length(rows)} | for(label <- @chips, do: {label, Map.get(tally, label, 0)})]
end

@doc "The *All day* group above the timeline, or nothing when the day has none."
def all_day_block([]), do: ~MOB"<Spacer size={0} />"
@doc """
The *All day* group above the timeline, or nothing when the day has none.

Episodes with a date and no hour fold into one grouped card once there are
`Layout.collapse_at/0` of them, the timeline's own rule, and open by the
same `group_` tag. Films and the reader's own all-day events stay rows.
"""
@spec all_day_block([map()], [atom()]) :: map()
def all_day_block(rows, open \\ [])
def all_day_block([], _open), do: ~MOB"<Spacer size={0} />"

def all_day_block(rows, open) do
{episodes, rest} = Enum.split_with(rows, &episode?/1)

{group, rest} =
if length(episodes) >= Layout.collapse_at(),
do: {all_day_group(episodes, open), all_day_rows(rest)},
else: {~MOB"<Spacer size={0} />", Kati.Screens.MonthGrid.day_rows(rows)}

def all_day_block(rows) do
~MOB"""
<Column fill_width={true} padding_top={18}>
{Kati.UI.eyebrow(gettext("All day"))}
{Kati.Screens.MonthGrid.day_rows(rows)}
{group}
{rest}
<Spacer size={18} />
</Column>
"""
end

@all_day_group :group_all_day

defp all_day_group(episodes, open) do
placement = %{event: %{collapsed: episodes, kind: :air_date}}
cluster = %{tag: @all_day_group, open?: @all_day_group in open}

~MOB"""
<Row fill_width={true}>
{Kati.Screens.Day.grouped_card(placement, cluster)}
</Row>
"""
end

defp episode?(row), do: Map.get(row, :tracked_kind) == :series and is_binary(row[:tracked_id])

defp all_day_rows([]), do: ~MOB"<Spacer size={0} />"

defp all_day_rows(rows) do
~MOB"""
<Column fill_width={true} padding_top={10}>
{Kati.Screens.MonthGrid.day_rows(rows)}
</Column>
"""
end

@doc "The lane rows, in clock order."
def timeline(clusters) do
clusters
Expand Down Expand Up @@ -753,6 +804,10 @@ defmodule Kati.Screens.Day do
# around a 12.5pt title and a 10pt meta line. There is no way to say "as tall
# as my siblings" here: `fill_height` inside a Row resolves against the
# incoming maximum, which is unbounded inside a Scroll.
#
# The width is fixed, not a minimum: the tile centres its figure with weighted
# spacers, and an unweighted child with weighted content takes the whole row,
# which left the two lane cards beside it zero wide.
defp overflow_tile(nil), do: []

defp overflow_tile(tile) do
Expand All @@ -770,7 +825,7 @@ defmodule Kati.Screens.Day do
[
~MOB"""
<Box
min_width={44}
width={44}
min_height={55}
corner_radius={16}
background={Palette.placeholder()}
Expand Down Expand Up @@ -1099,9 +1154,10 @@ defmodule Kati.Screens.Day do
@spec member_row(map()) :: map()
def member_row(member) do
title = Map.get(member, :title) || gettext("Untitled")
tap = Kati.Screens.Day.card_tap(member)

~MOB"""
<Row fill_width={true} align="center" padding_top={9} padding_bottom={9}>
<Row fill_width={true} align="center" padding_top={9} padding_bottom={9} on_tap={tap}>
{Kati.Screens.Day.thumb(member, Palette.placeholder())}
<Spacer size={11} />
<Column weight={1.0}>
Expand Down Expand Up @@ -1352,6 +1408,17 @@ defmodule Kati.Screens.Day do

def state_icon(_), do: ~MOB"<Spacer size={0} />"

# A show that drops a whole season is one member carrying many episodes, so
# "3 episodes" would undercount a day of three binge drops.
defp collapsed_title(%{collapsed: members, kind: :air_date}) do
shows = length(members)
episodes = members |> Enum.map(&Map.get(&1, :episodes, 1)) |> Enum.sum()

if episodes > shows,
do: joined(shows_label(shows), kind_label(:air_date, episodes)),
else: kind_label(:air_date, shows)
end

defp collapsed_title(%{collapsed: members, kind: kind}),
do: kind_label(kind, length(members))

Expand All @@ -1371,6 +1438,8 @@ defmodule Kati.Screens.Day do

defp collapsed_meta(_), do: ""

defp shows_label(n), do: ngettext("%{n} show", "%{n} shows", n, n: Kati.Locale.number(n))

# The label a user reads, not the atom the schema stores. "3 air_date
# events" is a database row talking to itself.
#
Expand Down
61 changes: 34 additions & 27 deletions priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ msgstr ""
#: lib/kati/library/sample.ex:192
#: lib/kati/screens/anime_filter.ex:281
#: lib/kati/screens/calendar.ex:861
#: lib/kati/screens/day.ex:478
#: lib/kati/screens/day.ex:529
#: lib/kati/screens/library.ex:1379
#: lib/kati/screens/meal_library.ex:278
#: lib/kati/screens/meals_day.ex:564
Expand Down Expand Up @@ -734,7 +734,7 @@ msgstr ""
#: lib/kati/notifications/inbox.ex:117
#: lib/kati/screens/calendar.ex:256
#: lib/kati/screens/calendar.ex:864
#: lib/kati/screens/day.ex:481
#: lib/kati/screens/day.ex:532
#: lib/kati/screens/home.ex:534
#: lib/kati/screens/money_day.ex:363
#: lib/kati/screens/my_services.ex:396
Expand Down Expand Up @@ -995,7 +995,7 @@ msgstr ""
#: lib/kati/screens/books.ex:539
#: lib/kati/screens/calendar.ex:255
#: lib/kati/screens/calendar.ex:862
#: lib/kati/screens/day.ex:479
#: lib/kati/screens/day.ex:530
#: lib/kati/screens/home.ex:530
#: lib/kati/screens/library.ex:1180
#: lib/kati/screens/meals_day.ex:566
Expand Down Expand Up @@ -4280,14 +4280,14 @@ msgstr ""
msgid "Show settings"
msgstr ""

#: lib/kati/calendars/airings.ex:218
#: lib/kati/calendars/airings.ex:296
#: lib/kati/calendars/airings.ex:219
#: lib/kati/calendars/airings.ex:298
#: lib/kati/calendars/today.ex:207
#: lib/kati/screens/activity.ex:1293
#: lib/kati/screens/activity.ex:1375
#: lib/kati/screens/day.ex:1101
#: lib/kati/screens/day.ex:1358
#: lib/kati/screens/day.ex:1367
#: lib/kati/screens/day.ex:1152
#: lib/kati/screens/day.ex:1421
#: lib/kati/screens/day.ex:1430
#: lib/kati/screens/drop_sheet.ex:482
#: lib/kati/screens/drop_sheet.ex:483
#: lib/kati/screens/event_detail.ex:192
Expand Down Expand Up @@ -4874,7 +4874,7 @@ msgstr ""

#: lib/kati/screens/agenda.ex:96
#: lib/kati/screens/calendar.ex:469
#: lib/kati/screens/day.ex:600
#: lib/kati/screens/day.ex:651
#: lib/kati/screens/month_grid.ex:139
#: lib/kati/screens/shopping.ex:154
#: lib/kati/screens/shopping.ex:351
Expand Down Expand Up @@ -4983,7 +4983,7 @@ msgstr ""

#: lib/kati/screens/agenda.ex:165
#: lib/kati/screens/calendar.ex:990
#: lib/kati/screens/day.ex:577
#: lib/kati/screens/day.ex:628
#: lib/kati/screens/month_grid.ex:133
#: lib/kati/screens/month_grid.ex:462
#: lib/kati/screens/week.ex:379
Expand All @@ -4995,7 +4995,7 @@ msgstr ""
#: lib/kati/screens/calendar.ex:863
#: lib/kati/screens/calendars.ex:573
#: lib/kati/screens/calendars.ex:590
#: lib/kati/screens/day.ex:480
#: lib/kati/screens/day.ex:531
#: lib/kati/screens/meals_day.ex:567
#: lib/kati/screens/money_day.ex:365
#: lib/kati/screens/quick_add/sample.ex:193
Expand Down Expand Up @@ -5094,7 +5094,7 @@ msgstr ""
msgid "New releases"
msgstr ""

#: lib/kati/calendars/airings.ex:148
#: lib/kati/calendars/airings.ex:149
#: lib/kati/screens/clear_history.ex:242
#: lib/kati/screens/home.ex:426
#: lib/kati/screens/library.ex:621
Expand Down Expand Up @@ -7963,7 +7963,7 @@ msgstr[1] ""
#: lib/kati/calendar/sample_meal_day.ex:78
#: lib/kati/calendar/sample_meal_day.ex:254
#: lib/kati/meals/sample_library.ex:167
#: lib/kati/screens/day.ex:1392
#: lib/kati/screens/day.ex:1457
#: lib/kati/screens/meal_library.ex:389
#: lib/kati/screens/meals_day.ex:173
#: lib/kati/screens/search_result_states.ex:254
Expand Down Expand Up @@ -8080,11 +8080,11 @@ msgstr ""
msgid "Activate"
msgstr ""

#: lib/kati/calendars/airings.ex:221
#: lib/kati/calendars/airings.ex:299
#: lib/kati/calendars/airings.ex:222
#: lib/kati/calendars/airings.ex:302
#: lib/kati/calendars/today.ex:205
#: lib/kati/money/day_sample.ex:156
#: lib/kati/screens/day.ex:312
#: lib/kati/screens/day.ex:337
#: lib/kati/screens/event_detail.ex:264
#: lib/kati/screens/money_day.ex:442
#: lib/kati/screens/week.ex:417
Expand Down Expand Up @@ -11021,7 +11021,7 @@ msgstr ""
msgid "%{n} albums"
msgstr ""

#: lib/kati/screens/day.ex:628
#: lib/kati/screens/day.ex:679
#, elixir-autogen, elixir-format
msgid "%{n} at once"
msgstr ""
Expand All @@ -11040,7 +11040,7 @@ msgid_plural "%{n} changes"
msgstr[0] ""
msgstr[1] ""

#: lib/kati/screens/day.ex:602
#: lib/kati/screens/day.ex:653
#, elixir-autogen, elixir-format
msgid "%{n} clash"
msgid_plural "%{n} clashes"
Expand All @@ -11054,8 +11054,8 @@ msgid_plural "%{n} edits"
msgstr[0] ""
msgstr[1] ""

#: lib/kati/calendars/airings.ex:155
#: lib/kati/screens/day.ex:1395
#: lib/kati/calendars/airings.ex:156
#: lib/kati/screens/day.ex:1460
#: lib/kati/screens/series.ex:924
#: lib/kati/settings/detect_music_sample.ex:137
#, elixir-autogen, elixir-format
Expand All @@ -11064,14 +11064,14 @@ msgid_plural "%{n} episodes"
msgstr[0] ""
msgstr[1] ""

#: lib/kati/screens/day.ex:1404
#: lib/kati/screens/day.ex:1469
#, elixir-autogen, elixir-format
msgid "%{n} event"
msgid_plural "%{n} events"
msgstr[0] ""
msgstr[1] ""

#: lib/kati/screens/day.ex:1398
#: lib/kati/screens/day.ex:1463
#, elixir-autogen, elixir-format
msgid "%{n} habit"
msgid_plural "%{n} habits"
Expand All @@ -11087,7 +11087,7 @@ msgstr[1] ""

#: lib/kati/money/day_sample.ex:86
#: lib/kati/money/day_sample.ex:180
#: lib/kati/screens/day.ex:1401
#: lib/kati/screens/day.ex:1466
#: lib/kati/screens/money_day.ex:302
#, elixir-autogen, elixir-format
msgid "%{n} renewal"
Expand Down Expand Up @@ -11916,7 +11916,7 @@ msgctxt "sync tally"
msgid "WAITING"
msgstr ""

#: lib/kati/screens/day.ex:771
#: lib/kati/screens/day.ex:822
#, elixir-autogen, elixir-format
msgctxt "the +n MORE tile on a clash row"
msgid "MORE"
Expand Down Expand Up @@ -16455,7 +16455,7 @@ msgstr ""
msgid "Which service carries what comes from JustWatch, through TMDB. Both are credited in Settings, under Where this comes from."
msgstr ""

#: lib/kati/calendars/airings.ex:219
#: lib/kati/calendars/airings.ex:220
#, elixir-autogen, elixir-format
msgid "Film release"
msgstr ""
Expand Down Expand Up @@ -17176,7 +17176,7 @@ msgstr ""
msgid "Earlier"
msgstr ""

#: lib/kati/screens/day.ex:337
#: lib/kati/screens/day.ex:388
#, elixir-autogen, elixir-format
msgid "Next day"
msgstr ""
Expand All @@ -17186,7 +17186,7 @@ msgstr ""
msgid "Next week"
msgstr ""

#: lib/kati/screens/day.ex:337
#: lib/kati/screens/day.ex:388
#, elixir-autogen, elixir-format
msgid "Previous day"
msgstr ""
Expand Down Expand Up @@ -17608,3 +17608,10 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Could not save what %{source} sent. Try again."
msgstr ""

#: lib/kati/screens/day.ex:1437
#, elixir-autogen, elixir-format
msgid "%{n} show"
msgid_plural "%{n} shows"
msgstr[0] ""
msgstr[1] ""
Loading
Loading