update docs and extract handle_modal

This commit is contained in:
🪞👃🪞 2024-07-13 23:29:51 +03:00
parent 81ea049773
commit f49615d598
9 changed files with 27 additions and 23 deletions

View file

@ -4,13 +4,8 @@ use crate::{core::*, handle, App, AppFocus};
handle!{
App |self, e| {
if let Some(ref mut modal) = self.modal {
if modal.handle(e)? {
if modal.exited() {
self.modal = None;
}
return Ok(true)
};
if handle_modal(self, e)? {
return Ok(true)
}
Ok(if self.entered {
handle_focused(self, e)?
@ -24,6 +19,18 @@ handle!{
}
}
fn handle_modal (state: &mut App, e: &AppEvent) -> Usually<bool> {
if let Some(ref mut modal) = state.modal {
if modal.handle(e)? {
if modal.exited() {
state.modal = None;
}
return Ok(true)
};
}
Ok(false)
}
fn handle_focused (state: &mut App, e: &AppEvent) -> Usually<bool> {
match state.section {
AppFocus::Transport =>