lib: Improve UI around aliases and nids

This commit is contained in:
Erik Kundt
2024-01-09 10:50:58 +01:00
parent 72dbae4cb1
commit 5d559b54f9
3 changed files with 43 additions and 7 deletions
+8 -2
View File
@@ -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(
+22 -4
View File
@@ -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),
+13 -1
View File
@@ -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