src/traits/item.rs
30 lines · 784 bytes
1use std::error::Error;
2
3use crate::{
4 app::app::{App, AppNoState},
5 structs::{Item, WatchHistory},
6};
7use crossterm::event::KeyEvent;
8use tui::{backend::Backend, layout::Rect, Frame};
9
10pub trait ItemTrait {
11 fn key_input(&mut self, key: KeyEvent, app: App) -> (bool, App);
12 fn render_item<B: Backend>(
13 &mut self,
14 frame: &mut Frame<B>,
15 rect: Rect,
16 app: AppNoState,
17 selected: bool,
18 hover: bool,
19 popup_focus: bool,
20 popup_render: bool,
21 ) -> (bool, AppNoState);
22 fn select(&mut self, app: App) -> (App, bool);
23 fn selectable(&self) -> bool;
24 fn load_item(
25 &self,
26 app: &App,
27 watch_history: &mut WatchHistory,
28 ) -> Result<Item, Box<dyn Error>>;
29 fn reset(&mut self) {}
30}