BlueGit

ict rusty-teams

feat(calendar): month view and date picker

- Month view: six week grid, up to three events per day, +N more, click opens the day
- Date title opens a mini month picker; the shown range is highlighted
- Back and forward step whole months in the month view

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-08 · 3 weeks ago

Hash
ab0c26339ea6d6fec3f0996a54fdc52286eb920d
Parent
5411189c
6 files changed +517 −27
crates/app-call-model/src/week_grid.rs +55 −6
@@ -1,8 +1,9 @@
1 1 use chatsvc::{CalendarEvent, ResponseType, ShowAs};
2 use chrono::{DateTime, Datelike, Duration, FixedOffset, NaiveDate, Utc, Weekday};
2 use chrono::{DateTime, Datelike, Duration, FixedOffset, Months, NaiveDate, Utc, Weekday};
3 3
4 4 pub const WORK_WEEK_DAYS: i64 = 5;
5 5 pub const MINUTES_PER_DAY: i64 = 24 * 60;
6 pub const MONTH_GRID_DAYS: i64 = 42;
6 7
7 8 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8 9 pub struct WeekBlock {
@@ -30,13 +31,15 @@ pub enum CalendarSpan {
30 31 #[default]
31 32 WorkWeek,
32 33 Week,
34 Month,
33 35 }
34 36
35 37 impl CalendarSpan {
36 pub const ALL: [CalendarSpan; 3] = [
38 pub const ALL: [CalendarSpan; 4] = [
37 39 CalendarSpan::Day,
38 40 CalendarSpan::WorkWeek,
39 41 CalendarSpan::Week,
42 CalendarSpan::Month,
40 43 ];
41 44
42 45 pub fn label(self) -> &'static str {
@@ -44,6 +47,7 @@ impl CalendarSpan {
44 47 CalendarSpan::Day => "Day",
45 48 CalendarSpan::WorkWeek => "Work week",
46 49 CalendarSpan::Week => "Week",
50 CalendarSpan::Month => "Month",
47 51 }
48 52 }
49 53
@@ -52,6 +56,7 @@ impl CalendarSpan {
52 56 CalendarSpan::Day => 1,
53 57 CalendarSpan::WorkWeek => WORK_WEEK_DAYS,
54 58 CalendarSpan::Week => 7,
59 CalendarSpan::Month => MONTH_GRID_DAYS,
55 60 }
56 61 }
57 62
@@ -60,15 +65,45 @@ impl CalendarSpan {
60 65 CalendarSpan::Day => date,
61 66 CalendarSpan::WorkWeek => work_week_for(date),
62 67 CalendarSpan::Week => week_start(date),
68 CalendarSpan::Month => month_grid_start(date),
63 69 }
64 70 }
65 71
66 pub fn step(self) -> Duration {
72 pub fn shifted(self, start: NaiveDate, steps: i32) -> NaiveDate {
67 73 match self {
68 CalendarSpan::Day => Duration::days(1),
69 CalendarSpan::WorkWeek | CalendarSpan::Week => Duration::weeks(1),
74 CalendarSpan::Day => start + Duration::days(i64::from(steps)),
75 CalendarSpan::WorkWeek | CalendarSpan::Week => start + Duration::weeks(i64::from(steps)),
76 CalendarSpan::Month => {
77 let month = month_shown(start);
78 let moved = if steps >= 0 {
79 month.checked_add_months(Months::new(steps.unsigned_abs()))
80 } else {
81 month.checked_sub_months(Months::new(steps.unsigned_abs()))
82 };
83 month_grid_start(moved.unwrap_or(month))
84 }
70 85 }
71 86 }
87
88 pub fn title(self, start: NaiveDate) -> String {
89 match self {
90 CalendarSpan::Month => month_shown(start).format("%B %Y").to_string(),
91 _ => range_label(start, self.days()),
92 }
93 }
94 }
95
96 pub fn first_of_month(date: NaiveDate) -> NaiveDate {
97 date.with_day(1).unwrap_or(date)
98 }
99
100 pub fn month_grid_start(date: NaiveDate) -> NaiveDate {
101 week_start(first_of_month(date))
102 }
103
104 /// The grid starts up to six days before the 1st, so a week in is always inside the shown month.
105 pub fn month_shown(grid_start: NaiveDate) -> NaiveDate {
106 first_of_month(grid_start + Duration::weeks(1))
72 107 }
73 108
74 109 /// On a weekend the work week view shows the coming week, as Outlook does.
@@ -245,6 +280,20 @@ mod tests {
245 280 FixedOffset::east_opt(0).unwrap()
246 281 }
247 282
283 #[test]
284 fn month_view_steps_whole_months_from_a_monday_grid() {
285 let date = |day| NaiveDate::from_ymd_opt(2026, 11, day).unwrap();
286 let start = CalendarSpan::Month.start_for(date(18));
287 assert_eq!(start, NaiveDate::from_ymd_opt(2026, 10, 26).unwrap());
288 assert_eq!(CalendarSpan::Month.title(start), "November 2026");
289 let next = CalendarSpan::Month.shifted(start, 1);
290 assert_eq!(next, NaiveDate::from_ymd_opt(2026, 11, 30).unwrap());
291 assert_eq!(CalendarSpan::Month.title(next), "December 2026");
292 let back = CalendarSpan::Month.shifted(start, -11);
293 assert_eq!(CalendarSpan::Month.title(back), "December 2025");
294 assert_eq!(CalendarSpan::Week.shifted(date(2), -1), date(2) - Duration::weeks(1));
295 }
296
248 297 #[test]
249 298 fn the_week_starts_on_monday() {
250 299 let sunday = NaiveDate::from_ymd_opt(2026, 11, 15).unwrap();
@@ -312,7 +361,7 @@ mod tests {
312 361 assert_eq!(CalendarSpan::Week.start_for(wednesday), monday);
313 362 let sunday = NaiveDate::from_ymd_opt(2026, 11, 15).unwrap();
314 363 assert_eq!(CalendarSpan::Week.start_for(sunday), monday);
315 assert_eq!(CalendarSpan::Day.step(), Duration::days(1));
364 assert_eq!(CalendarSpan::Day.shifted(wednesday, 1), wednesday + Duration::days(1));
316 365 assert_eq!(CalendarSpan::Week.days(), 7);
317 366 }
318 367
@@ -1,8 +1,9 @@
1use chatsvc::{CalendarEvent, ResponseType, ShowAs};
1use chatsvc::{CalendarEvent, ResponseType, ShowAs};
2use chrono::{DateTime, Datelike, Duration, FixedOffset, NaiveDate, Utc, Weekday};
2use chrono::{DateTime, Datelike, Duration, FixedOffset, Months, NaiveDate, Utc, Weekday};
3
3
4pub const WORK_WEEK_DAYS: i64 = 5;
4pub const WORK_WEEK_DAYS: i64 = 5;
5pub const MINUTES_PER_DAY: i64 = 24 * 60;
5pub const MINUTES_PER_DAY: i64 = 24 * 60;
6pub const MONTH_GRID_DAYS: i64 = 42;
6
7
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct WeekBlock {
9pub struct WeekBlock {
@@ -30,13 +31,15 @@ pub enum CalendarSpan {
30 #[default]
31 #[default]
31 WorkWeek,
32 WorkWeek,
32 Week,
33 Week,
34 Month,
33}
35}
34
36
35impl CalendarSpan {
37impl CalendarSpan {
36 pub const ALL: [CalendarSpan; 3] = [
38 pub const ALL: [CalendarSpan; 4] = [
37 CalendarSpan::Day,
39 CalendarSpan::Day,
38 CalendarSpan::WorkWeek,
40 CalendarSpan::WorkWeek,
39 CalendarSpan::Week,
41 CalendarSpan::Week,
42 CalendarSpan::Month,
40 ];
43 ];
41
44
42 pub fn label(self) -> &'static str {
45 pub fn label(self) -> &'static str {
@@ -44,6 +47,7 @@ impl CalendarSpan {
44 CalendarSpan::Day => "Day",
47 CalendarSpan::Day => "Day",
45 CalendarSpan::WorkWeek => "Work week",
48 CalendarSpan::WorkWeek => "Work week",
46 CalendarSpan::Week => "Week",
49 CalendarSpan::Week => "Week",
50 CalendarSpan::Month => "Month",
47 }
51 }
48 }
52 }
49
53
@@ -52,6 +56,7 @@ impl CalendarSpan {
52 CalendarSpan::Day => 1,
56 CalendarSpan::Day => 1,
53 CalendarSpan::WorkWeek => WORK_WEEK_DAYS,
57 CalendarSpan::WorkWeek => WORK_WEEK_DAYS,
54 CalendarSpan::Week => 7,
58 CalendarSpan::Week => 7,
59 CalendarSpan::Month => MONTH_GRID_DAYS,
55 }
60 }
56 }
61 }
57
62
@@ -60,15 +65,45 @@ impl CalendarSpan {
60 CalendarSpan::Day => date,
65 CalendarSpan::Day => date,
61 CalendarSpan::WorkWeek => work_week_for(date),
66 CalendarSpan::WorkWeek => work_week_for(date),
62 CalendarSpan::Week => week_start(date),
67 CalendarSpan::Week => week_start(date),
68 CalendarSpan::Month => month_grid_start(date),
63 }
69 }
64 }
70 }
65
71
66 pub fn step(self) -> Duration {
72 pub fn shifted(self, start: NaiveDate, steps: i32) -> NaiveDate {
67 match self {
73 match self {
68 CalendarSpan::Day => Duration::days(1),
74 CalendarSpan::Day => start + Duration::days(i64::from(steps)),
69 CalendarSpan::WorkWeek | CalendarSpan::Week => Duration::weeks(1),
75 CalendarSpan::WorkWeek | CalendarSpan::Week => start + Duration::weeks(i64::from(steps)),
76 CalendarSpan::Month => {
77 let month = month_shown(start);
78 let moved = if steps >= 0 {
79 month.checked_add_months(Months::new(steps.unsigned_abs()))
80 } else {
81 month.checked_sub_months(Months::new(steps.unsigned_abs()))
82 };
83 month_grid_start(moved.unwrap_or(month))
84 }
70 }
85 }
71 }
86 }
87
88 pub fn title(self, start: NaiveDate) -> String {
89 match self {
90 CalendarSpan::Month => month_shown(start).format("%B %Y").to_string(),
91 _ => range_label(start, self.days()),
92 }
93 }
94}
95
96pub fn first_of_month(date: NaiveDate) -> NaiveDate {
97 date.with_day(1).unwrap_or(date)
98}
99
100pub fn month_grid_start(date: NaiveDate) -> NaiveDate {
101 week_start(first_of_month(date))
102}
103
104/// The grid starts up to six days before the 1st, so a week in is always inside the shown month.
105pub fn month_shown(grid_start: NaiveDate) -> NaiveDate {
106 first_of_month(grid_start + Duration::weeks(1))
72}
107}
73
108
74/// On a weekend the work week view shows the coming week, as Outlook does.
109/// On a weekend the work week view shows the coming week, as Outlook does.
@@ -245,6 +280,20 @@ mod tests {
245 FixedOffset::east_opt(0).unwrap()
280 FixedOffset::east_opt(0).unwrap()
246 }
281 }
247
282
283 #[test]
284 fn month_view_steps_whole_months_from_a_monday_grid() {
285 let date = |day| NaiveDate::from_ymd_opt(2026, 11, day).unwrap();
286 let start = CalendarSpan::Month.start_for(date(18));
287 assert_eq!(start, NaiveDate::from_ymd_opt(2026, 10, 26).unwrap());
288 assert_eq!(CalendarSpan::Month.title(start), "November 2026");
289 let next = CalendarSpan::Month.shifted(start, 1);
290 assert_eq!(next, NaiveDate::from_ymd_opt(2026, 11, 30).unwrap());
291 assert_eq!(CalendarSpan::Month.title(next), "December 2026");
292 let back = CalendarSpan::Month.shifted(start, -11);
293 assert_eq!(CalendarSpan::Month.title(back), "December 2025");
294 assert_eq!(CalendarSpan::Week.shifted(date(2), -1), date(2) - Duration::weeks(1));
295 }
296
248 #[test]
297 #[test]
249 fn the_week_starts_on_monday() {
298 fn the_week_starts_on_monday() {
250 let sunday = NaiveDate::from_ymd_opt(2026, 11, 15).unwrap();
299 let sunday = NaiveDate::from_ymd_opt(2026, 11, 15).unwrap();
@@ -312,7 +361,7 @@ mod tests {
312 assert_eq!(CalendarSpan::Week.start_for(wednesday), monday);
361 assert_eq!(CalendarSpan::Week.start_for(wednesday), monday);
313 let sunday = NaiveDate::from_ymd_opt(2026, 11, 15).unwrap();
362 let sunday = NaiveDate::from_ymd_opt(2026, 11, 15).unwrap();
314 assert_eq!(CalendarSpan::Week.start_for(sunday), monday);
363 assert_eq!(CalendarSpan::Week.start_for(sunday), monday);
315 assert_eq!(CalendarSpan::Day.step(), Duration::days(1));
364 assert_eq!(CalendarSpan::Day.shifted(wednesday, 1), wednesday + Duration::days(1));
316 assert_eq!(CalendarSpan::Week.days(), 7);
365 assert_eq!(CalendarSpan::Week.days(), 7);
317 }
366 }
318
367
crates/app-state/src/call/week.rs +12 −2
@@ -31,8 +31,8 @@ impl AppState {
31 31 }
32 32
33 33 pub fn shift_calendar_week(&mut self, steps: i32, cx: &mut Context<Self>) {
34 let step = self.calendar_week.span.step() * steps;
35 self.calendar_week.start = Some(self.calendar_start() + step);
34 let span = self.calendar_week.span;
35 self.calendar_week.start = Some(span.shifted(self.calendar_start(), steps));
36 36 self.load_calendar_week(cx);
37 37 }
38 38
@@ -51,6 +51,16 @@ impl AppState {
51 51 self.load_calendar_week(cx);
52 52 }
53 53
54 pub fn show_calendar_date(&mut self, date: NaiveDate, cx: &mut Context<Self>) {
55 self.calendar_week.start = Some(self.calendar_week.span.start_for(date));
56 self.load_calendar_week(cx);
57 }
58
59 pub fn show_calendar_day(&mut self, date: NaiveDate, cx: &mut Context<Self>) {
60 self.calendar_week.span = CalendarSpan::Day;
61 self.show_calendar_date(date, cx);
62 }
63
54 64 fn load_calendar_week(&mut self, cx: &mut Context<Self>) {
55 65 let start = self.calendar_start();
56 66 let offset = Local::now().offset().fix();
@@ -31,8 +31,8 @@ impl AppState {
31 }
31 }
32
32
33 pub fn shift_calendar_week(&mut self, steps: i32, cx: &mut Context<Self>) {
33 pub fn shift_calendar_week(&mut self, steps: i32, cx: &mut Context<Self>) {
34 let step = self.calendar_week.span.step() * steps;
34 let span = self.calendar_week.span;
35 self.calendar_week.start = Some(self.calendar_start() + step);
35 self.calendar_week.start = Some(span.shifted(self.calendar_start(), steps));
36 self.load_calendar_week(cx);
36 self.load_calendar_week(cx);
37 }
37 }
38
38
@@ -51,6 +51,16 @@ impl AppState {
51 self.load_calendar_week(cx);
51 self.load_calendar_week(cx);
52 }
52 }
53
53
54 pub fn show_calendar_date(&mut self, date: NaiveDate, cx: &mut Context<Self>) {
55 self.calendar_week.start = Some(self.calendar_week.span.start_for(date));
56 self.load_calendar_week(cx);
57 }
58
59 pub fn show_calendar_day(&mut self, date: NaiveDate, cx: &mut Context<Self>) {
60 self.calendar_week.span = CalendarSpan::Day;
61 self.show_calendar_date(date, cx);
62 }
63
54 fn load_calendar_week(&mut self, cx: &mut Context<Self>) {
64 fn load_calendar_week(&mut self, cx: &mut Context<Self>) {
55 let start = self.calendar_start();
65 let start = self.calendar_start();
56 let offset = Local::now().offset().fix();
66 let offset = Local::now().offset().fix();
crates/app/src/views/calendar_date_picker.rs added +200 −0
@@ -0,0 +1,200 @@
1 use std::cell::RefCell;
2 use std::rc::Rc;
3
4 use chrono::{Datelike, Duration, Local, Months, NaiveDate};
5 use gpui_kit::assets::IconName;
6 use gpui_kit::component::Sizable as _;
7 use gpui_kit::component::button::{Button, ButtonVariants as _};
8 use gpui_kit::component::popover::{Popover, PopoverState};
9 use gpui_kit::component::{h_flex, v_flex};
10 use gpui_kit::prelude::FluentBuilder as _;
11 use gpui_kit::*;
12
13 use crate::app_state::AppState;
14 use crate::call::week_grid::{MONTH_GRID_DAYS, first_of_month, month_grid_start};
15 use crate::theme;
16
17 pub const DATE_PICKER_TAG: &str = "shell/islands/calendar/date-picker";
18 const WEEKDAY_LETTERS: [&str; 7] = ["M", "T", "W", "T", "F", "S", "S"];
19 const CELL_SIZE: f32 = 32.;
20 const PICKER_PADDING: f32 = 12.;
21
22 pub struct DatePicker {
23 app: Entity<AppState>,
24 month: NaiveDate,
25 shown_start: NaiveDate,
26 shown_days: i64,
27 popover: WeakEntity<PopoverState>,
28 }
29
30 impl DatePicker {
31 fn new(
32 app: Entity<AppState>,
33 shown_start: NaiveDate,
34 shown_days: i64,
35 month: NaiveDate,
36 popover: WeakEntity<PopoverState>,
37 ) -> Self {
38 DatePicker {
39 app,
40 month: first_of_month(month),
41 shown_start,
42 shown_days,
43 popover,
44 }
45 }
46
47 fn move_month(&mut self, forward: bool, cx: &mut Context<Self>) {
48 let moved = if forward {
49 self.month.checked_add_months(Months::new(1))
50 } else {
51 self.month.checked_sub_months(Months::new(1))
52 };
53 self.month = moved.unwrap_or(self.month);
54 cx.notify();
55 }
56
57 fn pick(&mut self, date: NaiveDate, window: &mut Window, cx: &mut Context<Self>) {
58 self.app
59 .update(cx, |state, cx| state.show_calendar_date(date, cx));
60 self.popover
61 .update(cx, |popover, cx| popover.dismiss(window, cx))
62 .ok();
63 }
64
65 fn day_cell(&self, date: NaiveDate, today: NaiveDate, cx: &mut Context<Self>) -> Stateful<Div> {
66 let in_month = date.month() == self.month.month();
67 let shown = self.shown_start <= date && date < self.shown_start + Duration::days(self.shown_days);
68 let is_today = date == today;
69 div()
70 .id(SharedString::from(format!("date-picker-{date}")))
71 .size(px(CELL_SIZE))
72 .flex()
73 .items_center()
74 .justify_center()
75 .rounded_full()
76 .cursor_pointer()
77 .text_size(px(12.))
78 .text_color(if in_month {
79 theme::text()
80 } else {
81 theme::text_faint()
82 })
83 .when(shown && !is_today, |cell| cell.bg(theme::popup_hover()))
84 .when(is_today, |cell| {
85 cell.bg(theme::accent()).text_color(theme::on_accent())
86 })
87 .when(!is_today, |cell| cell.hover(|cell| cell.bg(theme::border_strong())))
88 .child(date.day().to_string())
89 .on_click(cx.listener(move |this, _, window, cx| this.pick(date, window, cx)))
90 }
91 }
92
93 impl Render for DatePicker {
94 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
95 let today = Local::now().date_naive();
96 let start = month_grid_start(self.month);
97 let days: Vec<NaiveDate> = (0..MONTH_GRID_DAYS)
98 .map(|offset| start + Duration::days(offset))
99 .collect();
100 let weeks = days
101 .chunks(7)
102 .map(|week| {
103 h_flex().children(
104 week.iter()
105 .map(|date| self.day_cell(*date, today, cx))
106 .collect::<Vec<_>>(),
107 )
108 })
109 .collect::<Vec<_>>();
110 v_flex()
111 .debug_selector(|| DATE_PICKER_TAG.into())
112 .p(px(PICKER_PADDING))
113 .gap(px(4.))
114 .child(
115 h_flex()
116 .items_center()
117 .justify_between()
118 .pb(px(4.))
119 .child(
120 div()
121 .pl(px(6.))
122 .text_size(px(14.))
123 .font_weight(FontWeight::SEMIBOLD)
124 .text_color(theme::text())
125 .child(self.month.format("%B %Y").to_string()),
126 )
127 .child(
128 h_flex()
129 .child(
130 Button::new("date-picker-back")
131 .small()
132 .ghost()
133 .icon(IconName::ChevronLeft)
134 .tooltip("Previous month")
135 .on_click(cx.listener(|this, _, _, cx| this.move_month(false, cx))),
136 )
137 .child(
138 Button::new("date-picker-forward")
139 .small()
140 .ghost()
141 .icon(IconName::ChevronRight)
142 .tooltip("Next month")
143 .on_click(cx.listener(|this, _, _, cx| this.move_month(true, cx))),
144 ),
145 ),
146 )
147 .child(
148 h_flex().children(WEEKDAY_LETTERS.iter().map(|letter| {
149 div()
150 .size(px(CELL_SIZE))
151 .flex()
152 .items_center()
153 .justify_center()
154 .text_size(px(11.))
155 .text_color(theme::text_muted())
156 .child(*letter)
157 })),
158 )
159 .children(weeks)
160 }
161 }
162
163 pub fn date_picker_button(
164 app: &Entity<AppState>,
165 title: String,
166 shown_start: NaiveDate,
167 shown_days: i64,
168 month: NaiveDate,
169 ) -> AnyElement {
170 let app = app.clone();
171 let picker: Rc<RefCell<Option<Entity<DatePicker>>>> = Rc::default();
172 let reset = picker.clone();
173 Popover::new("calendar-date-picker")
174 .anchor(Anchor::TopLeft)
175 .p(px(0.))
176 .trigger(
177 Button::new("calendar-date-title")
178 .small()
179 .ghost()
180 .label(title)
181 .dropdown_caret(true),
182 )
183 .on_open_change(move |open, _, _| {
184 if !*open {
185 reset.borrow_mut().take();
186 }
187 })
188 .content(move |_, _, cx| {
189 if let Some(existing) = picker.borrow().clone() {
190 return existing;
191 }
192 let popover = cx.entity().downgrade();
193 let app = app.clone();
194 let created =
195 cx.new(|_| DatePicker::new(app, shown_start, shown_days, month, popover));
196 *picker.borrow_mut() = Some(created.clone());
197 created
198 })
199 .into_any_element()
200 }
@@ -0,0 +1,200 @@
1use std::cell::RefCell;
2use std::rc::Rc;
3
4use chrono::{Datelike, Duration, Local, Months, NaiveDate};
5use gpui_kit::assets::IconName;
6use gpui_kit::component::Sizable as _;
7use gpui_kit::component::button::{Button, ButtonVariants as _};
8use gpui_kit::component::popover::{Popover, PopoverState};
9use gpui_kit::component::{h_flex, v_flex};
10use gpui_kit::prelude::FluentBuilder as _;
11use gpui_kit::*;
12
13use crate::app_state::AppState;
14use crate::call::week_grid::{MONTH_GRID_DAYS, first_of_month, month_grid_start};
15use crate::theme;
16
17pub const DATE_PICKER_TAG: &str = "shell/islands/calendar/date-picker";
18const WEEKDAY_LETTERS: [&str; 7] = ["M", "T", "W", "T", "F", "S", "S"];
19const CELL_SIZE: f32 = 32.;
20const PICKER_PADDING: f32 = 12.;
21
22pub struct DatePicker {
23 app: Entity<AppState>,
24 month: NaiveDate,
25 shown_start: NaiveDate,
26 shown_days: i64,
27 popover: WeakEntity<PopoverState>,
28}
29
30impl DatePicker {
31 fn new(
32 app: Entity<AppState>,
33 shown_start: NaiveDate,
34 shown_days: i64,
35 month: NaiveDate,
36 popover: WeakEntity<PopoverState>,
37 ) -> Self {
38 DatePicker {
39 app,
40 month: first_of_month(month),
41 shown_start,
42 shown_days,
43 popover,
44 }
45 }
46
47 fn move_month(&mut self, forward: bool, cx: &mut Context<Self>) {
48 let moved = if forward {
49 self.month.checked_add_months(Months::new(1))
50 } else {
51 self.month.checked_sub_months(Months::new(1))
52 };
53 self.month = moved.unwrap_or(self.month);
54 cx.notify();
55 }
56
57 fn pick(&mut self, date: NaiveDate, window: &mut Window, cx: &mut Context<Self>) {
58 self.app
59 .update(cx, |state, cx| state.show_calendar_date(date, cx));
60 self.popover
61 .update(cx, |popover, cx| popover.dismiss(window, cx))
62 .ok();
63 }
64
65 fn day_cell(&self, date: NaiveDate, today: NaiveDate, cx: &mut Context<Self>) -> Stateful<Div> {
66 let in_month = date.month() == self.month.month();
67 let shown = self.shown_start <= date && date < self.shown_start + Duration::days(self.shown_days);
68 let is_today = date == today;
69 div()
70 .id(SharedString::from(format!("date-picker-{date}")))
71 .size(px(CELL_SIZE))
72 .flex()
73 .items_center()
74 .justify_center()
75 .rounded_full()
76 .cursor_pointer()
77 .text_size(px(12.))
78 .text_color(if in_month {
79 theme::text()
80 } else {
81 theme::text_faint()
82 })
83 .when(shown && !is_today, |cell| cell.bg(theme::popup_hover()))
84 .when(is_today, |cell| {
85 cell.bg(theme::accent()).text_color(theme::on_accent())
86 })
87 .when(!is_today, |cell| cell.hover(|cell| cell.bg(theme::border_strong())))
88 .child(date.day().to_string())
89 .on_click(cx.listener(move |this, _, window, cx| this.pick(date, window, cx)))
90 }
91}
92
93impl Render for DatePicker {
94 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
95 let today = Local::now().date_naive();
96 let start = month_grid_start(self.month);
97 let days: Vec<NaiveDate> = (0..MONTH_GRID_DAYS)
98 .map(|offset| start + Duration::days(offset))
99 .collect();
100 let weeks = days
101 .chunks(7)
102 .map(|week| {
103 h_flex().children(
104 week.iter()
105 .map(|date| self.day_cell(*date, today, cx))
106 .collect::<Vec<_>>(),
107 )
108 })
109 .collect::<Vec<_>>();
110 v_flex()
111 .debug_selector(|| DATE_PICKER_TAG.into())
112 .p(px(PICKER_PADDING))
113 .gap(px(4.))
114 .child(
115 h_flex()
116 .items_center()
117 .justify_between()
118 .pb(px(4.))
119 .child(
120 div()
121 .pl(px(6.))
122 .text_size(px(14.))
123 .font_weight(FontWeight::SEMIBOLD)
124 .text_color(theme::text())
125 .child(self.month.format("%B %Y").to_string()),
126 )
127 .child(
128 h_flex()
129 .child(
130 Button::new("date-picker-back")
131 .small()
132 .ghost()
133 .icon(IconName::ChevronLeft)
134 .tooltip("Previous month")
135 .on_click(cx.listener(|this, _, _, cx| this.move_month(false, cx))),
136 )
137 .child(
138 Button::new("date-picker-forward")
139 .small()
140 .ghost()
141 .icon(IconName::ChevronRight)
142 .tooltip("Next month")
143 .on_click(cx.listener(|this, _, _, cx| this.move_month(true, cx))),
144 ),
145 ),
146 )
147 .child(
148 h_flex().children(WEEKDAY_LETTERS.iter().map(|letter| {
149 div()
150 .size(px(CELL_SIZE))
151 .flex()
152 .items_center()
153 .justify_center()
154 .text_size(px(11.))
155 .text_color(theme::text_muted())
156 .child(*letter)
157 })),
158 )
159 .children(weeks)
160 }
161}
162
163pub fn date_picker_button(
164 app: &Entity<AppState>,
165 title: String,
166 shown_start: NaiveDate,
167 shown_days: i64,
168 month: NaiveDate,
169) -> AnyElement {
170 let app = app.clone();
171 let picker: Rc<RefCell<Option<Entity<DatePicker>>>> = Rc::default();
172 let reset = picker.clone();
173 Popover::new("calendar-date-picker")
174 .anchor(Anchor::TopLeft)
175 .p(px(0.))
176 .trigger(
177 Button::new("calendar-date-title")
178 .small()
179 .ghost()
180 .label(title)
181 .dropdown_caret(true),
182 )
183 .on_open_change(move |open, _, _| {
184 if !*open {
185 reset.borrow_mut().take();
186 }
187 })
188 .content(move |_, _, cx| {
189 if let Some(existing) = picker.borrow().clone() {
190 return existing;
191 }
192 let popover = cx.entity().downgrade();
193 let app = app.clone();
194 let created =
195 cx.new(|_| DatePicker::new(app, shown_start, shown_days, month, popover));
196 *picker.borrow_mut() = Some(created.clone());
197 created
198 })
199 .into_any_element()
200}
crates/app/src/views/calendar_month.rs added +216 −0
@@ -0,0 +1,216 @@
1 use app_base::format::clock_format;
2 use chatsvc::CalendarEvent;
3 use chrono::{Datelike, FixedOffset, NaiveDate};
4 use gpui_kit::component::{h_flex, v_flex};
5 use gpui_kit::prelude::FluentBuilder as _;
6 use gpui_kit::*;
7
8 use crate::app_state::AppState;
9 use crate::call::week_grid::{WeekDay, month_shown};
10 use crate::theme;
11
12 pub const MONTH_GRID_TAG: &str = "shell/islands/calendar/month";
13 const WEEKDAY_NAMES: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
14 const WEEKDAY_HEADER_HEIGHT: f32 = 32.;
15 const VISIBLE_EVENTS: usize = 3;
16 const DAY_NUMBER_SIZE: f32 = 24.;
17 const CHIP_HEIGHT: f32 = 20.;
18
19 fn day_events(day: &WeekDay) -> Vec<usize> {
20 let mut timed: Vec<(i64, usize)> = day
21 .blocks
22 .iter()
23 .map(|block| (block.start_minute, block.event_index))
24 .collect();
25 timed.sort();
26 day.all_day
27 .iter()
28 .copied()
29 .chain(timed.into_iter().map(|(_, index)| index))
30 .collect()
31 }
32
33 fn more_label(hidden: usize) -> String {
34 format!("+{hidden} more")
35 }
36
37 fn event_chip(event: &CalendarEvent, offset: FixedOffset) -> Div {
38 let time = (!event.all_day).then(|| {
39 event
40 .start
41 .with_timezone(&offset)
42 .format(clock_format())
43 .to_string()
44 });
45 h_flex()
46 .h(px(CHIP_HEIGHT))
47 .flex_none()
48 .w_full()
49 .px(px(6.))
50 .gap(px(6.))
51 .items_center()
52 .rounded(px(4.))
53 .bg(theme::accent().opacity(if event.all_day { 0.28 } else { 0.14 }))
54 .text_size(px(11.5))
55 .text_color(theme::text())
56 .children(time.map(|time| {
57 div()
58 .flex_none()
59 .text_color(theme::text_soft())
60 .child(time)
61 }))
62 .child(div().flex_1().min_w_0().truncate().child(event.subject.clone()))
63 }
64
65 fn day_cell(
66 state: &Entity<AppState>,
67 day: &WeekDay,
68 events: &[CalendarEvent],
69 shown_month: NaiveDate,
70 today: NaiveDate,
71 offset: FixedOffset,
72 ) -> Stateful<Div> {
73 let date = day.date;
74 let in_month = date.month() == shown_month.month();
75 let is_today = date == today;
76 let indexes = day_events(day);
77 let hidden = indexes.len().saturating_sub(VISIBLE_EVENTS);
78 let number = if date.day() == 1 {
79 date.format("%b %-d").to_string()
80 } else {
81 date.day().to_string()
82 };
83 let open_state = state.clone();
84 v_flex()
85 .id(SharedString::from(format!("calendar-month-{date}")))
86 .flex_1()
87 .min_w_0()
88 .h_full()
89 .p(px(4.))
90 .gap(px(2.))
91 .overflow_hidden()
92 .cursor_pointer()
93 .when(!in_month, |cell| cell.bg(theme::background().opacity(0.35)))
94 .hover(|cell| cell.bg(theme::row_hover()))
95 .child(
96 h_flex().child(
97 div()
98 .h(px(DAY_NUMBER_SIZE))
99 .min_w(px(DAY_NUMBER_SIZE))
100 .px(px(6.))
101 .flex()
102 .items_center()
103 .justify_center()
104 .rounded_full()
105 .text_size(px(12.))
106 .when(is_today, |number| {
107 number
108 .bg(theme::accent())
109 .text_color(theme::on_accent())
110 .font_weight(FontWeight::SEMIBOLD)
111 })
112 .when(!is_today, |number| {
113 number.text_color(if in_month {
114 theme::text()
115 } else {
116 theme::text_faint()
117 })
118 })
119 .child(number),
120 ),
121 )
122 .children(
123 indexes
124 .iter()
125 .take(VISIBLE_EVENTS)
126 .filter_map(|index| events.get(*index))
127 .map(|event| event_chip(event, offset)),
128 )
129 .when(hidden > 0, |cell| {
130 cell.child(
131 div()
132 .px(px(6.))
133 .text_size(px(11.5))
134 .text_color(theme::text_muted())
135 .child(more_label(hidden)),
136 )
137 })
138 .on_click(move |_, _, cx| {
139 open_state.update(cx, |state, cx| state.show_calendar_day(date, cx));
140 })
141 }
142
143 fn horizontal_line() -> Div {
144 div().w_full().h(px(1.)).flex_none().bg(theme::border())
145 }
146
147 fn vertical_line() -> Div {
148 div().w(px(1.)).h_full().flex_none().bg(theme::border())
149 }
150
151 pub fn month_grid(
152 state: &Entity<AppState>,
153 start: NaiveDate,
154 days: &[WeekDay],
155 events: &[CalendarEvent],
156 today: NaiveDate,
157 offset: FixedOffset,
158 ) -> Div {
159 let shown_month = month_shown(start);
160 let mut rows = v_flex().flex_1().min_h_0().w_full();
161 for week in days.chunks(7) {
162 let mut row = h_flex().flex_1().min_h_0().w_full();
163 for (position, day) in week.iter().enumerate() {
164 if position > 0 {
165 row = row.child(vertical_line());
166 }
167 row = row.child(day_cell(state, day, events, shown_month, today, offset));
168 }
169 rows = rows.child(horizontal_line()).child(row);
170 }
171 v_flex()
172 .debug_selector(|| MONTH_GRID_TAG.into())
173 .flex_1()
174 .min_h_0()
175 .w_full()
176 .child(
177 h_flex()
178 .h(px(WEEKDAY_HEADER_HEIGHT))
179 .flex_none()
180 .w_full()
181 .children(WEEKDAY_NAMES.iter().map(|name| {
182 div()
183 .flex_1()
184 .px(px(10.))
185 .text_size(px(12.))
186 .text_color(theme::text_muted())
187 .child(*name)
188 })),
189 )
190 .child(rows)
191 }
192
193 #[cfg(test)]
194 mod tests {
195 use super::{WeekDay, day_events, more_label};
196 use crate::call::week_grid::WeekBlock;
197 use chrono::NaiveDate;
198
199 #[test]
200 fn a_day_lists_all_day_events_first_then_by_start() {
201 let block = |event_index, start_minute| WeekBlock {
202 event_index,
203 start_minute,
204 end_minute: start_minute + 30,
205 lane: 0,
206 lanes: 1,
207 };
208 let day = WeekDay {
209 date: NaiveDate::from_ymd_opt(2026, 11, 9).unwrap(),
210 all_day: vec![4],
211 blocks: vec![block(2, 600), block(1, 540)],
212 };
213 assert_eq!(day_events(&day), [4, 1, 2]);
214 assert_eq!(more_label(2), "+2 more");
215 }
216 }
@@ -0,0 +1,216 @@
1use app_base::format::clock_format;
2use chatsvc::CalendarEvent;
3use chrono::{Datelike, FixedOffset, NaiveDate};
4use gpui_kit::component::{h_flex, v_flex};
5use gpui_kit::prelude::FluentBuilder as _;
6use gpui_kit::*;
7
8use crate::app_state::AppState;
9use crate::call::week_grid::{WeekDay, month_shown};
10use crate::theme;
11
12pub const MONTH_GRID_TAG: &str = "shell/islands/calendar/month";
13const WEEKDAY_NAMES: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
14const WEEKDAY_HEADER_HEIGHT: f32 = 32.;
15const VISIBLE_EVENTS: usize = 3;
16const DAY_NUMBER_SIZE: f32 = 24.;
17const CHIP_HEIGHT: f32 = 20.;
18
19fn day_events(day: &WeekDay) -> Vec<usize> {
20 let mut timed: Vec<(i64, usize)> = day
21 .blocks
22 .iter()
23 .map(|block| (block.start_minute, block.event_index))
24 .collect();
25 timed.sort();
26 day.all_day
27 .iter()
28 .copied()
29 .chain(timed.into_iter().map(|(_, index)| index))
30 .collect()
31}
32
33fn more_label(hidden: usize) -> String {
34 format!("+{hidden} more")
35}
36
37fn event_chip(event: &CalendarEvent, offset: FixedOffset) -> Div {
38 let time = (!event.all_day).then(|| {
39 event
40 .start
41 .with_timezone(&offset)
42 .format(clock_format())
43 .to_string()
44 });
45 h_flex()
46 .h(px(CHIP_HEIGHT))
47 .flex_none()
48 .w_full()
49 .px(px(6.))
50 .gap(px(6.))
51 .items_center()
52 .rounded(px(4.))
53 .bg(theme::accent().opacity(if event.all_day { 0.28 } else { 0.14 }))
54 .text_size(px(11.5))
55 .text_color(theme::text())
56 .children(time.map(|time| {
57 div()
58 .flex_none()
59 .text_color(theme::text_soft())
60 .child(time)
61 }))
62 .child(div().flex_1().min_w_0().truncate().child(event.subject.clone()))
63}
64
65fn day_cell(
66 state: &Entity<AppState>,
67 day: &WeekDay,
68 events: &[CalendarEvent],
69 shown_month: NaiveDate,
70 today: NaiveDate,
71 offset: FixedOffset,
72) -> Stateful<Div> {
73 let date = day.date;
74 let in_month = date.month() == shown_month.month();
75 let is_today = date == today;
76 let indexes = day_events(day);
77 let hidden = indexes.len().saturating_sub(VISIBLE_EVENTS);
78 let number = if date.day() == 1 {
79 date.format("%b %-d").to_string()
80 } else {
81 date.day().to_string()
82 };
83 let open_state = state.clone();
84 v_flex()
85 .id(SharedString::from(format!("calendar-month-{date}")))
86 .flex_1()
87 .min_w_0()
88 .h_full()
89 .p(px(4.))
90 .gap(px(2.))
91 .overflow_hidden()
92 .cursor_pointer()
93 .when(!in_month, |cell| cell.bg(theme::background().opacity(0.35)))
94 .hover(|cell| cell.bg(theme::row_hover()))
95 .child(
96 h_flex().child(
97 div()
98 .h(px(DAY_NUMBER_SIZE))
99 .min_w(px(DAY_NUMBER_SIZE))
100 .px(px(6.))
101 .flex()
102 .items_center()
103 .justify_center()
104 .rounded_full()
105 .text_size(px(12.))
106 .when(is_today, |number| {
107 number
108 .bg(theme::accent())
109 .text_color(theme::on_accent())
110 .font_weight(FontWeight::SEMIBOLD)
111 })
112 .when(!is_today, |number| {
113 number.text_color(if in_month {
114 theme::text()
115 } else {
116 theme::text_faint()
117 })
118 })
119 .child(number),
120 ),
121 )
122 .children(
123 indexes
124 .iter()
125 .take(VISIBLE_EVENTS)
126 .filter_map(|index| events.get(*index))
127 .map(|event| event_chip(event, offset)),
128 )
129 .when(hidden > 0, |cell| {
130 cell.child(
131 div()
132 .px(px(6.))
133 .text_size(px(11.5))
134 .text_color(theme::text_muted())
135 .child(more_label(hidden)),
136 )
137 })
138 .on_click(move |_, _, cx| {
139 open_state.update(cx, |state, cx| state.show_calendar_day(date, cx));
140 })
141}
142
143fn horizontal_line() -> Div {
144 div().w_full().h(px(1.)).flex_none().bg(theme::border())
145}
146
147fn vertical_line() -> Div {
148 div().w(px(1.)).h_full().flex_none().bg(theme::border())
149}
150
151pub fn month_grid(
152 state: &Entity<AppState>,
153 start: NaiveDate,
154 days: &[WeekDay],
155 events: &[CalendarEvent],
156 today: NaiveDate,
157 offset: FixedOffset,
158) -> Div {
159 let shown_month = month_shown(start);
160 let mut rows = v_flex().flex_1().min_h_0().w_full();
161 for week in days.chunks(7) {
162 let mut row = h_flex().flex_1().min_h_0().w_full();
163 for (position, day) in week.iter().enumerate() {
164 if position > 0 {
165 row = row.child(vertical_line());
166 }
167 row = row.child(day_cell(state, day, events, shown_month, today, offset));
168 }
169 rows = rows.child(horizontal_line()).child(row);
170 }
171 v_flex()
172 .debug_selector(|| MONTH_GRID_TAG.into())
173 .flex_1()
174 .min_h_0()
175 .w_full()
176 .child(
177 h_flex()
178 .h(px(WEEKDAY_HEADER_HEIGHT))
179 .flex_none()
180 .w_full()
181 .children(WEEKDAY_NAMES.iter().map(|name| {
182 div()
183 .flex_1()
184 .px(px(10.))
185 .text_size(px(12.))
186 .text_color(theme::text_muted())
187 .child(*name)
188 })),
189 )
190 .child(rows)
191}
192
193#[cfg(test)]
194mod tests {
195 use super::{WeekDay, day_events, more_label};
196 use crate::call::week_grid::WeekBlock;
197 use chrono::NaiveDate;
198
199 #[test]
200 fn a_day_lists_all_day_events_first_then_by_start() {
201 let block = |event_index, start_minute| WeekBlock {
202 event_index,
203 start_minute,
204 end_minute: start_minute + 30,
205 lane: 0,
206 lanes: 1,
207 };
208 let day = WeekDay {
209 date: NaiveDate::from_ymd_opt(2026, 11, 9).unwrap(),
210 all_day: vec![4],
211 blocks: vec![block(2, 600), block(1, 540)],
212 };
213 assert_eq!(day_events(&day), [4, 1, 2]);
214 assert_eq!(more_label(2), "+2 more");
215 }
216}
crates/app/src/views/calendar_view.rs +32 −19
@@ -9,13 +9,15 @@ use gpui_kit::component::{h_flex, v_flex};
9 9 use gpui_kit::prelude::FluentBuilder as _;
10 10 use gpui_kit::*;
11 11
12 use super::calendar_date_picker::date_picker_button;
13 use super::calendar_month::month_grid;
12 14 use super::rsvp_menu::rsvp_menu;
13 15 use super::join_dialog::open_join_with_id;
14 16 use super::new_meeting_dialog::open_new_meeting;
15 17 use crate::app_state::AppState;
16 18 use crate::call::join_available;
17 19 use crate::call::week_grid::{
18 CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, range_label, week_days,
20 CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, month_shown, week_days,
19 21 };
20 22 use crate::theme;
21 23
@@ -93,10 +95,10 @@ impl CalendarView {
93 95 .small()
94 96 .ghost()
95 97 .icon(IconName::ChevronLeft)
96 .tooltip(if span == CalendarSpan::Day {
97 "Go to previous day"
98 } else {
99 "Go to previous week"
98 .tooltip(match span {
99 CalendarSpan::Day => "Go to previous day",
100 CalendarSpan::Month => "Go to previous month",
101 _ => "Go to previous week",
100 102 })
101 103 .on_click(move |_, _, cx| {
102 104 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
@@ -107,23 +109,27 @@ impl CalendarView {
107 109 .small()
108 110 .ghost()
109 111 .icon(IconName::ChevronRight)
110 .tooltip(if span == CalendarSpan::Day {
111 "Go to next day"
112 } else {
113 "Go to next week"
112 .tooltip(match span {
113 CalendarSpan::Day => "Go to next day",
114 CalendarSpan::Month => "Go to next month",
115 _ => "Go to next week",
114 116 })
115 117 .on_click(move |_, _, cx| {
116 118 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
117 119 }),
118 120 )
119 121 .child(
120 div()
121 .flex_1()
122 .min_w_0()
123 .truncate()
124 .text_size(px(14.))
125 .font_weight(FontWeight::SEMIBOLD)
126 .child(range_label(start, span.days())),
122 h_flex().flex_1().min_w_0().child(date_picker_button(
123 &self.state,
124 span.title(start),
125 start,
126 span.days(),
127 if span == CalendarSpan::Month {
128 month_shown(start)
129 } else {
130 start
131 },
132 )),
127 133 )
128 134 .child(
129 135 Button::new("calendar-span")
@@ -579,8 +585,15 @@ impl Render for CalendarView {
579 585 .bg(theme::surface())
580 586 .overflow_hidden()
581 587 .child(self.header(start, span, compact))
582 .child(self.day_headers(&days, today))
583 .children(self.all_day_row(&days, &events))
584 .child(self.grid(&days, &events, today, now, send_response))
588 .map(|calendar| {
589 if span == CalendarSpan::Month {
590 calendar.child(month_grid(&self.state, start, &days, &events, today, offset))
591 } else {
592 calendar
593 .child(self.day_headers(&days, today))
594 .children(self.all_day_row(&days, &events))
595 .child(self.grid(&days, &events, today, now, send_response))
596 }
597 })
585 598 }
586 599 }
@@ -9,13 +9,15 @@ use gpui_kit::component::{h_flex, v_flex};
9use gpui_kit::prelude::FluentBuilder as _;
9use gpui_kit::prelude::FluentBuilder as _;
10use gpui_kit::*;
10use gpui_kit::*;
11
11
12use super::calendar_date_picker::date_picker_button;
13use super::calendar_month::month_grid;
12use super::rsvp_menu::rsvp_menu;
14use super::rsvp_menu::rsvp_menu;
13use super::join_dialog::open_join_with_id;
15use super::join_dialog::open_join_with_id;
14use super::new_meeting_dialog::open_new_meeting;
16use super::new_meeting_dialog::open_new_meeting;
15use crate::app_state::AppState;
17use crate::app_state::AppState;
16use crate::call::join_available;
18use crate::call::join_available;
17use crate::call::week_grid::{
19use crate::call::week_grid::{
18 CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, range_label, week_days,
20 CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, month_shown, week_days,
19};
21};
20use crate::theme;
22use crate::theme;
21
23
@@ -93,10 +95,10 @@ impl CalendarView {
93 .small()
95 .small()
94 .ghost()
96 .ghost()
95 .icon(IconName::ChevronLeft)
97 .icon(IconName::ChevronLeft)
96 .tooltip(if span == CalendarSpan::Day {
98 .tooltip(match span {
97 "Go to previous day"
99 CalendarSpan::Day => "Go to previous day",
98 } else {
100 CalendarSpan::Month => "Go to previous month",
99 "Go to previous week"
101 _ => "Go to previous week",
100 })
102 })
101 .on_click(move |_, _, cx| {
103 .on_click(move |_, _, cx| {
102 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
104 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
@@ -107,23 +109,27 @@ impl CalendarView {
107 .small()
109 .small()
108 .ghost()
110 .ghost()
109 .icon(IconName::ChevronRight)
111 .icon(IconName::ChevronRight)
110 .tooltip(if span == CalendarSpan::Day {
112 .tooltip(match span {
111 "Go to next day"
113 CalendarSpan::Day => "Go to next day",
112 } else {
114 CalendarSpan::Month => "Go to next month",
113 "Go to next week"
115 _ => "Go to next week",
114 })
116 })
115 .on_click(move |_, _, cx| {
117 .on_click(move |_, _, cx| {
116 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
118 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
117 }),
119 }),
118 )
120 )
119 .child(
121 .child(
120 div()
122 h_flex().flex_1().min_w_0().child(date_picker_button(
121 .flex_1()
123 &self.state,
122 .min_w_0()
124 span.title(start),
123 .truncate()
125 start,
124 .text_size(px(14.))
126 span.days(),
125 .font_weight(FontWeight::SEMIBOLD)
127 if span == CalendarSpan::Month {
126 .child(range_label(start, span.days())),
128 month_shown(start)
129 } else {
130 start
131 },
132 )),
127 )
133 )
128 .child(
134 .child(
129 Button::new("calendar-span")
135 Button::new("calendar-span")
@@ -579,8 +585,15 @@ impl Render for CalendarView {
579 .bg(theme::surface())
585 .bg(theme::surface())
580 .overflow_hidden()
586 .overflow_hidden()
581 .child(self.header(start, span, compact))
587 .child(self.header(start, span, compact))
582 .child(self.day_headers(&days, today))
588 .map(|calendar| {
583 .children(self.all_day_row(&days, &events))
589 if span == CalendarSpan::Month {
584 .child(self.grid(&days, &events, today, now, send_response))
590 calendar.child(month_grid(&self.state, start, &days, &events, today, offset))
591 } else {
592 calendar
593 .child(self.day_headers(&days, today))
594 .children(self.all_day_row(&days, &events))
595 .child(self.grid(&days, &events, today, now, send_response))
596 }
597 })
585 }
598 }
586}
599}
crates/app/src/views/mod.rs +2 −0
@@ -25,6 +25,8 @@ pub mod call_stage;
25 25 pub mod call_transcript;
26 26 pub mod call_view;
27 27 pub mod call_view_menu;
28 pub mod calendar_date_picker;
29 pub mod calendar_month;
28 30 pub mod calendar_view;
29 31 pub mod calls_page;
30 32 mod rsvp_menu;
@@ -25,6 +25,8 @@ pub mod call_stage;
25pub mod call_transcript;
25pub mod call_transcript;
26pub mod call_view;
26pub mod call_view;
27pub mod call_view_menu;
27pub mod call_view_menu;
28pub mod calendar_date_picker;
29pub mod calendar_month;
28pub mod calendar_view;
30pub mod calendar_view;
29pub mod calls_page;
31pub mod calls_page;
30mod rsvp_menu;
32mod rsvp_menu;