theme: Turn ThemeRegistry into a trait (#20076)
This PR converts the `ThemeRegistry` type into a trait instead of a concrete implementation. This allows for the extension store to depend on an abstraction rather than the concrete theme registry implementation. We currently have two `ThemeRegistry` implementations: - `RealThemeRegistry` — this was previously the `ThemeRegistry` and contains the real implementation of the registry. - `VoidThemeRegistry` — a null object that doesn't have any behavior. Release Notes: - N/A
This commit is contained in:
@@ -97,7 +97,7 @@ impl ThemeSelectorDelegate {
|
||||
let original_theme = cx.theme().clone();
|
||||
|
||||
let staff_mode = cx.is_staff();
|
||||
let registry = ThemeRegistry::global(cx);
|
||||
let registry = <dyn ThemeRegistry>::global(cx);
|
||||
let mut themes = registry
|
||||
.list(staff_mode)
|
||||
.into_iter()
|
||||
@@ -142,7 +142,7 @@ impl ThemeSelectorDelegate {
|
||||
|
||||
fn show_selected_theme(&mut self, cx: &mut ViewContext<Picker<ThemeSelectorDelegate>>) {
|
||||
if let Some(mat) = self.matches.get(self.selected_index) {
|
||||
let registry = ThemeRegistry::global(cx);
|
||||
let registry = <dyn ThemeRegistry>::global(cx);
|
||||
match registry.get(&mat.string) {
|
||||
Ok(theme) => {
|
||||
Self::set_theme(theme, cx);
|
||||
|
||||
Reference in New Issue
Block a user