Skip to content

extensions: Read the IdeTheme and notify extension app #9182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ TODO: Remove this section if there are not any general updates.

## DevTools Extension updates

TODO: Remove this section if there are not any general updates.
- Extensions which are embedded in the IDE window now display with the correct
IDE theme.

## Full commit history

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class _DevToolsExtensionState extends State<DevToolsExtension>
}

addAutoDisposeListener(extensionManager.darkThemeEnabled);
addAutoDisposeListener(extensionManager.theme);
}

void _initGlobals() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class ExtensionManager {
/// notifications from this notifier.
final darkThemeEnabled = ValueNotifier<bool>(useDarkThemeAsDefault);

/// The [IdeTheme] which has been parsed from the query parameters.
///
/// Ultimately, the theme is fetched from [globals], but this [ValueNotifier]
/// notifies listeners when it changes.
final theme = ValueNotifier<IdeTheme?>(null);

/// Registers an event handler for [DevToolsExtensionEvent]s of type [type].
///
/// When an event of type [type] is received by the extension, [handler] will
Expand Down Expand Up @@ -50,7 +56,9 @@ class ExtensionManager {
_handleMessageListener = _handleMessage.toJS,
);

// TODO(kenz): handle the ide theme that may be part of the query params.
setGlobal(IdeTheme, getIdeTheme());
theme.value = ideTheme;

final queryParams = loadQueryParams();
final themeValue = queryParams[ExtensionEventParameters.theme];
_setThemeForValue(themeValue);
Expand Down