Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Implement dynamic context bar height
Erik Kundt committed 2 years ago
commit 109a2408572a614a35988eb019b471520d7398b9
parent 7a53efcc47af7308093ab4b6d73af9d6cd07bb2e
7 files changed +45 -18
modified bin/commands/issue/suite/page.rs
@@ -163,8 +163,14 @@ impl ViewPage<Cid, Message> for ListPage {

    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
+
        let context_h = app
+
            .query(&Cid::List(ListCid::Context), Attribute::Height)
+
            .unwrap_or_default()
+
            .unwrap_or(AttrValue::Size(0))
+
            .unwrap_size();
        let shortcuts_h = 1u16;
-
        let layout = layout::full_page(area, shortcuts_h);
+

+
        let layout = layout::full_page(area, context_h, shortcuts_h);

        app.view(&Cid::List(ListCid::Header), frame, layout.navigation);
        app.view(
modified bin/commands/patch/common/ui.rs
@@ -9,7 +9,7 @@ use radicle_tui as tui;

use tui::context::Context;
use tui::ui::cob::PatchItem;
-
use tui::ui::theme::{Theme, style};
+
use tui::ui::theme::{style, Theme};
use tui::ui::widget::{Widget, WidgetComponent};

use tui::ui::widget::label::{self};
@@ -129,8 +129,7 @@ pub fn browse_context(context: &Context, _theme: &Theme, progress: Progress) ->
    let merged_n = label::default(&format!("{merged}")).style(style::cyan());
    let merged = label::default(" Merged ");

-
    let progress =
-
        label::default(&format!(" {} ", progress.to_string())).style(style::magenta_reversed());
+
    let progress = label::reversable(&progress.to_string()).style(style::magenta_reversed());
    let spacer = label::default("");

    let context_bar = ContextBar::new(
modified bin/commands/patch/list/page.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;

use anyhow::Result;

-
use tuirealm::{Frame, NoUserEvent, State, StateValue, Sub, SubClause};
+
use tuirealm::{AttrValue, Attribute, Frame, NoUserEvent, State, StateValue, Sub, SubClause};

use radicle_tui as tui;

@@ -13,8 +13,8 @@ use tui::ui::widget::Widget;
use tui::ui::{layout, subscription};
use tui::ViewPage;

-
use super::{ui, Application, Cid, ListCid, Message};
use super::super::common;
+
use super::{ui, Application, Cid, ListCid, Message};

///
/// Home
@@ -131,8 +131,14 @@ impl ViewPage<Cid, Message> for ListView {

    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
+
        let context_h = app
+
            .query(&Cid::List(ListCid::Context), Attribute::Height)
+
            .unwrap_or_default()
+
            .unwrap_or(AttrValue::Size(0))
+
            .unwrap_size();
        let shortcuts_h = 1u16;
-
        let layout = layout::default_page(area, shortcuts_h);
+

+
        let layout = layout::default_page(area, context_h, shortcuts_h);

        app.view(
            &Cid::List(self.active_component.clone()),
modified bin/commands/patch/select/page.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;

use anyhow::Result;

-
use tuirealm::{Frame, NoUserEvent, State, StateValue, Sub, SubClause};
+
use tuirealm::{AttrValue, Attribute, Frame, NoUserEvent, State, StateValue, Sub, SubClause};

use radicle_tui as tui;

@@ -130,8 +130,14 @@ impl ViewPage<Cid, Message> for ListView {

    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
+
        let context_h = app
+
            .query(&Cid::List(ListCid::Context), Attribute::Height)
+
            .unwrap_or_default()
+
            .unwrap_or(AttrValue::Size(0))
+
            .unwrap_size();
        let shortcuts_h = 0u16;
-
        let layout = layout::default_page(area, shortcuts_h);
+

+
        let layout = layout::default_page(area, context_h, shortcuts_h);

        app.view(
            &Cid::List(self.active_component.clone()),
modified bin/commands/patch/suite/page.rs
@@ -4,7 +4,7 @@ use anyhow::Result;

use radicle::cob::patch::{Patch, PatchId};

-
use tuirealm::{Frame, NoUserEvent, State, StateValue, Sub, SubClause};
+
use tuirealm::{AttrValue, Attribute, Frame, NoUserEvent, State, StateValue, Sub, SubClause};

use radicle_tui as tui;

@@ -131,8 +131,14 @@ impl ViewPage<Cid, Message> for ListView {

    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
+
        let context_h = app
+
            .query(&Cid::List(ListCid::Context), Attribute::Height)
+
            .unwrap_or_default()
+
            .unwrap_or(AttrValue::Size(0))
+
            .unwrap_size();
        let shortcuts_h = 1u16;
-
        let layout = layout::full_page(area, shortcuts_h);
+

+
        let layout = layout::full_page(area, context_h, shortcuts_h);

        app.view(&Cid::List(ListCid::Header), frame, layout.navigation);
        app.view(
@@ -283,8 +289,14 @@ impl ViewPage<Cid, Message> for PatchView {

    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
+
        let context_h = app
+
            .query(&Cid::List(ListCid::Context), Attribute::Height)
+
            .unwrap_or_default()
+
            .unwrap_or(AttrValue::Size(0))
+
            .unwrap_size();
        let shortcuts_h = 1u16;
-
        let layout = layout::full_page(area, shortcuts_h);
+

+
        let layout = layout::full_page(area, context_h, shortcuts_h);

        app.view(&Cid::Patch(PatchCid::Header), frame, layout.navigation);
        app.view(
modified src/ui/layout.rs
@@ -97,9 +97,8 @@ pub fn app_header(area: Rect, info_w: u16) -> AppHeader {
    }
}

-
pub fn full_page(area: Rect, shortcuts_h: u16) -> FullPage {
+
pub fn full_page(area: Rect, context_h: u16, shortcuts_h: u16) -> FullPage {
    let nav_h = 3u16;
-
    let context_h = 1u16;
    let margin_h = 1u16;
    let component_h = area
        .height
@@ -127,8 +126,7 @@ pub fn full_page(area: Rect, shortcuts_h: u16) -> FullPage {
    }
}

-
pub fn default_page(area: Rect, shortcuts_h: u16) -> DefaultPage {
-
    let context_h = 1u16;
+
pub fn default_page(area: Rect, context_h: u16, shortcuts_h: u16) -> DefaultPage {
    let margin_h = 1u16;
    let component_h = area
        .height
modified src/ui/widget/context.rs
@@ -175,7 +175,7 @@ impl WidgetComponent for ContextBar {
        }

        if display {
-
            let layout = layout::h_stack(
+
            let content_layout = layout::h_stack(
                vec![
                    self.col_0.clone().to_boxed(),
                    self.col_1.clone().to_boxed(),
@@ -192,7 +192,7 @@ impl WidgetComponent for ContextBar {
                area,
            );

-
            for (mut component, area) in layout {
+
            for (mut component, area) in content_layout {
                component.view(frame, area);
            }
        }