Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class _LegendButton extends StatelessWidget {
},
icon: legendVisible ? Icons.close : Icons.storage,
label: 'Legend',
tooltip: 'Show chart legend',
tooltip: 'Toggle visibility of the chart legend',
minScreenWidthForTextBeforeScaling: memoryControlsMinVerboseWidth,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ class PrimaryControls extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ChartVisibilityButton(
showChart: preferences.memory.showChart,
return VisibilityButton(
show: preferences.memory.showChart,
onPressed: (show) => preferences.memory.showChart.value = show,
minScreenWidthForTextBeforeScaling: memoryControlsMinVerboseWidth,
label: 'Memory chart',
tooltip: 'Toggle visibility of the Memory usage chart',
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ class _PrimaryControls extends StatelessWidget {
return Row(
children: [
if (serviceManager.connectedApp!.isFlutterAppNow!) ...[
ChartVisibilityButton(
showChart:
controller.flutterFramesController.showFlutterFramesChart,
VisibilityButton(
show: controller.flutterFramesController.showFlutterFramesChart,
onPressed:
controller.flutterFramesController.toggleShowFlutterFrames,
label: 'Flutter frames',
tooltip: 'Toggle visibility of the Flutter frames',
),
const SizedBox(width: denseSpacing),
],
Expand Down
17 changes: 10 additions & 7 deletions packages/devtools_app/lib/src/shared/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -511,30 +511,33 @@ class CollapseAllButton extends StatelessWidget {
///
/// The button automatically toggles the icon and the tooltip to indicate the
/// shown or hidden state.
class ChartVisibilityButton extends StatelessWidget {
const ChartVisibilityButton({
required this.showChart,
class VisibilityButton extends StatelessWidget {
const VisibilityButton({
required this.show,
required this.onPressed,
this.minScreenWidthForTextBeforeScaling,
this.label = 'Chart',
required this.label,
required this.tooltip,
});

final ValueListenable<bool> showChart;
final ValueListenable<bool> show;

final void Function(bool) onPressed;

final double? minScreenWidthForTextBeforeScaling;

final String label;

final String tooltip;

@override
Widget build(BuildContext context) {
return ValueListenableBuilder<bool>(
valueListenable: showChart,
valueListenable: show,
builder: (_, show, __) {
return IconLabelButton(
key: key,
tooltip: show ? 'Hide chart' : 'Show chart',
tooltip: tooltip,
icon: show ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
label: label,
minScreenWidthForTextBeforeScaling:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void main() {
find.text('Select a frame above to view analysis data.'),
findsOneWidget,
);
expect(find.byType(ChartVisibilityButton), findsOneWidget);
expect(find.byType(VisibilityButton), findsOneWidget);
expect(find.byIcon(Icons.block), findsOneWidget);
expect(find.text('Performance Overlay'), findsOneWidget);
expect(find.text('Enhance Tracing'), findsOneWidget);
Expand Down Expand Up @@ -133,7 +133,7 @@ void main() {
findsNothing,
);
expect(find.byType(EventDetails), findsOneWidget);
expect(find.byType(ChartVisibilityButton), findsNothing);
expect(find.byType(VisibilityButton), findsNothing);
expect(find.byIcon(Icons.block), findsOneWidget);
expect(find.text('Performance Overlay'), findsNothing);
expect(find.text('Enhance Tracing'), findsNothing);
Expand All @@ -157,7 +157,7 @@ void main() {
await pumpPerformanceScreen(tester, runAsync: true);
await tester.pumpAndSettle();

final chartButtonFinder = find.byType(ChartVisibilityButton);
final chartButtonFinder = find.byType(VisibilityButton);
expect(chartButtonFinder, findsOneWidget);

// The flutter frames chart is visible.
Expand Down