Compare commits
2 commits
857f0771f0
...
e4a840d7e4
Author | SHA1 | Date | |
---|---|---|---|
e4a840d7e4 | |||
11e10c0f5e |
7 changed files with 44 additions and 12 deletions
|
@ -8,4 +8,4 @@ edition = "2021"
|
|||
[dependencies]
|
||||
crossterm = "0.26.1"
|
||||
ratatui = "0.21.0"
|
||||
rusqlite = "0.29.0"
|
||||
sqlx = { version = "0.6.3", features = ["postgres", "runtime-tokio-native-tls", "sqlite"] }
|
||||
|
|
|
@ -14,5 +14,9 @@
|
|||
buildInputs = with pkgs; [
|
||||
ruststable
|
||||
rust-analyzer
|
||||
bacon
|
||||
|
||||
pkg-config
|
||||
openssl
|
||||
];
|
||||
}
|
||||
|
|
0
src/db.rs
Normal file
0
src/db.rs
Normal file
|
@ -4,3 +4,5 @@ pub mod app;
|
|||
pub mod tui;
|
||||
|
||||
pub mod ui;
|
||||
|
||||
pub mod uis;
|
||||
|
|
32
src/ui.rs
32
src/ui.rs
|
@ -1,6 +1,4 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::app::{AppResult, App};
|
||||
use crate::app::App;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
|
@ -10,6 +8,8 @@ use ratatui::{
|
|||
Frame,
|
||||
};
|
||||
|
||||
use crate::uis::render_history_tab;
|
||||
|
||||
|
||||
pub fn render<B: Backend> (f: &mut Frame<B>, app: &App) {
|
||||
|
||||
|
@ -19,24 +19,33 @@ pub fn render<B: Backend> (f: &mut Frame<B>, app: &App) {
|
|||
.constraints([Constraint::Length(3), Constraint::Min(0)].as_ref())
|
||||
.split(size);
|
||||
|
||||
let bottom_block = Block::default();
|
||||
let bottom_block = Block::default()
|
||||
.borders(Borders::ALL);
|
||||
f.render_widget(bottom_block, chunks[1]);
|
||||
|
||||
render_statusbar(f, chunks[0], app);
|
||||
|
||||
let bottom_chunk = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.margin(1)
|
||||
.constraints([Constraint::Percentage(100)])
|
||||
.split(chunks[1]);
|
||||
// if app.tabs selected == history,
|
||||
render_history_tab(f, bottom_chunk[0], app);
|
||||
}
|
||||
|
||||
pub fn render_statusbar<B: Backend> (f: &mut Frame<B>, status_rect: Rect, app: &App) {
|
||||
|
||||
let status_bar_chunks = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Percentage(50), Constraint::Min(10)])
|
||||
.margin(1)
|
||||
.constraints([Constraint::Percentage(75), Constraint::Min(10)])
|
||||
.split(status_rect);
|
||||
|
||||
let top_block = Block::default()
|
||||
let left_block = Block::default()
|
||||
.borders(Borders::ALL);
|
||||
let right_block = Block::default()
|
||||
.borders(Borders::ALL);
|
||||
|
||||
f.render_widget(top_block, status_rect);
|
||||
|
||||
let titles = app
|
||||
.tabs
|
||||
|
@ -46,9 +55,10 @@ pub fn render_statusbar<B: Backend> (f: &mut Frame<B>, status_rect: Rect, app: &
|
|||
.collect();
|
||||
|
||||
let tabs = Tabs::new(titles)
|
||||
.block(Block::default().borders(Borders::NONE))
|
||||
//.block(Block::default().borders(Borders::NONE))
|
||||
.block(left_block)
|
||||
.select(app.tab_index)
|
||||
.style(Style::default().fg(Color::Cyan))
|
||||
//.style(Style::default().fg(Color::Cyan))
|
||||
.highlight_style(
|
||||
Style::default()
|
||||
.fg(Color::White)
|
||||
|
@ -62,7 +72,7 @@ pub fn render_statusbar<B: Backend> (f: &mut Frame<B>, status_rect: Rect, app: &
|
|||
Text::styled("Aurora",
|
||||
Style::default().fg(Color::Green)
|
||||
)
|
||||
);
|
||||
).block(right_block);
|
||||
|
||||
f.render_widget(connection_paragraph, status_bar_chunks[1]);
|
||||
}
|
||||
|
|
12
src/uis/history.rs
Normal file
12
src/uis/history.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use ratatui::{backend::Backend, Frame, layout::Rect, widgets::Paragraph, text::Text, style::{Style, Color}};
|
||||
use crate::app::App;
|
||||
|
||||
|
||||
pub fn render_history_tab<B: Backend> (f: &mut Frame<B>, status_rect: Rect, app: &App) {
|
||||
let connection_paragraph = Paragraph::new(
|
||||
Text::styled("I'm a ghost!",
|
||||
Style::default().fg(Color::Green)
|
||||
)
|
||||
);
|
||||
f.render_widget(connection_paragraph, status_rect);
|
||||
}
|
4
src/uis/mod.rs
Normal file
4
src/uis/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
|
||||
pub mod history;
|
||||
pub use self::history::render_history_tab;
|
Loading…
Reference in a new issue