src/app/pages/main_menu.rs
78 lines · 2492 bytes
1use crate::app::app::{GlobalItem, Item, Row, RowItem};
2use invidious::structs::video::Video;
3use tui::layout::Constraint;
4
5#[derive(Debug)]
6pub enum MainMenuItem {
7 SeletorTab(MainMenuSelector),
8 VideoList(Option<Vec<Video>>, Option<usize>), // Videos, index
9 VideoDetails(Option<Video>), // Single video
10}
11
12#[derive(Debug)]
13pub enum MainMenuSelector {
14 Trending,
15 Popular,
16 History,
17}
18
19impl MainMenuSelector {
20 pub fn default() -> Self {
21 Self::Trending
22 }
23}
24
25pub struct MainMenu;
26
27impl MainMenu {
28 pub fn default() -> Vec<Row> {
29 vec![
30 Row {
31 items: vec![RowItem {
32 item: Item::Global(GlobalItem::SearchBar(Vec::new())),
33 constraint: Constraint::Percentage(100),
34 }],
35 centered: false,
36 height: Constraint::Length(3),
37 },
38 Row {
39 items: vec![RowItem {
40 item: Item::MainMenu(MainMenuItem::SeletorTab(MainMenuSelector::Trending)),
41 constraint: Constraint::Length(15),
42 },
43 RowItem {
44 item: Item::MainMenu(MainMenuItem::SeletorTab(MainMenuSelector::Popular)),
45 constraint: Constraint::Length(15),
46 },
47 RowItem {
48 item: Item::MainMenu(MainMenuItem::SeletorTab(MainMenuSelector::History)),
49 constraint: Constraint::Length(15),
50 }],
51 centered: true,
52 height: Constraint::Length(3),
53 },
54 Row {
55 items: vec![
56 RowItem {
57 item: Item::MainMenu(MainMenuItem::VideoList(None, None)),
58 constraint: Constraint::Percentage(40),
59 },
60 RowItem {
61 item: Item::MainMenu(MainMenuItem::VideoDetails(None)),
62 constraint: Constraint::Percentage(60),
63 },
64 ],
65 centered: false,
66 height: Constraint::Min(6),
67 },
68 Row {
69 items: vec![RowItem {
70 item: Item::Global(GlobalItem::MessageBar(None)),
71 constraint: Constraint::Percentage(100),
72 }],
73 centered: false,
74 height: Constraint::Length(3),
75 },
76 ]
77 }
78}