Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
Frank Villaro-Dixon 2024-05-16 22:39:08 +02:00
parent 5456c6845e
commit 1e4b6f7d16

View file

@ -33,7 +33,7 @@ impl AppBase {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Menu { pub struct Menu {
pub submenus: Vec<Box<Menu>>, pub submenus: Vec<Menu>,
current_submenu_id: usize, current_submenu_id: usize,
pub selected_submenu: Option<Box<Menu>>, pub selected_submenu: Option<Box<Menu>>,
pub name: String, pub name: String,
@ -46,7 +46,7 @@ impl Menu {
panic!("Invalid submenu id"); panic!("Invalid submenu id");
} }
self.current_submenu_id = id; self.current_submenu_id = id;
self.selected_submenu = Some(self.submenus[self.current_submenu_id].clone()); self.selected_submenu = Some(Box::new(self.submenus[self.current_submenu_id].clone()));
} }
pub fn get_deepest_selected_submenu(&self) -> &Menu { pub fn get_deepest_selected_submenu(&self) -> &Menu {
@ -71,74 +71,74 @@ struct Spotify {
impl Spotify { impl Spotify {
fn new() -> Self { fn new() -> Self {
let spotify_menus = vec![ let spotify_menus = vec![
Box::new(Menu { Menu {
submenus: vec![ submenus: vec![
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Liked Songs".to_string(), name: "Liked Songs".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Recently Played".to_string(), name: "Recently Played".to_string(),
}), },
], ],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Playlists".to_string(), name: "Playlists".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![ submenus: vec![
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Mike Oldfield".to_string(), name: "Mike Oldfield".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "JM. Jarre".to_string(), name: "JM. Jarre".to_string(),
}), },
], ],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Artists".to_string(), name: "Artists".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Albums".to_string(), name: "Albums".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Songs".to_string(), name: "Songs".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Genres".to_string(), name: "Genres".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "New Releases".to_string(), name: "New Releases".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Charts".to_string(), name: "Charts".to_string(),
}), },
]; ];
Spotify { Spotify {
base: AppBase { base: AppBase {
@ -171,24 +171,24 @@ struct Radio {
impl Radio { impl Radio {
fn new() -> Self { fn new() -> Self {
let radio_menus = vec![ let radio_menus = vec![
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Favorites".to_string(), name: "Favorites".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Local".to_string(), name: "Local".to_string(),
}), },
Box::new(Menu { Menu {
submenus: vec![], submenus: vec![],
current_submenu_id: 0, current_submenu_id: 0,
selected_submenu: None, selected_submenu: None,
name: "Global".to_string(), name: "Global".to_string(),
}), },
]; ];
Radio { Radio {
base: AppBase { base: AppBase {