From 71a7d9029cac50a24355697a7eec0b14a09bfd63 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Thu, 5 Dec 2024 14:06:37 +0300 Subject: [PATCH] generic styling added for the popups Signed-off-by: Uncle Stretch --- config/config.json5 | 2 ++ src/components/wallet/add_account.rs | 9 +++++++ .../wallet/add_address_book_record.rs | 9 +++++++ src/components/wallet/rename_account.rs | 6 +++++ .../wallet/rename_address_book_record.rs | 6 +++++ src/components/wallet/transfer.rs | 5 ++-- src/palette.rs | 26 +++++++++++++++++++ 7 files changed, 60 insertions(+), 3 deletions(-) diff --git a/config/config.json5 b/config/config.json5 index a79952e..1aed01e 100644 --- a/config/config.json5 +++ b/config/config.json5 @@ -27,6 +27,8 @@ "normal_title_style": "blue", "hover_title_style": "", "highlight_style": "yellow bold", + "popup_style": "blue", + "popup_title_style": "blue", } }, "keybindings": { diff --git a/src/components/wallet/add_account.rs b/src/components/wallet/add_account.rs index 948acdc..af607f2 100644 --- a/src/components/wallet/add_account.rs +++ b/src/components/wallet/add_account.rs @@ -87,6 +87,8 @@ impl Component for AddAccount { self.palette.with_normal_style(style.get("normal_style").copied()); self.palette.with_normal_border_style(style.get("normal_border_style").copied()); self.palette.with_normal_title_style(style.get("normal_title_style").copied()); + self.palette.with_popup_style(style.get("popup_style").copied()); + self.palette.with_popup_title_style(style.get("popup_title_style").copied()); } Ok(()) } @@ -108,8 +110,15 @@ impl Component for AddAccount { fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> { if self.is_active { + let size = area.as_size(); + let area = Rect::new(size.width / 2, size.height / 2, 50, 3); + let (border_style, border_type) = self.palette.create_popup_style(); + let input = Paragraph::new(self.name.value()) .block(Block::bordered() + .border_style(border_style) + .border_type(border_type) + .title_style(self.palette.create_popup_title_style()) .title_alignment(Alignment::Right) .title("New wallet name")); let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center); diff --git a/src/components/wallet/add_address_book_record.rs b/src/components/wallet/add_address_book_record.rs index 881b7cf..5a66480 100644 --- a/src/components/wallet/add_address_book_record.rs +++ b/src/components/wallet/add_address_book_record.rs @@ -132,6 +132,8 @@ impl Component for AddAddressBookRecord { self.palette.with_normal_style(style.get("normal_style").copied()); self.palette.with_normal_border_style(style.get("normal_border_style").copied()); self.palette.with_normal_title_style(style.get("normal_title_style").copied()); + self.palette.with_popup_style(style.get("popup_style").copied()); + self.palette.with_popup_title_style(style.get("popup_title_style").copied()); } Ok(()) } @@ -158,14 +160,21 @@ impl Component for AddAddressBookRecord { let size = area.as_size(); let name_area = Rect::new(size.width / 2, size.height / 2, 50, 3); let address_area = Rect::new(size.width / 2, size.height / 2 + 3, 50, 3); + let (border_style, border_type) = self.palette.create_popup_style(); let input_name = Paragraph::new(self.name.value()) .block(Block::bordered() + .border_style(border_style) + .border_type(border_type) + .title_style(self.palette.create_popup_title_style()) .title_alignment(Alignment::Right) .title("New name in Address Book")); let input_address = Paragraph::new(self.address.value()) .block(Block::bordered() + .border_style(border_style) + .border_type(border_type) + .title_style(self.palette.create_popup_title_style()) .title_alignment(Alignment::Right) .title("Address for new name")); diff --git a/src/components/wallet/rename_account.rs b/src/components/wallet/rename_account.rs index c4cfd0c..912c34e 100644 --- a/src/components/wallet/rename_account.rs +++ b/src/components/wallet/rename_account.rs @@ -90,6 +90,8 @@ impl Component for RenameAccount { self.palette.with_normal_style(style.get("normal_style").copied()); self.palette.with_normal_border_style(style.get("normal_border_style").copied()); self.palette.with_normal_title_style(style.get("normal_title_style").copied()); + self.palette.with_popup_style(style.get("popup_style").copied()); + self.palette.with_popup_title_style(style.get("popup_title_style").copied()); } Ok(()) } @@ -119,8 +121,12 @@ impl Component for RenameAccount { fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> { if self.is_active { + let (border_style, border_type) = self.palette.create_popup_style(); let input = Paragraph::new(self.name.value()) .block(Block::bordered() + .border_style(border_style) + .border_type(border_type) + .title_style(self.palette.create_popup_title_style()) .title_alignment(Alignment::Right) .title(format!("New name for '{}'", self.old_name))); let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center); diff --git a/src/components/wallet/rename_address_book_record.rs b/src/components/wallet/rename_address_book_record.rs index db239f8..286deef 100644 --- a/src/components/wallet/rename_address_book_record.rs +++ b/src/components/wallet/rename_address_book_record.rs @@ -91,6 +91,8 @@ impl Component for RenameAddressBookRecord { self.palette.with_normal_style(style.get("normal_style").copied()); self.palette.with_normal_border_style(style.get("normal_border_style").copied()); self.palette.with_normal_title_style(style.get("normal_title_style").copied()); + self.palette.with_popup_style(style.get("popup_style").copied()); + self.palette.with_popup_title_style(style.get("popup_title_style").copied()); } Ok(()) } @@ -120,8 +122,12 @@ impl Component for RenameAddressBookRecord { fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> { if self.is_active { + let (border_style, border_type) = self.palette.create_popup_style(); let input = Paragraph::new(self.name.value()) .block(Block::bordered() + .border_style(border_style) + .border_type(border_type) + .title_style(self.palette.create_popup_title_style()) .title_alignment(Alignment::Right) .title(format!("New name for '{}'", self.old_name))); let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center); diff --git a/src/components/wallet/transfer.rs b/src/components/wallet/transfer.rs index 8629ee6..197c0ba 100644 --- a/src/components/wallet/transfer.rs +++ b/src/components/wallet/transfer.rs @@ -43,11 +43,10 @@ impl Component for Transfer { fn register_config_handler(&mut self, config: Config) -> Result<()> { if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) { self.palette.with_normal_style(style.get("normal_style").copied()); - self.palette.with_hover_style(style.get("hover_style").copied()); self.palette.with_normal_border_style(style.get("normal_border_style").copied()); - self.palette.with_hover_border_style(style.get("hover_border_style").copied()); self.palette.with_normal_title_style(style.get("normal_title_style").copied()); - self.palette.with_hover_title_style(style.get("hover_title_style").copied()); + self.palette.with_popup_style(style.get("popup_style").copied()); + self.palette.with_popup_title_style(style.get("popup_title_style").copied()); } Ok(()) } diff --git a/src/palette.rs b/src/palette.rs index d0ab449..2aab005 100644 --- a/src/palette.rs +++ b/src/palette.rs @@ -15,8 +15,12 @@ pub struct StylePalette { highlight_style: Option