fix stash msg popup title/msg

This commit is contained in:
Stephan Dilly 2020-05-22 18:02:25 +02:00
parent 1727b50556
commit 60ba75f1db
4 changed files with 23 additions and 5 deletions

View file

@ -80,7 +80,11 @@ impl CommitComponent {
pub fn new(queue: Queue, theme: &Theme) -> Self {
Self {
queue,
input: TextInputComponent::new(theme),
input: TextInputComponent::new(
theme,
strings::COMMIT_TITLE,
strings::COMMIT_MSG,
),
}
}

View file

@ -96,7 +96,11 @@ impl StashMsgComponent {
Self {
options: StashingOptions::default(),
queue,
input: TextInputComponent::new(theme),
input: TextInputComponent::new(
theme,
strings::STASH_POPUP_TITLE,
strings::STASH_POPUP_MSG,
),
}
}
}

View file

@ -18,6 +18,8 @@ use tui::{
/// primarily a subcomponet for user input of text (used in `CommitComponent`)
pub struct TextInputComponent {
title: String,
default_msg: String,
msg: String,
visible: bool,
theme: Theme,
@ -25,11 +27,17 @@ pub struct TextInputComponent {
impl TextInputComponent {
///
pub fn new(theme: &Theme) -> Self {
pub fn new(
theme: &Theme,
title: &str,
default_msg: &str,
) -> Self {
Self {
msg: String::default(),
visible: false,
theme: *theme,
title: title.to_string(),
default_msg: default_msg.to_string(),
}
}
@ -49,7 +57,7 @@ impl DrawableComponent for TextInputComponent {
if self.visible {
let txt = if self.msg.is_empty() {
[Text::Styled(
Cow::from(strings::COMMIT_MSG),
Cow::from(self.default_msg.as_str()),
self.theme.text(false, false),
)]
} else {
@ -62,7 +70,7 @@ impl DrawableComponent for TextInputComponent {
let area = ui::centered_rect(60, 20, f.size());
f.render_widget(Clear, area);
f.render_widget(
dialog_paragraph(strings::COMMIT_TITLE, txt.iter()),
dialog_paragraph(self.title.as_str(), txt.iter()),
area,
);
}

View file

@ -12,6 +12,8 @@ pub static CMD_SPLITTER: &str = " ";
pub static MSG_TITLE_ERROR: &str = "Error";
pub static COMMIT_TITLE: &str = "Commit";
pub static COMMIT_MSG: &str = "type commit message..";
pub static STASH_POPUP_TITLE: &str = "Stash";
pub static STASH_POPUP_MSG: &str = "type name (optional)";
pub static RESET_TITLE: &str = "Reset";
pub static RESET_MSG: &str = "confirm file reset?";