123 lines
2.4 KiB
Rust
123 lines
2.4 KiB
Rust
pub struct BeoApps {
|
|
pub apps: Vec<Box<dyn App>>,
|
|
}
|
|
|
|
struct MainMenu {
|
|
pub last_id: usize,
|
|
pub default_id: usize,
|
|
pub names: Vec<String>,
|
|
}
|
|
|
|
pub struct AppBase {
|
|
name: String,
|
|
pub main_menu: MainMenu,
|
|
}
|
|
|
|
impl AppBase {
|
|
pub fn name(&self) -> &str {
|
|
&self.name
|
|
}
|
|
}
|
|
|
|
pub trait App {
|
|
fn base(&self) -> &AppBase;
|
|
// fn main_menu(&self) -> &MainMenu;
|
|
}
|
|
|
|
struct Spotify {
|
|
base: AppBase,
|
|
}
|
|
|
|
impl Spotify {
|
|
fn new() -> Self {
|
|
Spotify {
|
|
base: AppBase {
|
|
name: "Spotify".to_string(),
|
|
main_menu: MainMenu {
|
|
last_id: 0,
|
|
default_id: 0,
|
|
names: vec![
|
|
"Playlists".to_string(),
|
|
"Artists".to_string(),
|
|
"Albums".to_string(),
|
|
],
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
impl App for Spotify {
|
|
fn base(&self) -> &AppBase {
|
|
&self.base
|
|
}
|
|
}
|
|
|
|
// Similar implementations for other apps like Radio and Settings
|
|
struct Radio {
|
|
base: AppBase,
|
|
}
|
|
|
|
impl Radio {
|
|
fn new() -> Self {
|
|
Radio {
|
|
base: AppBase {
|
|
name: "Radio".to_string(),
|
|
main_menu: MainMenu {
|
|
last_id: 0,
|
|
default_id: 0,
|
|
names: vec![
|
|
"Favorites".to_string(),
|
|
"Local".to_string(),
|
|
"Global".to_string(),
|
|
],
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
impl App for Radio {
|
|
fn base(&self) -> &AppBase {
|
|
&self.base
|
|
}
|
|
}
|
|
|
|
struct Settings {
|
|
base: AppBase,
|
|
}
|
|
|
|
impl Settings {
|
|
fn new() -> Self {
|
|
Settings {
|
|
base: AppBase {
|
|
name: "Settings".to_string(),
|
|
main_menu: MainMenu {
|
|
last_id: 0,
|
|
default_id: 0,
|
|
names: vec![
|
|
"Display".to_string(),
|
|
"Sound".to_string(),
|
|
"Network".to_string(),
|
|
],
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
impl App for Settings {
|
|
fn base(&self) -> &AppBase {
|
|
&self.base
|
|
}
|
|
}
|
|
|
|
pub fn get_beo_apps() -> BeoApps {
|
|
let apps: Vec<Box<dyn App>> = vec![
|
|
Box::new(Spotify::new()),
|
|
Box::new(Radio::new()),
|
|
Box::new(Settings::new()),
|
|
];
|
|
BeoApps { apps }
|
|
}
|