Finish up ThemeRegistry
and remove AnyAssetSource
This commit is contained in:
parent
51c66f508b
commit
4ca7ddfc42
9 changed files with 39 additions and 51 deletions
|
@ -1,17 +1,14 @@
|
|||
use crate::{Theme, ThemeMetadata, themes::one_dark};
|
||||
use anyhow::Result;
|
||||
use gpui2::{AnyAssetSource, SharedString};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::Arc
|
||||
};
|
||||
use crate::{themes::one_dark, Theme, ThemeMetadata};
|
||||
use anyhow::{anyhow, Result};
|
||||
use gpui2::SharedString;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
pub struct ThemeRegistry {
|
||||
themes: HashMap<SharedString, Arc<Theme>>,
|
||||
}
|
||||
|
||||
impl ThemeRegistry {
|
||||
pub fn new(assets: AnyAssetSource) -> Self {
|
||||
pub fn new() -> Self {
|
||||
let mut this = Self {
|
||||
themes: HashMap::default(),
|
||||
};
|
||||
|
@ -23,19 +20,24 @@ impl ThemeRegistry {
|
|||
|
||||
fn insert_themes(&mut self, themes: impl IntoIterator<Item = Theme>) {
|
||||
for theme in themes.into_iter() {
|
||||
self.themes.insert(theme.metadata.name.clone(), Arc::new(theme));
|
||||
self.themes
|
||||
.insert(theme.metadata.name.clone(), Arc::new(theme));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_names(&self, staff: bool) -> impl Iterator<Item = SharedString> + '_ {
|
||||
None.into_iter()
|
||||
pub fn list_names(&self, _staff: bool) -> impl Iterator<Item = SharedString> + '_ {
|
||||
self.themes.keys().cloned()
|
||||
}
|
||||
|
||||
pub fn list(&self, staff: bool) -> impl Iterator<Item = ThemeMetadata> + '_ {
|
||||
None.into_iter()
|
||||
pub fn list(&self, _staff: bool) -> impl Iterator<Item = ThemeMetadata> + '_ {
|
||||
self.themes.values().map(|theme| theme.metadata.clone())
|
||||
}
|
||||
|
||||
pub fn get(&self, name: impl Into<SharedString>) -> Result<Arc<Theme>> {
|
||||
todo!()
|
||||
let name = name.into();
|
||||
self.themes
|
||||
.get(&name)
|
||||
.ok_or_else(|| anyhow!("theme not found: {}", name))
|
||||
.cloned()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue