generated from GarandPLG/rust-flake-template
Extract default view keybindings and widget
Move generic view rendering and keybinding logic into a new default module and replace inline implementations with calls to the new helpers.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
use crate::app::{App, widgets::KeybindingsWidget};
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::{Alignment, Constraint, Layout, Rect},
|
||||
style::Stylize,
|
||||
widgets::{Block, Borders, Paragraph, Widget},
|
||||
};
|
||||
|
||||
pub fn default_view_widget(app: &App, area: Rect, buf: &mut Buffer) {
|
||||
let vertical_layout: Layout = Layout::vertical([Constraint::Fill(1), Constraint::Length(4)]);
|
||||
|
||||
let [main_area, keybindings_area] = vertical_layout.areas(area);
|
||||
|
||||
Paragraph::new("Work in progress")
|
||||
.alignment(Alignment::Center)
|
||||
.yellow()
|
||||
.block(
|
||||
Block::new()
|
||||
.gray()
|
||||
.borders(Borders::LEFT | Borders::TOP | Borders::RIGHT),
|
||||
)
|
||||
.render(main_area, buf);
|
||||
|
||||
KeybindingsWidget::new(app.view).render(keybindings_area, buf);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
pub mod default;
|
||||
pub mod keybindings;
|
||||
pub mod main_menu;
|
||||
|
||||
pub use default::default_view_widget;
|
||||
pub use keybindings::KeybindingsWidget;
|
||||
pub use main_menu::main_menu_widget;
|
||||
|
||||
Reference in New Issue
Block a user