MOAR CODE

This commit is contained in:
Conrad Irwin 2023-11-07 13:42:33 -07:00
parent 3a85beeaa5
commit 5751303ea4
2 changed files with 105 additions and 66 deletions

View file

@ -33,7 +33,7 @@ impl ModalRegistry {
pub fn register_modal<A: 'static, V, B>(&mut self, action: A, build_view: B)
where
V: Render,
B: Fn(&Workspace, &mut ViewContext<Workspace>) -> View<V> + 'static,
B: Fn(&Workspace, &mut ViewContext<Workspace>) -> Option<View<V>> + 'static,
{
let build_view = Arc::new(build_view);
@ -47,12 +47,14 @@ impl ModalRegistry {
event: &A,
phase: DispatchPhase,
cx: &mut ViewContext<Workspace>| {
dbg!("GOT HERE");
if phase == DispatchPhase::Capture {
return;
}
let new_modal = (build_view)(workspace, cx);
let Some(new_modal) = (build_view)(workspace, cx) else {
return;
};
workspace.modal_layer.update(cx, |modal_layer, _| {
modal_layer.open_modal = Some(new_modal.into());
});