generic styling added for the popups
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
79abbd566d
commit
71a7d9029c
@ -27,6 +27,8 @@
|
|||||||
"normal_title_style": "blue",
|
"normal_title_style": "blue",
|
||||||
"hover_title_style": "",
|
"hover_title_style": "",
|
||||||
"highlight_style": "yellow bold",
|
"highlight_style": "yellow bold",
|
||||||
|
"popup_style": "blue",
|
||||||
|
"popup_title_style": "blue",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"keybindings": {
|
"keybindings": {
|
||||||
|
@ -87,6 +87,8 @@ impl Component for AddAccount {
|
|||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
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_border_style(style.get("normal_border_style").copied());
|
||||||
self.palette.with_normal_title_style(style.get("normal_title_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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -108,8 +110,15 @@ impl Component for AddAccount {
|
|||||||
|
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||||
if self.is_active {
|
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())
|
let input = Paragraph::new(self.name.value())
|
||||||
.block(Block::bordered()
|
.block(Block::bordered()
|
||||||
|
.border_style(border_style)
|
||||||
|
.border_type(border_type)
|
||||||
|
.title_style(self.palette.create_popup_title_style())
|
||||||
.title_alignment(Alignment::Right)
|
.title_alignment(Alignment::Right)
|
||||||
.title("New wallet name"));
|
.title("New wallet name"));
|
||||||
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
||||||
|
@ -132,6 +132,8 @@ impl Component for AddAddressBookRecord {
|
|||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
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_border_style(style.get("normal_border_style").copied());
|
||||||
self.palette.with_normal_title_style(style.get("normal_title_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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -158,14 +160,21 @@ impl Component for AddAddressBookRecord {
|
|||||||
let size = area.as_size();
|
let size = area.as_size();
|
||||||
let name_area = Rect::new(size.width / 2, size.height / 2, 50, 3);
|
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 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())
|
let input_name = Paragraph::new(self.name.value())
|
||||||
.block(Block::bordered()
|
.block(Block::bordered()
|
||||||
|
.border_style(border_style)
|
||||||
|
.border_type(border_type)
|
||||||
|
.title_style(self.palette.create_popup_title_style())
|
||||||
.title_alignment(Alignment::Right)
|
.title_alignment(Alignment::Right)
|
||||||
.title("New name in Address Book"));
|
.title("New name in Address Book"));
|
||||||
|
|
||||||
let input_address = Paragraph::new(self.address.value())
|
let input_address = Paragraph::new(self.address.value())
|
||||||
.block(Block::bordered()
|
.block(Block::bordered()
|
||||||
|
.border_style(border_style)
|
||||||
|
.border_type(border_type)
|
||||||
|
.title_style(self.palette.create_popup_title_style())
|
||||||
.title_alignment(Alignment::Right)
|
.title_alignment(Alignment::Right)
|
||||||
.title("Address for new name"));
|
.title("Address for new name"));
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ impl Component for RenameAccount {
|
|||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
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_border_style(style.get("normal_border_style").copied());
|
||||||
self.palette.with_normal_title_style(style.get("normal_title_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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -119,8 +121,12 @@ impl Component for RenameAccount {
|
|||||||
|
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||||
if self.is_active {
|
if self.is_active {
|
||||||
|
let (border_style, border_type) = self.palette.create_popup_style();
|
||||||
let input = Paragraph::new(self.name.value())
|
let input = Paragraph::new(self.name.value())
|
||||||
.block(Block::bordered()
|
.block(Block::bordered()
|
||||||
|
.border_style(border_style)
|
||||||
|
.border_type(border_type)
|
||||||
|
.title_style(self.palette.create_popup_title_style())
|
||||||
.title_alignment(Alignment::Right)
|
.title_alignment(Alignment::Right)
|
||||||
.title(format!("New name for '{}'", self.old_name)));
|
.title(format!("New name for '{}'", self.old_name)));
|
||||||
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
||||||
|
@ -91,6 +91,8 @@ impl Component for RenameAddressBookRecord {
|
|||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
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_border_style(style.get("normal_border_style").copied());
|
||||||
self.palette.with_normal_title_style(style.get("normal_title_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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -120,8 +122,12 @@ impl Component for RenameAddressBookRecord {
|
|||||||
|
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||||
if self.is_active {
|
if self.is_active {
|
||||||
|
let (border_style, border_type) = self.palette.create_popup_style();
|
||||||
let input = Paragraph::new(self.name.value())
|
let input = Paragraph::new(self.name.value())
|
||||||
.block(Block::bordered()
|
.block(Block::bordered()
|
||||||
|
.border_style(border_style)
|
||||||
|
.border_type(border_type)
|
||||||
|
.title_style(self.palette.create_popup_title_style())
|
||||||
.title_alignment(Alignment::Right)
|
.title_alignment(Alignment::Right)
|
||||||
.title(format!("New name for '{}'", self.old_name)));
|
.title(format!("New name for '{}'", self.old_name)));
|
||||||
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
let v = Layout::vertical([Constraint::Max(3)]).flex(Flex::Center);
|
||||||
|
@ -43,11 +43,10 @@ impl Component for Transfer {
|
|||||||
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
||||||
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
if let Some(style) = config.styles.get(&crate::app::Mode::Wallet) {
|
||||||
self.palette.with_normal_style(style.get("normal_style").copied());
|
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_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_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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,12 @@ pub struct StylePalette {
|
|||||||
highlight_style: Option<Style>,
|
highlight_style: Option<Style>,
|
||||||
scrollbar_style: Option<Style>,
|
scrollbar_style: Option<Style>,
|
||||||
|
|
||||||
|
popup_style: Option<Style>,
|
||||||
|
popup_title_style: Option<Style>,
|
||||||
|
|
||||||
normal_border_type: BorderType,
|
normal_border_type: BorderType,
|
||||||
hover_border_type: BorderType,
|
hover_border_type: BorderType,
|
||||||
|
popup_border_type: BorderType,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for StylePalette {
|
impl Default for StylePalette {
|
||||||
@ -36,9 +40,12 @@ impl StylePalette {
|
|||||||
hover_title_style: None,
|
hover_title_style: None,
|
||||||
highlight_style: None,
|
highlight_style: None,
|
||||||
scrollbar_style: None,
|
scrollbar_style: None,
|
||||||
|
popup_style: None,
|
||||||
|
popup_title_style: None,
|
||||||
|
|
||||||
normal_border_type: BorderType::Plain,
|
normal_border_type: BorderType::Plain,
|
||||||
hover_border_type: BorderType::Double,
|
hover_border_type: BorderType::Double,
|
||||||
|
popup_border_type: BorderType::Thick,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +81,14 @@ impl StylePalette {
|
|||||||
self.scrollbar_style = scrollbar_style;
|
self.scrollbar_style = scrollbar_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_popup_style(&mut self, popup_style: Option<Style>) {
|
||||||
|
self.popup_style = popup_style;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_popup_title_style(&mut self, popup_title_style: Option<Style>) {
|
||||||
|
self.popup_title_style = popup_title_style;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_scrollbar_style(&mut self) -> Style {
|
pub fn create_scrollbar_style(&mut self) -> Style {
|
||||||
self.scrollbar_style.unwrap_or_default()
|
self.scrollbar_style.unwrap_or_default()
|
||||||
}
|
}
|
||||||
@ -111,4 +126,15 @@ impl StylePalette {
|
|||||||
self.hover_title_style.unwrap_or_default()
|
self.hover_title_style.unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_popup_style(&self) -> (Color, BorderType) {
|
||||||
|
(
|
||||||
|
self.popup_style.map(|style| style.fg).flatten().unwrap_or_default(),
|
||||||
|
self.popup_border_type,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create_popup_title_style(&self) -> Style {
|
||||||
|
self.popup_title_style.unwrap_or_default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user