Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
patch-list: Simplify layout
Erik Kundt committed 2 years ago
commit 52417a2eff126855dc3235312a33cdabcbbda376
parent b98d6731830c15ec1f4329c727f2948084f2ad4d
7 files changed +42 -19
modified bin/commands/issue/suite/page.rs
@@ -163,7 +163,7 @@ impl ViewPage<Cid, Message> for ListPage {
    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
        let shortcuts_h = 1u16;
-
        let layout = layout::default_page(area, shortcuts_h);
+
        let layout = layout::full_page(area, shortcuts_h);

        app.view(&Cid::List(ListCid::Header), frame, layout.navigation);
        app.view(
modified bin/commands/patch.rs
@@ -1,7 +1,7 @@
-
#[path = "patch/suite.rs"]
-
mod suite;
#[path = "patch/list.rs"]
mod list;
+
#[path = "patch/suite.rs"]
+
mod suite;

use std::ffi::OsString;

modified bin/commands/patch/list.rs
@@ -11,17 +11,15 @@ use anyhow::Result;

use radicle::cob::patch::PatchId;

-
use tui::Exit;
use tuirealm::application::PollStrategy;
use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause};

use radicle_tui as tui;

-
use radicle_tui::context::Context;
-
use radicle_tui::ui::subscription;
-
use radicle_tui::ui::theme::{self, Theme};
-
use radicle_tui::PageStack;
-
use radicle_tui::Tui;
+
use tui::context::Context;
+
use tui::ui::subscription;
+
use tui::ui::theme::{self, Theme};
+
use tui::{Exit, PageStack, Tui};

use page::ListView;

modified bin/commands/patch/list/page.rs
@@ -129,10 +129,8 @@ impl ViewPage<Cid, Message> for ListView {

    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
-
        let shortcuts_h = 1u16;
-
        let layout = layout::default_page(area, shortcuts_h);
+
        let layout = layout::default_page(area);

-
        app.view(&Cid::List(ListCid::Header), frame, layout.navigation);
        app.view(
            &Cid::List(self.active_component.clone()),
            frame,
@@ -140,7 +138,6 @@ impl ViewPage<Cid, Message> for ListView {
        );

        app.view(&Cid::List(ListCid::Context), frame, layout.context);
-
        app.view(&Cid::List(ListCid::Shortcuts), frame, layout.shortcuts);
    }

    fn subscribe(&self, app: &mut Application<Cid, Message, NoUserEvent>) -> Result<()> {
modified bin/commands/patch/list/ui.rs
@@ -131,7 +131,7 @@ pub fn browse_context(context: &Context, theme: &Theme, progress: Progress) -> W

    tui::ui::widget::context::bar(
        theme,
-
        "Browse",
+
        "Patches",
        "",
        "",
        &format!("{draft} draft | {open} open | {archived} archived | {merged} merged"),
modified bin/commands/patch/suite/page.rs
@@ -132,7 +132,7 @@ impl ViewPage<Cid, Message> for ListView {
    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
        let shortcuts_h = 1u16;
-
        let layout = layout::default_page(area, shortcuts_h);
+
        let layout = layout::full_page(area, shortcuts_h);

        app.view(&Cid::List(ListCid::Header), frame, layout.navigation);
        app.view(
@@ -284,7 +284,7 @@ impl ViewPage<Cid, Message> for PatchView {
    fn view(&mut self, app: &mut Application<Cid, Message, NoUserEvent>, frame: &mut Frame) {
        let area = frame.size();
        let shortcuts_h = 1u16;
-
        let layout = layout::default_page(area, shortcuts_h);
+
        let layout = layout::full_page(area, shortcuts_h);

        app.view(&Cid::Patch(PatchCid::Header), frame, layout.navigation);
        app.view(
modified src/ui/layout.rs
@@ -8,13 +8,18 @@ pub struct AppHeader {
    pub line: Rect,
}

-
pub struct DefaultPage {
+
pub struct FullPage {
    pub navigation: Rect,
    pub component: Rect,
    pub context: Rect,
    pub shortcuts: Rect,
}

+
pub struct DefaultPage {
+
    pub component: Rect,
+
    pub context: Rect,
+
}
+

pub struct IssuePage {
    pub header: Rect,
    pub left: Rect,
@@ -91,7 +96,7 @@ pub fn app_header(area: Rect, info_w: u16) -> AppHeader {
    }
}

-
pub fn default_page(area: Rect, shortcuts_h: u16) -> DefaultPage {
+
pub fn full_page(area: Rect, shortcuts_h: u16) -> FullPage {
    let nav_h = 3u16;
    let context_h = 1u16;
    let margin_h = 1u16;
@@ -113,7 +118,7 @@ pub fn default_page(area: Rect, shortcuts_h: u16) -> DefaultPage {
        )
        .split(area);

-
    DefaultPage {
+
    FullPage {
        navigation: layout[0],
        component: layout[1],
        context: layout[2],
@@ -121,6 +126,29 @@ pub fn default_page(area: Rect, shortcuts_h: u16) -> DefaultPage {
    }
}

+
pub fn default_page(area: Rect) -> DefaultPage {
+
    let context_h = 1u16;
+
    let margin_h = 1u16;
+
    let component_h = area.height.saturating_sub(context_h);
+

+
    let layout = Layout::default()
+
        .direction(Direction::Vertical)
+
        .horizontal_margin(margin_h)
+
        .constraints(
+
            [
+
                Constraint::Length(component_h),
+
                Constraint::Length(context_h),
+
            ]
+
            .as_ref(),
+
        )
+
        .split(area);
+

+
    DefaultPage {
+
        component: layout[0],
+
        context: layout[1],
+
    }
+
}
+

pub fn headerless_page(area: Rect) -> Vec<Rect> {
    let margin_h = 1u16;
    let content_h = area.height.saturating_sub(margin_h);