64 lines
2.2 KiB
Rust
64 lines
2.2 KiB
Rust
use crossterm::style;
|
|
use ratatui::{
|
|
layout::{Constraint, Direction, Layout, Rect},
|
|
style::{Color, Style, Modifier},
|
|
text::{self, Line, Span, Text},
|
|
widgets::{
|
|
Block, Borders, Clear, List, ListItem,Tabs, Paragraph, Wrap,
|
|
canvas::{self, Canvas, Circle, Map, MapResolution, Rectangle},
|
|
|
|
},
|
|
symbols,
|
|
Frame,
|
|
};
|
|
|
|
use crate::app::App;
|
|
|
|
pub fn render(frame: &mut Frame, app: &mut App) {
|
|
let chunks = Layout::vertical([Constraint::Length(3), Constraint::Min(1), Constraint::Length(3)]).split(frame.area());
|
|
let tabs = app.tabs
|
|
.titles
|
|
.iter()
|
|
.map(|t| text::Line::from(Span::styled(*t, Style::default().fg(Color::Green))))
|
|
.collect::<Tabs>()
|
|
.block(Block::bordered().title(app.title))
|
|
.highlight_style(Style::default().fg(Color::Yellow))
|
|
.select(app.tabs.index);
|
|
frame.render_widget(tabs, chunks[0]);
|
|
match app.tabs.index {
|
|
0 => draw_dashboard_tab(frame, app, chunks[1]),
|
|
1 => draw_machine_tab(frame, app, chunks[1]),
|
|
2 => draw_conf_tab(frame, app, chunks[1]),
|
|
_ => {}
|
|
};
|
|
draw_statusbar(frame, app, chunks[2]);
|
|
}
|
|
|
|
pub fn draw_dashboard_tab(frame: &mut Frame, app: &mut App, area: Rect) {
|
|
let chunks = Layout::vertical([Constraint::Percentage(50), Constraint::Percentage(50)]).split(area);
|
|
{
|
|
let chunks = Layout::horizontal([Constraint::Percentage(30), Constraint::Percentage(40), Constraint::Percentage(30)]).split(chunks[0]);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
pub fn draw_machine_tab(frame: &mut Frame, app: &mut App, area: Rect) {
|
|
|
|
}
|
|
|
|
pub fn draw_conf_tab(frame: &mut Frame, app: &mut App, area: Rect) {
|
|
|
|
}
|
|
|
|
pub fn draw_statusbar(frame: &mut Frame, app: &mut App, area: Rect) {
|
|
let chunks = Layout::horizontal([Constraint::Length(25), Constraint::Min(0)]).split(area);
|
|
let status = Block::bordered().title(Span::styled("Status", Style::default().fg(Color::Cyan).add_modifier(Modifier::BOLD),));
|
|
let statustext = Paragraph::new("Todo...").block(status);
|
|
frame.render_widget(statustext, chunks[0]);
|
|
|
|
let keysblock = Block::bordered();
|
|
let keystext = Paragraph::new(app.tabkeystext[app.tabs.index]).block(keysblock);
|
|
frame.render_widget(keystext, chunks[1]);
|
|
}
|