BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / calendar_view.rs

calendar_view.rs

calendar_view.rs 30.3 KiB Download Raw
1use std::time::Duration;
2
3use app_base::format::{self, clock_format};
4use chatsvc::{CalendarEvent, ResponseType, join_info_text};
5use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
6use gpui_kit::assets::IconName;
7use gpui_kit::component::Sizable as _;
8use gpui_kit::component::button::{Button, ButtonVariants as _};
9use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};
10use gpui_kit::component::{h_flex, v_flex};
11use gpui_kit::prelude::FluentBuilder as _;
12use gpui_kit::*;
13
14use super::calendar_date_picker::date_picker_button;
15use super::calendar_event_dialog::open_calendar_event;
16use super::calendar_month::month_grid;
17use super::calendar_picker;
18use super::join_dialog::open_join_with_id;
19use super::meeting_proposal_card::meeting_proposal_cards;
20use super::new_meeting_dialog::open_new_meeting;
21use super::rsvp_menu::rsvp_menu;
22use super::scroll_edge::scroll_offset;
23use crate::app_state::AppState;
24use crate::call::calendar_now::{
25 DEFAULT_GRID_VIEWPORT, FollowNow, MANUAL_SCROLL_EPSILON, NOW_BIAS_FRACTION,
26 now_scroll_offset_y, offset_differs, shows_hour_grid,
27};
28use crate::call::week_grid::{
29 CalendarSpan, EventLook, WeekBlock, WeekDay, event_look, hour_label, month_shown, week_days,
30};
31use crate::i18n::tr;
32use crate::theme;
33
34const HOUR_HEIGHT: f32 = 120.;
35const QUARTERS_PER_HOUR: usize = 4;
36const QUARTER_LINE_OPACITY: f32 = 0.45;
37const GUTTER_WIDTH: f32 = 50.;
38const HEADER_HEIGHT: f32 = 52.;
39const DAY_HEADER_HEIGHT: f32 = 56.;
40const ALL_DAY_HEIGHT: f32 = 26.;
41const BLOCK_GAP: f32 = 2.;
42const CANCELED_PREFIX: &str = "Canceled: ";
43const COPY_JOIN_INFO: &str = "Copy join info";
44const COMPACT_HEADER_WIDTH: f32 = 960.;
45const BUSY_FILL_OPACITY: f32 = 0.28;
46const FREE_FILL_OPACITY: f32 = 0.12;
47const STATUS_BAR_WIDTH: f32 = 4.;
48const HATCH_STRIPE: f32 = 1.5;
49const HATCH_GAP: f32 = 2.5;
50const SMALL_TITLE_HEIGHT: f32 = 20.;
51const TODAY_MARK_HEIGHT: f32 = 3.;
52const NOW_DOT_SIZE: f32 = 8.;
53const CLOCK_TICK: Duration = Duration::from_secs(30);
54const CHROME_HEIGHT: f32 = HEADER_HEIGHT + DAY_HEADER_HEIGHT + ALL_DAY_HEIGHT;
55
56pub struct CalendarView {
57 state: Entity<AppState>,
58 scroll: ScrollHandle,
59 follow_now: FollowNow,
60 seen_scroll_to_now: u64,
61 last_programmatic_offset: f32,
62 skip_manual_check: bool,
63 clock_running: bool,
64 _observation: Subscription,
65 _agent_observation: Option<Subscription>,
66}
67
68impl CalendarView {
69 pub fn new(state: Entity<AppState>, cx: &mut Context<Self>) -> Self {
70 let observation = cx.observe(&state, |_, _, cx| cx.notify());
71 let agent_observation =
72 crate::agent_api::handle(cx).map(|api| cx.observe(&api, |_, _, cx| cx.notify()));
73 CalendarView {
74 state,
75 scroll: ScrollHandle::new(),
76 follow_now: FollowNow { active: true },
77 seen_scroll_to_now: 0,
78 last_programmatic_offset: 0.,
79 skip_manual_check: false,
80 clock_running: false,
81 _observation: observation,
82 _agent_observation: agent_observation,
83 }
84 }
85
86 fn grid_viewport_height(window: &Window) -> f32 {
87 (f32::from(window.viewport_size().height) - CHROME_HEIGHT).max(DEFAULT_GRID_VIEWPORT * 0.5)
88 }
89
90 fn align_scroll_to_now(&mut self, window: &Window) {
91 let local = Local::now();
92 let offset = now_scroll_offset_y(
93 local.hour(),
94 local.minute(),
95 HOUR_HEIGHT,
96 Self::grid_viewport_height(window),
97 NOW_BIAS_FRACTION,
98 );
99 self.scroll.set_offset(point(px(0.), px(offset)));
100 self.last_programmatic_offset = offset;
101 self.skip_manual_check = true;
102 }
103
104 fn sync_follow_from_state(&mut self, window: &Window, cx: &mut Context<Self>) {
105 let (scroll_to_now, span, today_visible) = {
106 let state = self.state.read(cx);
107 let start = state.calendar_start();
108 let today = Local::now().date_naive();
109 let today_visible = start <= today
110 && today < start + chrono::Duration::days(state.calendar_week.span.days());
111 (
112 state.calendar_scroll_to_now,
113 state.calendar_week.span,
114 today_visible,
115 )
116 };
117 if !shows_hour_grid(span) {
118 self.stop_clock();
119 return;
120 }
121 self.ensure_clock(cx);
122 if scroll_to_now != self.seen_scroll_to_now {
123 self.seen_scroll_to_now = scroll_to_now;
124 self.follow_now.request_align();
125 }
126 if self.skip_manual_check {
127 self.skip_manual_check = false;
128 } else if self.follow_now.active
129 && offset_differs(
130 f32::from(scroll_offset(&self.scroll).y),
131 self.last_programmatic_offset,
132 MANUAL_SCROLL_EPSILON,
133 )
134 {
135 self.follow_now.note_manual_scroll();
136 }
137 if self.follow_now.should_follow(today_visible) {
138 self.align_scroll_to_now(window);
139 }
140 }
141
142 fn ensure_clock(&mut self, cx: &mut Context<Self>) {
143 if self.clock_running {
144 return;
145 }
146 self.clock_running = true;
147 cx.spawn(async move |this, cx| {
148 loop {
149 cx.background_executor().timer(CLOCK_TICK).await;
150 let keep = this
151 .update(cx, |view, cx| {
152 let span = view.state.read(cx).calendar_week.span;
153 if !shows_hour_grid(span) {
154 view.clock_running = false;
155 return false;
156 }
157 cx.notify();
158 true
159 })
160 .unwrap_or(false);
161 if !keep {
162 break;
163 }
164 }
165 })
166 .detach();
167 }
168
169 fn stop_clock(&mut self) {
170 self.clock_running = false;
171 }
172
173 fn on_grid_scroll_wheel(
174 &mut self,
175 _event: &ScrollWheelEvent,
176 _window: &mut Window,
177 cx: &mut Context<Self>,
178 ) {
179 self.follow_now.note_manual_scroll();
180 cx.notify();
181 }
182
183 fn header(&self, start: NaiveDate, span: CalendarSpan, compact: bool) -> impl IntoElement {
184 let span_state = self.state.clone();
185 let label = |text: &'static str| (!compact).then_some(text);
186 let (today, back, forward) = (self.state.clone(), self.state.clone(), self.state.clone());
187 let (join_state, meet_state, new_state) =
188 (self.state.clone(), self.state.clone(), self.state.clone());
189 h_flex()
190 .h(px(HEADER_HEIGHT))
191 .flex_none()
192 .items_center()
193 .gap(px(8.))
194 .px(px(16.))
195 .child(
196 div()
197 .flex_none()
198 .text_size(px(16.))
199 .font_weight(FontWeight::BOLD)
200 .mr(px(8.))
201 .child("Calendar"),
202 )
203 .child(
204 Button::new("calendar-today")
205 .small()
206 .outline()
207 .icon(IconName::Calendar)
208 .when_some(label("Today"), |button, text| button.label(text))
209 .tooltip("Today")
210 .on_click(move |_, _, cx| {
211 today.update(cx, |state, cx| state.calendar_to_today(cx))
212 }),
213 )
214 .child(
215 Button::new("calendar-back")
216 .small()
217 .ghost()
218 .icon(IconName::ChevronLeft)
219 .tooltip(match span {
220 CalendarSpan::Day => "Go to previous day",
221 CalendarSpan::Month => "Go to previous month",
222 _ => "Go to previous week",
223 })
224 .on_click(move |_, _, cx| {
225 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
226 }),
227 )
228 .child(
229 Button::new("calendar-forward")
230 .small()
231 .ghost()
232 .icon(IconName::ChevronRight)
233 .tooltip(match span {
234 CalendarSpan::Day => "Go to next day",
235 CalendarSpan::Month => "Go to next month",
236 _ => "Go to next week",
237 })
238 .on_click(move |_, _, cx| {
239 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
240 }),
241 )
242 .child(h_flex().flex_1().min_w_0().child(date_picker_button(
243 &self.state,
244 span.title(start),
245 start,
246 span.days(),
247 if span == CalendarSpan::Month {
248 month_shown(start)
249 } else {
250 start
251 },
252 )))
253 .child(
254 Button::new("calendar-span")
255 .small()
256 .ghost()
257 .label(span.label())
258 .dropdown_caret(true)
259 .dropdown_menu(move |menu, _, _| {
260 CalendarSpan::ALL.iter().fold(menu, |menu, &choice| {
261 let state = span_state.clone();
262 menu.item(
263 PopupMenuItem::new(choice.label())
264 .checked(choice == span)
265 .on_click(move |_, _, cx| {
266 state.update(cx, |state, cx| {
267 state.set_calendar_span(choice, cx)
268 })
269 }),
270 )
271 })
272 }),
273 )
274 .child(
275 Button::new("calendar-join-id")
276 .small()
277 .outline()
278 .icon(IconName::Hash)
279 .when_some(label("Join with an ID"), |button, text| button.label(text))
280 .tooltip("Join with an ID")
281 .on_click(move |_, window, cx| {
282 open_join_with_id(join_state.clone(), window, cx)
283 }),
284 )
285 .child(
286 Button::new("calendar-meet-now")
287 .small()
288 .outline()
289 .icon(IconName::Video)
290 .when_some(label("Meet now"), |button, text| button.label(text))
291 .tooltip("Meet now")
292 .on_click(move |_, _, cx| {
293 meet_state.update(cx, |state, cx| state.start_meet_now(cx))
294 }),
295 )
296 .child(
297 Button::new("calendar-new-meeting")
298 .small()
299 .primary()
300 .icon(IconName::Plus)
301 .when_some(label("New meeting"), |button, text| button.label(text))
302 .tooltip("New meeting")
303 .on_click(move |_, window, cx| open_new_meeting(new_state.clone(), window, cx)),
304 )
305 }
306
307 fn day_headers(&self, days: &[WeekDay], today: NaiveDate) -> impl IntoElement {
308 h_flex()
309 .h(px(DAY_HEADER_HEIGHT))
310 .flex_none()
311 .border_b_1()
312 .border_color(theme::border())
313 .child(div().w(px(GUTTER_WIDTH)).flex_none())
314 .children(days.iter().map(|day| {
315 let is_today = day.date == today;
316 let color = if is_today {
317 theme::accent_text()
318 } else {
319 theme::text_soft()
320 };
321 v_flex()
322 .relative()
323 .flex_1()
324 .min_w_0()
325 .h_full()
326 .justify_center()
327 .px(px(12.))
328 .border_l_1()
329 .border_color(theme::border())
330 .when(is_today, |header| {
331 header.child(
332 div()
333 .absolute()
334 .top_0()
335 .left_0()
336 .right_0()
337 .h(px(TODAY_MARK_HEIGHT))
338 .bg(theme::accent()),
339 )
340 })
341 .child(
342 div()
343 .text_size(px(20.))
344 .line_height(px(24.))
345 .text_color(color)
346 .child(format::calendar_day_number(day.date)),
347 )
348 .child(
349 div()
350 .text_size(px(12.))
351 .text_color(color)
352 .child(day.date.format("%a").to_string()),
353 )
354 }))
355 }
356
357 fn all_day_row(
358 &self,
359 days: &[WeekDay],
360 events: &[CalendarEvent],
361 send_response: bool,
362 ) -> Option<Div> {
363 if days.iter().all(|day| day.all_day.is_empty()) {
364 return None;
365 }
366 Some(
367 h_flex()
368 .flex_none()
369 .border_b_1()
370 .border_color(theme::border())
371 .child(div().w(px(GUTTER_WIDTH)).flex_none())
372 .children(days.iter().map(|day| {
373 v_flex()
374 .flex_1()
375 .min_w_0()
376 .gap(px(BLOCK_GAP))
377 .p(px(BLOCK_GAP))
378 .border_l_1()
379 .border_color(theme::border())
380 .children(day.all_day.iter().map(|&index| {
381 let event = events[index].clone();
382 let open_state = self.state.clone();
383 let (menu_state, menu_event) = (self.state.clone(), event.clone());
384 // Day-qualified id: multi-day all-day chips share object_id.
385 div()
386 .id(SharedString::from(format!(
387 "calendar-all-day-{}-{}",
388 event.object_id, day.date
389 )))
390 .h(px(ALL_DAY_HEIGHT - 2. * BLOCK_GAP))
391 .px(px(6.))
392 .flex()
393 .items_center()
394 .rounded(px(4.))
395 .bg(event_fill(event_look(&event)))
396 .text_size(px(12.))
397 .truncate()
398 .cursor_pointer()
399 .child(event_title(&event))
400 .on_click(move |_, window, cx| {
401 open_calendar_event(
402 open_state.clone(),
403 event.clone(),
404 window,
405 cx,
406 );
407 })
408 .context_menu(move |menu, _, _| {
409 event_menu(menu, &menu_state, &menu_event, send_response)
410 })
411 }))
412 })),
413 )
414 }
415
416 fn event_block(
417 &self,
418 block: &WeekBlock,
419 event: &CalendarEvent,
420 day: NaiveDate,
421 send_response: bool,
422 ) -> impl IntoElement {
423 let top = block.start_minute as f32 / 60. * HOUR_HEIGHT;
424 let height = ((block.end_minute - block.start_minute) as f32 / 60. * HOUR_HEIGHT
425 - BLOCK_GAP)
426 .max(14.);
427 let width = 1. / block.lanes as f32;
428 let compact = height < 36.;
429 let small = height < SMALL_TITLE_HEIGHT;
430 let look = event_look(event);
431 // Join on the block whenever a Teams link exists (same as detail dialog).
432 let can_join = event.online && !event.cancelled && event.join_url.is_some();
433 let open_state = self.state.clone();
434 let open_event = event.clone();
435 let (menu_state, menu_event) = (self.state.clone(), event.clone());
436 let (join_state, join_url, subject) = (
437 self.state.clone(),
438 event.join_url.clone(),
439 event.subject.clone(),
440 );
441 let (title_color, detail_color) = match look {
442 EventLook::Busy => (theme::text(), theme::text_soft()),
443 EventLook::Free | EventLook::Tentative => (theme::text_soft(), theme::text_muted()),
444 };
445 // Day-qualified id: overnight / multi-day spans reuse object_id per column.
446 div()
447 .id(SharedString::from(format!(
448 "calendar-event-{}-{}",
449 event.object_id, day
450 )))
451 .absolute()
452 .top(px(top))
453 .h(px(height))
454 .left(relative(width * block.lane as f32))
455 .w(relative(width))
456 .px(px(BLOCK_GAP))
457 .child(
458 h_flex()
459 .size_full()
460 .items_start()
461 .overflow_hidden()
462 .rounded(px(4.))
463 .bg(event_fill(look))
464 .when(event.cancelled, |block| block.opacity(0.6))
465 .cursor_pointer()
466 .children(status_bar(look))
467 .child(
468 v_flex()
469 .flex_1()
470 .min_w_0()
471 .pl(px(5.))
472 .pr(px(4.))
473 .h_full()
474 .py(px(if compact { 1. } else { 4. }))
475 .when(compact, |body| body.justify_center())
476 .child(
477 div()
478 .text_size(px(if small { 10. } else { 12. }))
479 .line_height(px(if small { 13. } else { 16. }))
480 .font_weight(FontWeight::SEMIBOLD)
481 .text_color(title_color)
482 .when(compact, |title| title.truncate())
483 .when(!compact, |title| title.line_clamp(2))
484 .child(event_title(event)),
485 )
486 .when(!compact, |body| {
487 body.children(event.organizer_name.clone().map(|organizer| {
488 div()
489 .text_size(px(12.))
490 .line_height(px(16.))
491 .text_color(detail_color)
492 .truncate()
493 .child(organizer)
494 }))
495 }),
496 )
497 .when(can_join, |block| {
498 block.child(
499 div().flex_none().pr(px(4.)).pt(px(3.)).h_full().child(
500 Button::new(SharedString::from(format!(
501 "calendar-join-{}-{}",
502 event.object_id, day
503 )))
504 .xsmall()
505 .primary()
506 .label(tr("common.join"))
507 .on_click(move |_, _, cx| {
508 cx.stop_propagation();
509 join_state.update(cx, |state, cx| {
510 state.join_calendar_meeting(
511 join_url.as_deref(),
512 &subject,
513 cx,
514 )
515 });
516 }),
517 ),
518 )
519 }),
520 )
521 .on_click(move |_, window, cx| {
522 open_calendar_event(open_state.clone(), open_event.clone(), window, cx);
523 })
524 .context_menu(move |menu, _, _| {
525 event_menu(menu, &menu_state, &menu_event, send_response)
526 })
527 }
528
529 fn grid(
530 &self,
531 days: &[WeekDay],
532 events: &[CalendarEvent],
533 today: NaiveDate,
534 now: DateTime<Utc>,
535 send_response: bool,
536 cx: &mut Context<Self>,
537 ) -> impl IntoElement {
538 let total_height = 24. * HOUR_HEIGHT;
539 let twelve_hour = clock_format().contains("%p") || clock_format().contains("%P");
540 let now_minute = {
541 let local = now.with_timezone(&Local);
542 local.hour() * 60 + local.minute()
543 };
544 div()
545 .id("calendar-grid")
546 .flex_1()
547 .min_h_0()
548 .overflow_y_scroll()
549 .track_scroll(&self.scroll)
550 .on_scroll_wheel(cx.listener(Self::on_grid_scroll_wheel))
551 .child(
552 h_flex()
553 .h(px(total_height))
554 .w_full()
555 .child(
556 v_flex()
557 .w(px(GUTTER_WIDTH))
558 .flex_none()
559 .children((0..24).map(|hour| {
560 div()
561 .h(px(HOUR_HEIGHT))
562 .pt(px(4.))
563 .flex()
564 .justify_center()
565 .text_size(px(12.))
566 .text_color(theme::text_soft())
567 .when(hour > 0, |label| {
568 label.child(hour_label(hour, twelve_hour))
569 })
570 })),
571 )
572 .children(days.iter().map(|day| {
573 div()
574 .relative()
575 .flex_1()
576 .min_w_0()
577 .h_full()
578 .border_l_1()
579 .border_color(theme::border())
580 .children((1..24 * QUARTERS_PER_HOUR).map(|quarter| {
581 let line = div()
582 .absolute()
583 .top(
584 px(quarter as f32 * HOUR_HEIGHT / QUARTERS_PER_HOUR as f32),
585 )
586 .left_0()
587 .right_0();
588 if quarter % QUARTERS_PER_HOUR == 0 {
589 line.h(px(1.)).bg(theme::border())
590 } else {
591 line.h(px(1.))
592 .bg(theme::border().opacity(QUARTER_LINE_OPACITY))
593 }
594 }))
595 .children(day.blocks.iter().map(|block| {
596 self.event_block(
597 block,
598 &events[block.event_index],
599 day.date,
600 send_response,
601 )
602 }))
603 .when(day.date == today, |column| {
604 let now_top = now_minute as f32 / 60. * HOUR_HEIGHT;
605 column
606 .child(
607 div()
608 .absolute()
609 .top(px(now_top - 1.))
610 .left_0()
611 .right_0()
612 .h(px(2.))
613 .bg(theme::accent()),
614 )
615 .child(
616 div()
617 .absolute()
618 .top(px(now_top - NOW_DOT_SIZE / 2.))
619 .left_0()
620 .size(px(NOW_DOT_SIZE))
621 .rounded_full()
622 .bg(theme::accent()),
623 )
624 })
625 })),
626 )
627 }
628}
629
630fn event_menu(
631 menu: PopupMenu,
632 state: &Entity<AppState>,
633 event: &CalendarEvent,
634 send_response: bool,
635) -> PopupMenu {
636 let mut menu = menu;
637 if let Some(join_url) = event
638 .join_url
639 .clone()
640 .filter(|_| event.online && !event.cancelled)
641 {
642 let (join_state, subject) = (state.clone(), event.subject.clone());
643 menu = menu.item(PopupMenuItem::new("Join").icon(IconName::Video).on_click(
644 move |_, _, cx| {
645 join_state.update(cx, |state, cx| {
646 state.join_calendar_meeting(Some(&join_url), &subject, cx)
647 })
648 },
649 ));
650 }
651 if let Some(join_url) = event.join_url.as_deref().filter(|_| event.online) {
652 let info = join_info_text(join_url, event.dial_in.as_ref());
653 menu = menu.item(
654 PopupMenuItem::new(COPY_JOIN_INFO)
655 .icon(IconName::Copy)
656 .on_click(move |_, _, cx| {
657 cx.write_to_clipboard(ClipboardItem::new_string(info.clone()))
658 }),
659 );
660 }
661 if let Some(thread_id) = event.thread_id.clone() {
662 let chat_state = state.clone();
663 menu = menu.item(
664 PopupMenuItem::new("Chat with participants")
665 .icon(IconName::MessageSquare)
666 .on_click(move |_, _, cx| {
667 chat_state.update(cx, |state, cx| {
668 state.open_meeting_chat(Some(&thread_id), cx)
669 })
670 }),
671 );
672 }
673 if event.response == ResponseType::Organizer || event.organizer_name.is_none() {
674 return menu;
675 }
676 rsvp_menu(
677 menu.separator(),
678 state,
679 &event.object_id,
680 event.response,
681 send_response,
682 )
683}
684
685fn event_fill(look: EventLook) -> Hsla {
686 match look {
687 EventLook::Busy => theme::accent().opacity(BUSY_FILL_OPACITY),
688 EventLook::Free | EventLook::Tentative => theme::accent().opacity(FREE_FILL_OPACITY),
689 }
690}
691
692fn status_bar(look: EventLook) -> Option<Div> {
693 let bar = div().flex_none().w(px(STATUS_BAR_WIDTH)).h_full();
694 match look {
695 EventLook::Busy => Some(bar.bg(theme::accent())),
696 EventLook::Tentative => Some(
697 bar.bg(theme::accent().opacity(BUSY_FILL_OPACITY)).child(
698 div()
699 .size_full()
700 .bg(pattern_slash(theme::accent(), HATCH_STRIPE, HATCH_GAP)),
701 ),
702 ),
703 EventLook::Free => None,
704 }
705}
706
707fn event_title(event: &CalendarEvent) -> String {
708 let subject = if event.cancelled {
709 format!("{CANCELED_PREFIX}{}", event.subject)
710 } else {
711 event.subject.clone()
712 };
713 let label = source_label(event);
714 if label.is_empty() {
715 subject
716 } else {
717 format!("{subject} · {label}")
718 }
719}
720
721fn source_label(event: &CalendarEvent) -> String {
722 let mut sources = event.sources.clone();
723 if sources.is_empty() {
724 sources.push(event.source);
725 }
726 sources.sort_by_key(|source| source.label());
727 sources.dedup();
728 if sources.len() == 1 && sources[0] == chatsvc::CalendarSource::Outlook {
729 return String::new();
730 }
731 sources
732 .iter()
733 .map(|source| source.label())
734 .collect::<Vec<_>>()
735 .join("+")
736}
737
738impl Render for CalendarView {
739 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
740 let compact = f32::from(window.viewport_size().width) < COMPACT_HEADER_WIDTH;
741 self.sync_follow_from_state(window, cx);
742 let state = self.state.read(cx);
743 let start = state.calendar_start();
744 let events = state.calendar_week.events.clone();
745 let send_response = state.rsvp_send_response;
746 let offset = Local::now().offset().fix();
747 let span = state.calendar_week.span;
748 let days = week_days(&events, start, span.days(), offset);
749 let today = Local::now().date_naive();
750 let now = Utc::now();
751 let show_picker = !compact;
752 h_flex()
753 .debug_selector(|| "shell/islands/calendar".into())
754 .flex_1()
755 .w_full()
756 .min_w_0()
757 .h_full()
758 .rounded(px(10.))
759 .bg(theme::surface())
760 .overflow_hidden()
761 .when(show_picker, |row| {
762 row.child(calendar_picker::render(&self.state, cx))
763 })
764 .child(
765 v_flex()
766 .flex_1()
767 .min_w_0()
768 .h_full()
769 .child(self.header(start, span, compact))
770 .children(meeting_proposal_cards(cx))
771 .map(|calendar| {
772 if span == CalendarSpan::Month {
773 calendar.child(month_grid(
774 &self.state,
775 start,
776 &days,
777 &events,
778 today,
779 offset,
780 ))
781 } else {
782 calendar
783 .child(self.day_headers(&days, today))
784 .children(self.all_day_row(&days, &events, send_response))
785 .child(self.grid(&days, &events, today, now, send_response, cx))
786 }
787 }),
788 )
789 }
790}