move more into sub components

This commit is contained in:
Stephan Dilly 2020-04-02 13:29:25 +02:00
parent 8937f5f437
commit 4bd9826666
2 changed files with 17 additions and 5 deletions

View File

@ -172,10 +172,6 @@ impl App {
DiffTarget::WorkingDir => Focus::WorkDir,
})
}
//TODO: move down
keys::OPEN_COMMIT if !self.index.is_empty() => {
self.commit.show();
}
_ => (),
};
}
@ -187,6 +183,7 @@ impl App {
self.git_diff.refresh();
self.git_status.fetch(current_tick());
self.commit.set_stage_empty(self.index.is_empty());
}
///

View File

@ -1,5 +1,5 @@
use super::{CommandInfo, Component, DrawableComponent, EventUpdate};
use crate::{strings, ui};
use crate::{keys, strings, ui};
use asyncgit::{sync, CWD};
use crossterm::event::{Event, KeyCode};
use std::borrow::Cow;
@ -16,6 +16,7 @@ pub struct CommitComponent {
msg: String,
// focused: bool,
visible: bool,
stage_empty: bool,
}
impl DrawableComponent for CommitComponent {
@ -83,6 +84,15 @@ impl Component for CommitComponent {
_ => EventUpdate::None,
});
}
} else {
if let Event::Key(e) = ev {
if let keys::OPEN_COMMIT = e {
if !self.stage_empty {
self.show();
return Some(EventUpdate::Changes);
}
}
}
}
None
}
@ -111,4 +121,9 @@ impl CommitComponent {
fn can_commit(&self) -> bool {
!self.msg.is_empty()
}
///
pub fn set_stage_empty(&mut self, empty: bool) {
self.stage_empty = empty;
}
}