refactor: task detail modal into its own component
Move task detail modal logic from App into a dedicated TaskDetailModal component. The modal now manages its own state (open/closed, loading, error states) and handles its own focus and scroll. App delegates modal operations to the component and reacts to its events.
This commit is contained in:
+16
-2
@@ -3,6 +3,20 @@ use crate::{
|
||||
keymap::{Command, CommandDispatcher, FocusTarget},
|
||||
};
|
||||
|
||||
impl App {
|
||||
fn close_task_detail(&mut self, cx: &mut gpui::Context<Self>) {
|
||||
self.task_detail_modal.update(cx, |modal, cx| {
|
||||
modal.close(cx);
|
||||
});
|
||||
}
|
||||
|
||||
fn scroll_task_detail(&self, delta: i32, cx: &mut gpui::Context<Self>) {
|
||||
self.task_detail_modal.update(cx, |modal, cx| {
|
||||
modal.scroll(delta, cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandDispatcher for App {
|
||||
fn dispatch(&mut self, command: Command, cx: &mut gpui::Context<Self>) -> bool {
|
||||
match command {
|
||||
@@ -94,11 +108,11 @@ impl CommandDispatcher for App {
|
||||
true
|
||||
}
|
||||
Command::CloseModal => {
|
||||
self.close_task_detail(None, cx);
|
||||
self.close_task_detail(cx);
|
||||
true
|
||||
}
|
||||
Command::SaveModal => {
|
||||
self.close_task_detail(None, cx);
|
||||
self.close_task_detail(cx);
|
||||
true
|
||||
}
|
||||
Command::ModalScrollUp => {
|
||||
|
||||
Reference in New Issue
Block a user