src/traits/item.rs

be4224817b612a60266af4f70f7e6836e60d0e9c
youtube-tui/src/traits/item.rs history · blame · raw

29 lines · 727 bytes

 1use std::error::Error;
 2
 3use crate::{
 4    app::app::App,
 5    structs::{Item, WatchHistory},
 6};
 7use crossterm::event::KeyCode;
 8use tui::{backend::Backend, layout::Rect, Frame};
 9
10pub trait ItemTrait {
11    fn key_input(&mut self, key: KeyCode, app: App) -> (bool, App);
12    fn render_item<B: Backend>(
13        &mut self,
14        frame: &mut Frame<B>,
15        rect: Rect,
16        app: App,
17        selected: bool,
18        hover: bool,
19        popup_focus: bool,
20        popup_render: bool,
21    ) -> (bool, App);
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}