Skip to content

Commit

Permalink
[Inspector V2] Hide implementation widgets by default (#8647)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Dec 20, 2024
1 parent ba8a14f commit 2ffc52c
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class InspectorController extends DisposableController
/// Whether the implementation widgets are hidden in the widget tree.
ValueListenable<bool> get implementationWidgetsHidden =>
_implementationWidgetsHidden;
final _implementationWidgetsHidden = ValueNotifier<bool>(false);
final _implementationWidgetsHidden = ValueNotifier<bool>(true);

InspectorTreeNode? lastExpanded;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ void main() {
(WidgetTester tester) async {
await _loadInspectorUI(tester);

// Toggle implementation widgets on.
await _toggleImplementationWidgets(tester);

// Before hidden widgets are expanded, confirm the HeroControllerScope
// is hidden:
final hideableNodeFinder = findNodeMatching('HeroControllerScope');
Expand Down Expand Up @@ -207,6 +210,9 @@ void main() {
) async {
await _loadInspectorUI(tester);

// Toggle implementation widgets on.
await _toggleImplementationWidgets(tester);

// Before searching, confirm the HeroControllerScope is hidden:
final hideableNodeFinder = findNodeMatching('HeroControllerScope');
expect(hideableNodeFinder, findsNothing);
Expand Down Expand Up @@ -239,21 +245,15 @@ void main() {
) async {
await _loadInspectorUI(tester);

// Give time for the initial animation to complete.
await tester.pumpAndSettle(inspectorChangeSettleTime);
// Toggle implementation widgets on.
await _toggleImplementationWidgets(tester);

// Confirm the hidden widgets are visible behind affordances like "X more
// widgets".
expect(find.richTextContaining('more widgets...'), findsWidgets);

// Tap the "Show Implementation Widgets" button (selected by default).
final showImplementationWidgetsButton = find.descendant(
of: find.byType(DevToolsToggleButton),
matching: find.text('Show Implementation Widgets'),
);
expect(showImplementationWidgetsButton, findsOneWidget);
await tester.tap(showImplementationWidgetsButton);
await tester.pumpAndSettle(inspectorChangeSettleTime);
// Toggle implementation widgets off.
await _toggleImplementationWidgets(tester);

// Confirm that the hidden widgets are no longer visible.
expect(find.richTextContaining('more widgets...'), findsNothing);
Expand Down Expand Up @@ -287,6 +287,10 @@ void main() {
) async {
// Load the Inspector.
await _loadInspectorUI(tester);

// Toggle implementation widgets on.
await _toggleImplementationWidgets(tester);

await tester.pumpAndSettle(inspectorChangeSettleTime);
final state =
tester.state(find.byType(InspectorScreenBody))
Expand All @@ -300,14 +304,8 @@ void main() {
diagnostics.firstWhere((d) => d?.description == 'Text')!;
expect(textDiagnostic.isCreatedByLocalProject, isTrue);

// Tap the "Show Implementation Widgets" button (selected by default).
final showImplementationWidgetsButton = find.descendant(
of: find.byType(DevToolsToggleButton),
matching: find.text('Show Implementation Widgets'),
);
expect(showImplementationWidgetsButton, findsOneWidget);
await tester.tap(showImplementationWidgetsButton);
await tester.pumpAndSettle(inspectorChangeSettleTime);
// Toggle implementation widgets off.
await _toggleImplementationWidgets(tester);

// Verify the Text diagnostic node is still in the tree.
final diagnosticsNow = state.controller.inspectorTree.rowsInTree.value.map(
Expand Down Expand Up @@ -505,6 +503,9 @@ void main() {
) async {
await _loadInspectorUI(tester);

// Toggle implementation widgets on.
await _toggleImplementationWidgets(tester);

// Give time for the initial animation to complete.
await tester.pumpAndSettle(inspectorChangeSettleTime);

Expand Down Expand Up @@ -596,6 +597,17 @@ void main() {
});
}

Future<void> _toggleImplementationWidgets(WidgetTester tester) async {
// Tap the "Show Implementation Widgets" button (selected by default).
final showImplementationWidgetsButton = find.descendant(
of: find.byType(DevToolsToggleButton),
matching: find.text('Show Implementation Widgets'),
);
expect(showImplementationWidgetsButton, findsOneWidget);
await tester.tap(showImplementationWidgetsButton);
await tester.pumpAndSettle(inspectorChangeSettleTime);
}

Future<void> _loadInspectorUI(WidgetTester tester) async {
final screen = InspectorScreen();
await tester.pumpWidget(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2ffc52c

Please sign in to comment.