Skip to content

Commit

Permalink
Register the Property Editor as a standalone screen (flutter#8600)
Browse files Browse the repository at this point in the history
Work towards flutter#8546

With the changes @DanTup has made in the VS Code extension, this allows us to now test the Property Editor in VS Code � 

![propery_editor_in_ide](https://github.com/user-attachments/assets/8585ff69-0bf7-427d-9d6c-6796f964f6f4)
  • Loading branch information
elliette authored Dec 9, 2024
1 parent 381ab87 commit 05daeec
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions packages/devtools_app/lib/src/standalone_ui/standalone_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:dtd/dtd.dart';
import 'package:flutter/material.dart';

import '../shared/globals.dart';
import '../shared/ui/common_widgets.dart';
import 'vs_code/flutter_panel.dart';
import 'vs_code/property_editor_panel.dart';

/// "Screens" that are intended for standalone use only, likely for embedding
/// directly in an IDE.
Expand All @@ -18,6 +20,7 @@ enum StandaloneScreenType {
// TODO(elliette): Add property editor as a standalone screen, see:
// https://github.com/flutter/devtools/issues/8546
editorSidebar,
propertyEditor,
vsCodeFlutterPanel; // Legacy postMessage version, shows an upgrade message.

Widget get screen {
Expand All @@ -36,11 +39,37 @@ enum StandaloneScreenType {
// useful message.
valueListenable: dtdManager.connection,
builder: (context, data, _) {
return data == null
? const CenteredCircularProgressIndicator()
: EditorSidebarPanel(data);
return _DtdConnectedScreen(
dtd: data,
screenProvider: (dtd) => EditorSidebarPanel(dtd),
);
},
),
StandaloneScreenType.propertyEditor => ValueListenableBuilder(
valueListenable: dtdManager.connection,
builder: (context, data, _) {
return _DtdConnectedScreen(
dtd: data,
screenProvider: (dtd) => PropertyEditorSidebarPanel(dtd),
);
},
),
};
}
}

/// Widget that returns a [CenteredCircularProgressIndicator] while it waits for
/// a [DartToolingDaemon] connection.
class _DtdConnectedScreen extends StatelessWidget {
const _DtdConnectedScreen({required this.dtd, required this.screenProvider});

final DartToolingDaemon? dtd;
final Widget Function(DartToolingDaemon) screenProvider;

@override
Widget build(BuildContext context) {
return dtd == null
? const CenteredCircularProgressIndicator()
: screenProvider(dtd!);
}
}

0 comments on commit 05daeec

Please sign in to comment.