tui: Add app header to issue page
This commit is contained in:
parent
21950e1cae
commit
2d84791402
|
|
@ -38,6 +38,7 @@ pub enum PatchCid {
|
|||
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
|
||||
pub enum IssueCid {
|
||||
Header,
|
||||
List,
|
||||
Details,
|
||||
Shortcuts,
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ impl ViewPage for IssuePage {
|
|||
theme: &Theme,
|
||||
) -> Result<()> {
|
||||
let (id, issue) = &self.issue;
|
||||
let header = widget::common::app_header(context, theme, None).to_boxed();
|
||||
let list = widget::issue::list(context, theme, (*id, issue.clone())).to_boxed();
|
||||
let details = widget::issue::details(context, theme, (*id, issue.clone())).to_boxed();
|
||||
let shortcuts = widget::common::shortcuts(
|
||||
|
|
@ -180,6 +181,7 @@ impl ViewPage for IssuePage {
|
|||
)
|
||||
.to_boxed();
|
||||
|
||||
app.remount(Cid::Issue(IssueCid::Header), header, vec![])?;
|
||||
app.remount(Cid::Issue(IssueCid::List), list, vec![])?;
|
||||
app.remount(Cid::Issue(IssueCid::Details), details, vec![])?;
|
||||
app.remount(Cid::Issue(IssueCid::Shortcuts), shortcuts, vec![])?;
|
||||
|
|
@ -190,6 +192,7 @@ impl ViewPage for IssuePage {
|
|||
}
|
||||
|
||||
fn unmount(&self, app: &mut Application<Cid, Message, NoUserEvent>) -> Result<()> {
|
||||
app.umount(&Cid::Issue(IssueCid::Header))?;
|
||||
app.umount(&Cid::Issue(IssueCid::List))?;
|
||||
app.umount(&Cid::Issue(IssueCid::Details))?;
|
||||
app.umount(&Cid::Issue(IssueCid::Shortcuts))?;
|
||||
|
|
@ -220,7 +223,8 @@ impl ViewPage for IssuePage {
|
|||
let shortcuts_h = 1u16;
|
||||
let layout = layout::issue_preview(area, shortcuts_h);
|
||||
|
||||
app.view(&Cid::Issue(IssueCid::List), frame, layout.left);
|
||||
app.view(&Cid::Issue(IssueCid::Header), frame, layout.header);
|
||||
app.view(&Cid::Issue(IssueCid::List), frame, layout.list);
|
||||
app.view(&Cid::Issue(IssueCid::Details), frame, layout.details);
|
||||
app.view(&Cid::Issue(IssueCid::Shortcuts), frame, layout.shortcuts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,20 @@ use tuirealm::props::{AttrValue, Attribute};
|
|||
use tuirealm::tui::layout::{Constraint, Direction, Layout, Rect};
|
||||
use tuirealm::MockComponent;
|
||||
|
||||
pub struct IssuePreview {
|
||||
pub left: Rect,
|
||||
pub details: Rect,
|
||||
pub discussion: Rect,
|
||||
pub shortcuts: Rect,
|
||||
}
|
||||
|
||||
pub struct AppHeader {
|
||||
pub nav: Rect,
|
||||
pub info: Rect,
|
||||
pub line: Rect,
|
||||
}
|
||||
|
||||
pub struct IssuePreview {
|
||||
pub header: Rect,
|
||||
pub list: Rect,
|
||||
pub details: Rect,
|
||||
pub discussion: Rect,
|
||||
pub shortcuts: Rect,
|
||||
}
|
||||
|
||||
pub fn v_stack(
|
||||
widgets: Vec<Box<dyn MockComponent>>,
|
||||
area: Rect,
|
||||
|
|
@ -170,13 +171,18 @@ pub fn centered_label(label_w: u16, area: Rect) -> Rect {
|
|||
}
|
||||
|
||||
pub fn issue_preview(area: Rect, shortcuts_h: u16) -> IssuePreview {
|
||||
let content_h = area.height.saturating_sub(shortcuts_h);
|
||||
let header_h = 3u16;
|
||||
let content_h = area
|
||||
.height
|
||||
.saturating_sub(header_h)
|
||||
.saturating_sub(shortcuts_h);
|
||||
|
||||
let root = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.horizontal_margin(1)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Length(header_h),
|
||||
Constraint::Length(content_h),
|
||||
Constraint::Length(shortcuts_h),
|
||||
]
|
||||
|
|
@ -187,7 +193,7 @@ pub fn issue_preview(area: Rect, shortcuts_h: u16) -> IssuePreview {
|
|||
let split = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
|
||||
.split(root[0]);
|
||||
.split(root[1]);
|
||||
|
||||
let right = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
|
|
@ -195,9 +201,10 @@ pub fn issue_preview(area: Rect, shortcuts_h: u16) -> IssuePreview {
|
|||
.split(split[1]);
|
||||
|
||||
IssuePreview {
|
||||
left: split[0],
|
||||
header: root[0],
|
||||
list: split[0],
|
||||
details: right[0],
|
||||
discussion: right[1],
|
||||
shortcuts: root[1],
|
||||
shortcuts: root[2],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue