gpui2: Notifications
This commit is contained in:
parent
700168467e
commit
039c933d8e
11 changed files with 190 additions and 111 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
AnyView, AnyWindowHandle, AppCell, AppContext, BackgroundExecutor, Context, FocusableView,
|
||||
ForegroundExecutor, Manager, Model, ModelContext, Render, Result, Task, View, ViewContext,
|
||||
VisualContext, WindowContext, WindowHandle,
|
||||
AnyView, AnyWindowHandle, AppCell, AppContext, BackgroundExecutor, Context, DismissEvent,
|
||||
FocusableView, ForegroundExecutor, Model, ModelContext, Render, Result, Task, View,
|
||||
ViewContext, VisualContext, WindowContext, WindowHandle,
|
||||
};
|
||||
use anyhow::{anyhow, Context as _};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
|
@ -326,7 +326,7 @@ impl VisualContext for AsyncWindowContext {
|
|||
V: crate::ManagedView,
|
||||
{
|
||||
self.window.update(self, |_, cx| {
|
||||
view.update(cx, |_, cx| cx.emit(Manager::Dismiss))
|
||||
view.update(cx, |_, cx| cx.emit(DismissEvent::Dismiss))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ impl<'a> VisualContext for VisualTestContext<'a> {
|
|||
{
|
||||
self.window
|
||||
.update(self.cx, |_, cx| {
|
||||
view.update(cx, |_, cx| cx.emit(crate::Manager::Dismiss))
|
||||
view.update(cx, |_, cx| cx.emit(crate::DismissEvent::Dismiss))
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
@ -193,11 +193,11 @@ pub trait FocusableView: 'static + Render {
|
|||
|
||||
/// ManagedView is a view (like a Modal, Popover, Menu, etc.)
|
||||
/// where the lifecycle of the view is handled by another view.
|
||||
pub trait ManagedView: FocusableView + EventEmitter<Manager> {}
|
||||
pub trait ManagedView: FocusableView + EventEmitter<DismissEvent> {}
|
||||
|
||||
impl<M: FocusableView + EventEmitter<Manager>> ManagedView for M {}
|
||||
impl<M: FocusableView + EventEmitter<DismissEvent>> ManagedView for M {}
|
||||
|
||||
pub enum Manager {
|
||||
pub enum DismissEvent {
|
||||
Dismiss,
|
||||
}
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ impl VisualContext for WindowContext<'_> {
|
|||
where
|
||||
V: ManagedView,
|
||||
{
|
||||
self.update_view(view, |_, cx| cx.emit(Manager::Dismiss))
|
||||
self.update_view(view, |_, cx| cx.emit(DismissEvent::Dismiss))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2349,7 +2349,7 @@ impl<'a, V: 'static> ViewContext<'a, V> {
|
|||
where
|
||||
V: ManagedView,
|
||||
{
|
||||
self.defer(|_, cx| cx.emit(Manager::Dismiss))
|
||||
self.defer(|_, cx| cx.emit(DismissEvent::Dismiss))
|
||||
}
|
||||
|
||||
pub fn listener<E>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue