71 lines
1.7 KiB
Rust
71 lines
1.7 KiB
Rust
use color_eyre::Result;
|
|
use crossterm::event::{KeyEvent, MouseEvent};
|
|
use ratatui::{
|
|
layout::{Rect, Size},
|
|
Frame,
|
|
};
|
|
use tokio::sync::mpsc::UnboundedSender;
|
|
use std::sync::mpsc::Sender;
|
|
|
|
use crate::{palette, action::Action, config::Config, tui::Event};
|
|
|
|
pub mod layouts;
|
|
pub mod fps;
|
|
pub mod health;
|
|
pub mod menu;
|
|
pub mod version;
|
|
pub mod explorer;
|
|
pub mod wallet;
|
|
pub mod validator;
|
|
pub mod empty;
|
|
pub mod help;
|
|
pub mod generic;
|
|
|
|
pub trait Component {
|
|
fn register_network_handler(&mut self, tx: Sender<Action>) -> Result<()> {
|
|
let _ = tx;
|
|
Ok(())
|
|
}
|
|
|
|
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
|
|
let _ = tx;
|
|
Ok(())
|
|
}
|
|
|
|
fn register_config_handler(&mut self, config: Config) -> Result<()> {
|
|
let _ = config;
|
|
Ok(())
|
|
}
|
|
|
|
fn handle_events(&mut self, event: Option<Event>) -> Result<Option<Action>> {
|
|
let action = match event {
|
|
Some(Event::Key(key_event)) => self.handle_key_event(key_event)?,
|
|
Some(Event::Mouse(mouse_event)) => self.handle_mouse_event(mouse_event)?,
|
|
_ => None,
|
|
};
|
|
Ok(action)
|
|
}
|
|
|
|
fn handle_key_event(&mut self, key: KeyEvent) -> Result<Option<Action>> {
|
|
let _ = key;
|
|
Ok(None)
|
|
}
|
|
|
|
fn handle_mouse_event(&mut self, mouse: MouseEvent) -> Result<Option<Action>> {
|
|
let _ = mouse;
|
|
Ok(None)
|
|
}
|
|
|
|
fn init(&mut self, area: Size) -> Result<()> {
|
|
let _ = area;
|
|
Ok(())
|
|
}
|
|
|
|
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
|
let _ = action;
|
|
Ok(None)
|
|
}
|
|
|
|
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()>;
|
|
}
|