Skip to content

Commit

Permalink
Revert "Add testing printouts"
Browse files Browse the repository at this point in the history
This reverts commit ddb45af.
  • Loading branch information
helin24 committed Sep 30, 2024
1 parent 0c711aa commit d718c0e
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 95 deletions.
9 changes: 1 addition & 8 deletions packages/devtools_app/lib/src/framework/framework_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@ abstract class FrameworkCore {
Future<void> _initDTDConnection() async {
try {
// Get the dtdUri from the devtools server
// TODO(helin24): Remove testing code for theme event.
final runningInIde = false;
final dtdUri = runningInIde
? await server.getDtdUri()
: Uri.parse('ws://127.0.0.1:52400/bWpURPBJaAAVvw6S');
final dtdUri = await server.getDtdUri();

if (dtdUri != null) {
await dtdManager.connect(
Expand All @@ -197,9 +193,6 @@ Future<void> _initDTDConnection() async {
if (dtdManager.connection.value != null) {
themeManager = EditorThemeManager(dtdManager.connection.value!);
themeManager!.listenForThemeChanges();
if (!runningInIde) {
dtdManager.sendTestEvent();
}
}
} else {
_log.info('No DTD uri provided from the server during initialization.');
Expand Down
19 changes: 0 additions & 19 deletions packages/devtools_app/lib/src/framework/settings_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import '../shared/feature_flags.dart';
import '../shared/globals.dart';
import '../shared/log_storage.dart';
import '../shared/server/server.dart';
import 'theme_manager.dart';

class OpenSettingsAction extends ScaffoldAction {
OpenSettingsAction({super.key, super.color})
Expand All @@ -41,8 +40,6 @@ class SettingsDialog extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final analyticsController = Provider.of<AnalyticsController>(context);
// TODO(helin24): Remove this code to test theme change
final ValueNotifier<bool> themeChange = ValueNotifier<bool>(true);
return DevToolsDialog(
title: const DialogTitleText('Settings'),
content: Column(
Expand Down Expand Up @@ -71,22 +68,6 @@ class SettingsDialog extends StatelessWidget {
gaItem: gac.analytics,
),
),
// TODO(helin24): Remove this code to test theme change
Flexible(
child: CheckboxSetting(
title: 'Test out theme change',
notifier: themeChange,
onChanged: (enable) {
if (enable!) {
dtdManager.sendTestEvent2();
} else {
dtdManager.sendTestEvent3();
}
},
gaScreen: gac.settingsDialog,
gaItem: gac.analytics,
),
),
Flexible(
child: CheckboxSetting(
title: 'Enable VM developer mode',
Expand Down
8 changes: 1 addition & 7 deletions packages/devtools_app/lib/src/framework/theme_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ final _log = Logger('theme_manager');
/// Manages changes in theme settings from an editor/IDE.
class EditorThemeManager extends DisposableController
with AutoDisposeControllerMixin {
EditorThemeManager(DartToolingDaemon dtd)
: editorClient = DtdEditorClient(dtd);
EditorThemeManager(DartToolingDaemon dtd) : editorClient = DtdEditorClient(dtd);

final DtdEditorClient editorClient;

void listenForThemeChanges() {
autoDisposeStreamSubscription(
editorClient.event.listen((event) {
if (event is ThemeChangedEvent) {
print('received a ThemeChangedEvent');
print(event);
final currentTheme = getIdeTheme();
final newTheme = event.theme;

Expand Down Expand Up @@ -82,9 +79,6 @@ class EditorThemeManager extends DisposableController
// features.
preferences.toggleDarkModeTheme(!newTheme.isDarkMode);
preferences.toggleDarkModeTheme(newTheme.isDarkMode);

print('got theme changed event');
print(currentTheme);
}
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class DtdEditorClient extends EditorClient with AutoDisposeControllerMixin {
autoDisposeStreamSubscription(
_dtd.onEvent(editorStreamName).listen((data) {
final kind = editorKindMap[data.kind];

// Unable to do this from IJ
final event = switch (kind) {
// Unknown event. Use null here so we get exhaustiveness checking for
// the rest.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ class _EditorConnectedPanelState extends State<_EditorConnectedPanel>
case DebugSessionStoppedEvent(:final debugSessionId):
debugSessions.remove(debugSessionId);
case ThemeChangedEvent():
print('event is theme change');
print(event);
// TODO: Handle this case.
// Do nothing; this is handled elsewhere.
}
});
}),
Expand Down
55 changes: 0 additions & 55 deletions packages/devtools_app_shared/lib/src/service/dtd_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app/src/service/editor/api_classes.dart';
import 'package:dtd/dtd.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
Expand Down Expand Up @@ -30,16 +29,11 @@ class DTDManager {
Future<void> connect(
Uri uri, {
void Function(Object, StackTrace?)? onError,
// Map<String, Function(DtdEvent)> eventHandlers,
}) async {
await disconnect();

try {
_connection.value = await DartToolingDaemon.connect(uri);
// _connection.value.onEvent('Editor').listen((data {
//
// }));
// _connection.value.streamListen('Editor');
_uri = uri;
_log.info('Successfully connected to DTD at: $uri');
} catch (e, st) {
Expand All @@ -64,55 +58,6 @@ class DTDManager {
_connection.dispose();
}

// TODO(helin24): Remove this code to test theme change event
void sendTestEvent() {
_log.info('about to send theme changed event');
_dtd.postEvent(
'Editor',
'themeChanged',
ThemeChangedEvent(
theme: EditorTheme(
isDarkMode: false,
backgroundColor: 'ff5733',
// foregroundColor: '',
fontSize: 24,
),
).toJson());
_log.info('after sending theme changed event');
}

void sendTestEvent2() {
_log.info('about to send theme changed event 2');
_dtd.postEvent(
'Editor',
'themeChanged',
ThemeChangedEvent(
theme: EditorTheme(
isDarkMode: false,
backgroundColor: 'ff5733',
// foregroundColor: '',
fontSize: 14,
),
).toJson());
_log.info('after sending theme changed event 2');
}

void sendTestEvent3() {
_log.info('about to send theme changed event 3');
_dtd.postEvent(
'Editor',
'themeChanged',
ThemeChangedEvent(
theme: EditorTheme(
isDarkMode: true,
backgroundColor: '000000',
// foregroundColor: '',
fontSize: 18,
),
).toJson());
_log.info('after sending theme changed event 3');
}

/// Returns the workspace roots for the Dart Tooling Daemon connection.
///
/// These roots are set by the tool that started DTD, which may be the IDE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final _log = Logger('ide_theme');

/// IDE-supplied theming.
final class IdeTheme {
IdeTheme({
IdeTheme({
this.backgroundColor,
this.foregroundColor,
this.fontSize = unscaledDefaultFontSize,
Expand Down

0 comments on commit d718c0e

Please sign in to comment.