From f8a448f5e9dea65fe5b693e84db6ad909356d704 Mon Sep 17 00:00:00 2001 From: veeso Date: Sat, 3 Apr 2021 17:27:43 +0200 Subject: [PATCH] Use default color if Text span part is Reset --- src/ui/activities/auth_activity/view.rs | 4 ++-- src/ui/layout/components/text.rs | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ui/activities/auth_activity/view.rs b/src/ui/activities/auth_activity/view.rs index 0f04862..18a7065 100644 --- a/src/ui/activities/auth_activity/view.rs +++ b/src/ui/activities/auth_activity/view.rs @@ -61,7 +61,6 @@ impl AuthActivity { super::COMPONENT_TEXT_FOOTER, Box::new(Text::new( PropsBuilder::default() - .with_foreground(Color::White) .with_texts(TextParts::new( None, Some(vec![ @@ -158,7 +157,8 @@ impl AuthActivity { super::COMPONENT_TEXT_NEW_VERSION, Box::new(Text::new( PropsBuilder::default() - .with_texts(TextParts::new(None, Some(vec![TextSpanBuilder::new(format!("TermSCP {} is now available! Download it from ", version).as_str()).with_foreground(Color::Yellow).bold().build()]))) + .with_foreground(Color::Yellow) + .with_texts(TextParts::new(None, Some(vec![TextSpan::from(format!("TermSCP {} is now available! Download it from ", version))]))) .build() )) ); diff --git a/src/ui/layout/components/text.rs b/src/ui/layout/components/text.rs index 653f042..d2c1286 100644 --- a/src/ui/layout/components/text.rs +++ b/src/ui/layout/components/text.rs @@ -30,7 +30,7 @@ use super::{Canvas, Component, InputEvent, Msg, Payload, Props, PropsBuilder}; // ext use tui::{ layout::Rect, - style::Style, + style::{Color, Style}, text::{Span, Spans, Text as TuiText}, widgets::Paragraph, }; @@ -64,12 +64,21 @@ impl Component for Text { Some(rows) => rows .iter() .map(|x| { + // Keep line color, or use default + let fg: Color = match x.fg { + Color::Reset => self.props.foreground, + _ => x.fg, + }; + let bg: Color = match x.bg { + Color::Reset => self.props.background, + _ => x.bg, + }; Span::styled( x.content.clone(), Style::default() .add_modifier(x.get_modifiers()) - .fg(x.fg) - .bg(x.bg), + .fg(fg) + .bg(bg), ) }) .collect(),