Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Switch context bar on new issue form
Erik Kundt committed 2 years ago
commit 81966a4aca55a23ec7e272a44a7250e77e82e6a2
parent 12ee3fb8b1cedcb178f6ffa28b33a7e3ba943001
4 files changed +31 -1
modified src/app/page.rs
@@ -376,6 +376,10 @@ impl IssuePage {
                let context = widget::issue::description_context(context, theme, progress);
                Some(context)
            }
+
            IssueCid::Form => {
+
                let context = widget::issue::form_context(context, theme, Progress::None);
+
                Some(context)
+
            }
            _ => None,
        };

@@ -511,6 +515,7 @@ impl ViewPage for IssuePage {
                    Sub::new(subscription::global_clause(), SubClause::Always),
                )?;

+
                self.activate(app, IssueCid::List)?;
                self.update_shortcuts(app, IssueCid::List)?;
            }
            _ => {}
modified src/ui/theme.rs
@@ -34,6 +34,7 @@ pub struct Colors {
    pub context_light: Color,
    pub context_dark: Color,
    pub context_badge_bg: Color,
+
    pub context_badge_edit_bg: Color,
    pub context_color_fg: Color,
    pub container_border_fg: Color,
    pub container_border_focus_fg: Color,
@@ -105,6 +106,7 @@ pub fn default_dark() -> Theme {
            context_light: Color::Gray,
            context_dark: COLOR_DEFAULT_DARK,
            context_badge_bg: Color::Magenta,
+
            context_badge_edit_bg: Color::Red,
            context_color_fg: Color::Cyan,
            container_border_fg: COLOR_DEFAULT_DARKEST,
            container_border_focus_fg: COLOR_DEFAULT_DARK,
modified src/ui/widget/common/context.rs
@@ -128,10 +128,14 @@ pub struct ContextBar {
    label_2: Widget<Label>,
    label_3: Widget<Label>,
    label_4: Widget<Label>,
+
    theme: Theme,
}

impl ContextBar {
+
    pub const PROP_EDIT_MODE: &str = "edit-mode";
+

    pub fn new(
+
        theme: Theme,
        label_0: Widget<Label>,
        label_1: Widget<Label>,
        label_2: Widget<Label>,
@@ -139,6 +143,7 @@ impl ContextBar {
        label_4: Widget<Label>,
    ) -> Self {
        Self {
+
            theme,
            label_0,
            label_1,
            label_2,
@@ -153,12 +158,25 @@ impl WidgetComponent for ContextBar {
        let display = properties
            .get_or(Attribute::Display, AttrValue::Flag(true))
            .unwrap_flag();
+
        let edit_mode = properties
+
            .get_or(
+
                Attribute::Custom(Self::PROP_EDIT_MODE),
+
                AttrValue::Flag(false),
+
            )
+
            .unwrap_flag();

        let label_0_w = self.label_0.query(Attribute::Width).unwrap().unwrap_size();
        let label_1_w = self.label_1.query(Attribute::Width).unwrap().unwrap_size();
        let label_2_w = self.label_2.query(Attribute::Width).unwrap().unwrap_size();
        let label_4_w = self.label_4.query(Attribute::Width).unwrap().unwrap_size();

+
        if edit_mode {
+
            self.label_0.attr(
+
                Attribute::Background,
+
                AttrValue::Color(self.theme.colors.context_badge_edit_bg),
+
            )
+
        }
+

        if display {
            let layout = layout::h_stack(
                vec![
@@ -216,7 +234,7 @@ pub fn bar(
        .foreground(theme.colors.context_light)
        .background(theme.colors.context_bg);

-
    let context_bar = ContextBar::new(context, id, author, title, comments);
+
    let context_bar = ContextBar::new(theme.clone(), context, id, author, title, comments);

    Widget::new(context_bar).height(1)
}
modified src/ui/widget/issue.rs
@@ -403,3 +403,8 @@ pub fn description_context(
) -> Widget<ContextBar> {
    common::context::bar(theme, "Show", "", "", "", &progress.to_string())
}
+

+
pub fn form_context(_context: &Context, theme: &Theme, progress: Progress) -> Widget<ContextBar> {
+
    common::context::bar(theme, "Edit", "", "", "", &progress.to_string())
+
        .custom(ContextBar::PROP_EDIT_MODE, AttrValue::Flag(true))
+
}