mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-10-30 16:30:56 +08:00
patch-list: Simplify layout
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<()> {
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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(
|
||||
|
||||
+31
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user