Add StatusToast & the ToastLayer (#26232)
https://github.com/user-attachments/assets/b16e32e6-46c6-41dc-ab68-1824d288c8c2 This PR adds the first part of our planned extended notification system: StatusToasts. It also makes various updates to ComponentPreview and adds a `Styled` extension in `ui::style::animation` to make it easier to animate styled elements. _**Note**: We will be very, very selective with what elements are allowed to be animated in Zed. Assume PRs adding animation to elements will all need to be manually signed off on by a designer._ ## Status Toast  These are designed to be used for notifying about things that don't require an action to be taken or don't need to be triaged. They are designed to be ignorable, and dismiss themselves automatically after a set time. They can optionally include a single action. Example: When the user enables Vim Mode, that action might let them undo enabling it.  Status Toasts should _not_ be used when an action is required, or for any binary choice. If the user must provide some input, this isn't the right component! ### Out of scope - Toasts should fade over a short time (like AnimationDuration::Fast or Instant) when dismissed - We should visually show when the toast will dismiss. We'll need to pipe the `duration_remaining` from the toast layer -> ActiveToast to do this. - Dismiss any active toast if another notification kind is created, like a Notification or Alert. Release Notes: - N/A --------- Co-authored-by: Cole Miller <m@cole-miller.net>
This commit is contained in:
parent
b8a8b9c699
commit
7e964290bf
24 changed files with 1308 additions and 75 deletions
|
@ -10,9 +10,12 @@ pub mod shared_screen;
|
|||
mod status_bar;
|
||||
pub mod tasks;
|
||||
mod theme_preview;
|
||||
mod toast_layer;
|
||||
mod toolbar;
|
||||
mod workspace_settings;
|
||||
|
||||
pub use toast_layer::{ToastLayer, ToastView};
|
||||
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use call::{call_settings::CallSettings, ActiveCall};
|
||||
use client::{
|
||||
|
@ -816,6 +819,7 @@ pub struct Workspace {
|
|||
last_active_view_id: Option<proto::ViewId>,
|
||||
status_bar: Entity<StatusBar>,
|
||||
modal_layer: Entity<ModalLayer>,
|
||||
toast_layer: Entity<ToastLayer>,
|
||||
titlebar_item: Option<AnyView>,
|
||||
notifications: Notifications,
|
||||
project: Entity<Project>,
|
||||
|
@ -1032,6 +1036,7 @@ impl Workspace {
|
|||
});
|
||||
|
||||
let modal_layer = cx.new(|_| ModalLayer::new());
|
||||
let toast_layer = cx.new(|_| ToastLayer::new());
|
||||
|
||||
let session_id = app_state.session.read(cx).id().to_owned();
|
||||
|
||||
|
@ -1112,6 +1117,7 @@ impl Workspace {
|
|||
last_active_view_id: None,
|
||||
status_bar,
|
||||
modal_layer,
|
||||
toast_layer,
|
||||
titlebar_item: None,
|
||||
notifications: Default::default(),
|
||||
left_dock,
|
||||
|
@ -4971,6 +4977,17 @@ impl Workspace {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn toggle_status_toast<V: ToastView>(
|
||||
&mut self,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
entity: Entity<V>,
|
||||
) {
|
||||
self.toast_layer.update(cx, |toast_layer, cx| {
|
||||
toast_layer.toggle_toast(window, cx, entity)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn toggle_centered_layout(
|
||||
&mut self,
|
||||
_: &ToggleCenteredLayout,
|
||||
|
@ -5485,7 +5502,8 @@ impl Render for Workspace {
|
|||
.children(self.render_notifications(window, cx)),
|
||||
)
|
||||
.child(self.status_bar.clone())
|
||||
.child(self.modal_layer.clone()),
|
||||
.child(self.modal_layer.clone())
|
||||
.child(self.toast_layer.clone()),
|
||||
),
|
||||
window,
|
||||
cx,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue