mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-29 06:20:28 +08:00
refactor: Simplify library ui and widget modules
This commit is contained in:
+4
-9
@@ -2,8 +2,9 @@ pub mod format;
|
||||
|
||||
use radicle_surf;
|
||||
|
||||
// use cli::terminal::format;
|
||||
// use radicle_cli as cli;
|
||||
use tuirealm::props::{Color, Style};
|
||||
use tuirealm::tui::text::{Span, Spans};
|
||||
use tuirealm::tui::widgets::Cell;
|
||||
|
||||
use radicle::prelude::Did;
|
||||
use radicle::storage::git::Repository;
|
||||
@@ -14,14 +15,8 @@ use radicle::cob::issue::{Issue, IssueId, State as IssueState};
|
||||
use radicle::cob::patch::{Patch, PatchId, State as PatchState};
|
||||
use radicle::cob::{Label, Timestamp};
|
||||
|
||||
use tuirealm::props::{Color, Style};
|
||||
use tuirealm::tui::text::{Span, Spans};
|
||||
use tuirealm::tui::widgets::Cell;
|
||||
|
||||
use crate::ui::theme::Theme;
|
||||
use crate::ui::widget::common::list::TableItem;
|
||||
|
||||
use super::widget::common::list::ListItem;
|
||||
use crate::ui::widget::list::{ListItem, TableItem};
|
||||
|
||||
/// An author item that can be used in tables, list or trees.
|
||||
///
|
||||
|
||||
+5
-1
@@ -1,4 +1,8 @@
|
||||
pub mod common;
|
||||
pub mod container;
|
||||
pub mod context;
|
||||
pub mod form;
|
||||
pub mod label;
|
||||
pub mod list;
|
||||
mod utils;
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
@@ -218,19 +218,19 @@ pub fn bar(
|
||||
label_3: &str,
|
||||
label_4: &str,
|
||||
) -> Widget<ContextBar> {
|
||||
let context = super::label(&format!(" {label_0} "))
|
||||
let context = crate::ui::label(&format!(" {label_0} "))
|
||||
.foreground(theme.colors.context_bg)
|
||||
.background(theme.colors.context_badge_bg);
|
||||
let id = super::label(&format!(" {label_1} "))
|
||||
let id = crate::ui::label(&format!(" {label_1} "))
|
||||
.foreground(theme.colors.context_color_fg)
|
||||
.background(theme.colors.context_bg);
|
||||
let title = super::label(&format!(" {label_2} "))
|
||||
let title = crate::ui::label(&format!(" {label_2} "))
|
||||
.foreground(theme.colors.default_fg)
|
||||
.background(theme.colors.context_bg);
|
||||
let author = super::label(&format!(" {label_3} "))
|
||||
let author = crate::ui::label(&format!(" {label_3} "))
|
||||
.foreground(theme.colors.context_light)
|
||||
.background(theme.colors.context_bg);
|
||||
let comments = super::label(&format!(" {label_4} "))
|
||||
let comments = crate::ui::label(&format!(" {label_4} "))
|
||||
.foreground(theme.colors.context_light)
|
||||
.background(theme.colors.context_bg);
|
||||
|
||||
@@ -25,11 +25,11 @@ impl TextField {
|
||||
.single_line(true)
|
||||
.cursor_line_style(Style::reset())
|
||||
.style(Style::default().fg(theme.colors.default_fg));
|
||||
let container = super::container(&theme, Box::new(input));
|
||||
let container = crate::ui::container(&theme, Box::new(input));
|
||||
|
||||
Self {
|
||||
input: container,
|
||||
placeholder: super::label(title).foreground(theme.colors.input_placeholder_fg),
|
||||
placeholder: crate::ui::label(title).foreground(theme.colors.input_placeholder_fg),
|
||||
show_placeholder: true,
|
||||
}
|
||||
}
|
||||
@@ -99,11 +99,11 @@ impl TextArea {
|
||||
.single_line(false)
|
||||
.cursor_line_style(Style::reset())
|
||||
.style(Style::default().fg(theme.colors.default_fg));
|
||||
let container = super::container(&theme, Box::new(input));
|
||||
let container = crate::ui::container(&theme, Box::new(input));
|
||||
|
||||
Self {
|
||||
input: container,
|
||||
placeholder: super::label(title).foreground(theme.colors.input_placeholder_fg),
|
||||
placeholder: crate::ui::label(title).foreground(theme.colors.input_placeholder_fg),
|
||||
show_placeholder: true,
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use crate::ui::widget::{utils, Widget, WidgetComponent};
|
||||
|
||||
use super::container::Header;
|
||||
use super::label::Label;
|
||||
use super::*;
|
||||
|
||||
/// A generic item that can be displayed in a table with [`const W: usize`] columns.
|
||||
pub trait TableItem<const W: usize> {
|
||||
@@ -48,7 +47,7 @@ pub struct Property {
|
||||
|
||||
impl Property {
|
||||
pub fn new(name: Widget<Label>, value: Widget<Label>) -> Self {
|
||||
let divider = label("");
|
||||
let divider = crate::ui::label("");
|
||||
Self {
|
||||
name,
|
||||
divider,
|
||||
@@ -1,6 +1,6 @@
|
||||
use tuirealm::tui::layout::{Constraint, Rect};
|
||||
|
||||
use super::common::list::ColumnWidth;
|
||||
use super::list::ColumnWidth;
|
||||
|
||||
/// Calculates `Constraint::Percentage` for each fixed column width in `widths`,
|
||||
/// taking into account the available width in `area` and the column spacing given by `spacing`.
|
||||
|
||||
Reference in New Issue
Block a user