mobile resolution

This commit is contained in:
Priec
2026-05-16 18:17:27 +02:00
parent 08884536d7
commit 8e99e53d8a
5 changed files with 165 additions and 21 deletions

View File

@@ -89,6 +89,9 @@ pub struct CalendarPage {
/// `false` on the public calendar once it reaches the two-week look-back
/// limit, which disables the "previous week" button. Always `true` for admin.
pub can_prev: bool,
/// Index (06, MonSun) of the day shown first in the mobile single-day
/// view — today when the displayed week contains it, otherwise Monday.
pub mobile_day: i64,
pub days: Vec<DayHead>,
pub rows: Vec<Row>,
}
@@ -193,6 +196,9 @@ pub async fn build_calendar(
let min_monday = monday_of(Utc::now().date_naive()) - Duration::weeks(2);
let monday = if is_admin { monday } else { monday.max(min_monday) };
let can_prev = is_admin || monday > min_monday;
// Mobile single-day view opens on today when it falls in the shown week.
let day_offset = (Utc::now().date_naive() - monday).num_days();
let mobile_day = if (0..7).contains(&day_offset) { day_offset } else { 0 };
let sunday = monday + Duration::days(6);
let days: Vec<DayHead> = (0..7i64)
@@ -278,6 +284,7 @@ pub async fn build_calendar(
.to_string(),
next_week: (monday + Duration::days(7)).format("%Y-%m-%d").to_string(),
can_prev,
mobile_day,
days,
rows,
})