Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Improve UI around aliases and nids
Erik Kundt committed 2 years ago
commit 5d559b54f92d3f3bf8d6ad8908f5d4e138e58d34
parent 72dbae4cb14d022f97c8cba38294d7048ebeddd9
3 files changed +43 -7
modified bin/commands/issue/suite/ui.rs
@@ -177,10 +177,16 @@ impl IssueHeader {
            tui::ui::label(item.title()).foreground(theme.colors.browser_list_title),
        );

+
        let author = match alias {
+
            Some(_) => tui::ui::label(&cob::format_author(issue.author().id(), &alias, by_you))
+
                .foreground(theme.colors.browser_list_author),
+
            None => tui::ui::label(&cob::format_author(issue.author().id(), &alias, by_you))
+
                .foreground(theme.colors.browser_list_author)
+
                .dim(),
+
        };
        let author = Property::new(
            tui::ui::label("Author").foreground(theme.colors.property_name_fg),
-
            tui::ui::label(&cob::format_author(issue.author().id(), &alias, by_you))
-
                .foreground(theme.colors.browser_list_author),
+
            author,
        );

        let issue_id = Property::new(
modified src/ui/cob.rs
@@ -2,7 +2,7 @@ pub mod format;

use radicle_surf;

-
use tuirealm::props::{Color, Style};
+
use tuirealm::props::{Color, Style, TextModifiers};
use tuirealm::tui::text::{Span, Spans};
use tuirealm::tui::widgets::Cell;

@@ -152,12 +152,18 @@ impl TableItem<8> for PatchItem {
        let title = Cell::from(self.title.clone())
            .style(Style::default().fg(theme.colors.browser_list_title));

+
        let author_style = match &self.author.alias {
+
            Some(_) => Style::default().fg(theme.colors.browser_list_author),
+
            None => Style::default()
+
                .fg(theme.colors.browser_list_author)
+
                .add_modifier(TextModifiers::DIM),
+
        };
        let author = Cell::from(format_author(
            &self.author.did,
            &self.author.alias,
            self.author.is_you,
        ))
-
        .style(Style::default().fg(theme.colors.browser_list_author));
+
        .style(author_style);

        let head = Cell::from(format::oid(self.head))
            .style(Style::default().fg(theme.colors.browser_patch_list_head));
@@ -266,12 +272,18 @@ impl TableItem<7> for IssueItem {
        let title = Cell::from(self.title.clone())
            .style(Style::default().fg(theme.colors.browser_list_title));

+
        let author_style = match &self.author.alias {
+
            Some(_) => Style::default().fg(theme.colors.browser_list_author),
+
            None => Style::default()
+
                .fg(theme.colors.browser_list_author)
+
                .add_modifier(TextModifiers::DIM),
+
        };
        let author = Cell::from(format_author(
            &self.author.did,
            &self.author.alias,
            self.author.is_you,
        ))
-
        .style(Style::default().fg(theme.colors.browser_list_author));
+
        .style(author_style);

        let labels = Cell::from(format_labels(&self.labels))
            .style(Style::default().fg(theme.colors.browser_list_labels));
@@ -294,6 +306,12 @@ impl TableItem<7> for IssueItem {
impl ListItem for IssueItem {
    fn row(&self, theme: &Theme) -> tuirealm::tui::widgets::ListItem {
        let (state, state_color) = format_issue_state(&self.state);
+
        let author_style = match &self.author.alias {
+
            Some(_) => Style::default().fg(theme.colors.browser_list_author),
+
            None => Style::default()
+
                .fg(theme.colors.browser_list_author)
+
                .add_modifier(TextModifiers::DIM),
+
        };
        let lines = vec![
            Spans::from(vec![
                Span::styled(state, Style::default().fg(state_color)),
@@ -306,7 +324,7 @@ impl ListItem for IssueItem {
                Span::raw(String::from("   ")),
                Span::styled(
                    format_author(&self.author.did, &self.author.alias, self.author.is_you),
-
                    Style::default().fg(theme.colors.browser_list_author),
+
                    author_style,
                ),
                Span::styled(
                    format!(" {} ", theme.icons.property_divider),
modified src/ui/widget.rs
@@ -8,7 +8,7 @@ mod utils;
use std::ops::Deref;

use tuirealm::command::{Cmd, CmdResult};
-
use tuirealm::props::{AttrValue, Attribute, Color, Layout, Props};
+
use tuirealm::props::{AttrValue, Attribute, Color, Layout, Props, TextModifiers};
use tuirealm::tui::layout::Rect;
use tuirealm::{Frame, MockComponent, State};

@@ -49,6 +49,18 @@ impl<T: WidgetComponent> Widget<T> {
        self
    }

+
    pub fn dim(mut self) -> Self {
+
        let props = self
+
            .query(Attribute::TextProps)
+
            .unwrap_or(AttrValue::TextModifiers(TextModifiers::empty()));
+

+
        self.attr(
+
            Attribute::TextProps,
+
            AttrValue::TextModifiers(props.unwrap_text_modifiers() | TextModifiers::DIM),
+
        );
+
        self
+
    }
+

    pub fn highlight(mut self, fg: Color) -> Self {
        self.attr(Attribute::HighlightedColor, AttrValue::Color(fg));
        self