Skip to content

Commit 20fd04b

Browse files
authored
New widget icons and alignment added (#3195) (#3215)
1 parent 501889e commit 20fd04b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+425
-82
lines changed
869 Bytes
835 Bytes
848 Bytes
649 Bytes
Binary file not shown.
Binary file not shown.
-786 Bytes
642 Bytes
Binary file not shown.

packages/devtools_app/lib/src/inspector/inspector_tree.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ typedef TreeEventCallback = void Function(InspectorTreeNode node);
3636
// TODO(jacobr): merge this scheme with other color schemes in DevTools.
3737
extension InspectorColorScheme on ColorScheme {
3838
Color get selectedRowBackgroundColor => isLight
39-
? const Color.fromARGB(255, 202, 191, 69)
40-
: const Color.fromARGB(255, 99, 101, 103);
39+
? const Color.fromARGB(255, 220, 220, 220)
40+
: const Color.fromARGB(255, 73, 73, 73);
4141
Color get hoverColor =>
4242
isLight ? Colors.yellowAccent : const Color.fromARGB(255, 70, 73, 76);
4343
}
4444

45-
const double iconPadding = 5.0;
45+
const double iconPadding = 4.0;
4646
const double chartLineStrokeWidth = 1.0;
4747
double get columnWidth => isDense() ? 12 : 16.0;
4848
double get verticalPadding => scaleByFontFactor(10.0);

packages/devtools_app/lib/src/inspector/inspector_tree_flutter.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ class InspectorRowContent extends StatelessWidget {
669669
},
670670
child: Container(
671671
height: rowHeight,
672-
padding: const EdgeInsets.symmetric(horizontal: 4.0),
673672
child: DiagnosticsNodeDescription(
674673
node.diagnostic,
675674
isSelected: row.isSelected,

packages/devtools_app/lib/src/inspector/layout_explorer/box/box.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import '../ui/layout_explorer_widget.dart';
2020
import '../ui/theme.dart';
2121
import '../ui/utils.dart';
2222
import '../ui/widget_constraints.dart';
23+
import '../ui/widgets_theme.dart';
2324

2425
class BoxLayoutExplorerWidget extends LayoutExplorerWidget {
2526
const BoxLayoutExplorerWidget(
@@ -215,7 +216,7 @@ class _BoxLayoutExplorerWidgetState extends LayoutExplorerWidgetState<
215216
height: constraints.maxHeight,
216217
decoration: BoxDecoration(
217218
border: Border.all(
218-
color: regularWidgetColor,
219+
color: WidgetTheme.fromName(properties.node.description).color,
219220
),
220221
),
221222
child: Stack(

packages/devtools_app/lib/src/inspector/layout_explorer/flex/flex.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,17 +453,29 @@ class _VisualizeFlexChildrenState extends State<VisualizeFlexChildren> {
453453
);
454454

455455
final childrenRenderWidgets = <Widget>[];
456+
Widget selectedWidget;
456457
for (var i = 0; i < widget.children.length; i++) {
457458
final child = widget.children[i];
458459
final isSelected = widget.highlighted == child;
459460

460-
childrenRenderWidgets.add(FlexChildVisualizer(
461+
final visualizer = FlexChildVisualizer(
461462
key: isSelected ? selectedChildKey : null,
462463
state: widget.state,
463464
layoutProperties: child,
464465
isSelected: isSelected,
465466
renderProperties: renderProperties[i],
466-
));
467+
);
468+
469+
if (isSelected) {
470+
selectedWidget = visualizer;
471+
} else {
472+
childrenRenderWidgets.add(visualizer);
473+
}
474+
}
475+
476+
// Selected widget needs to be last to draw its border over other children
477+
if (selectedWidget != null) {
478+
childrenRenderWidgets.add(selectedWidget);
467479
}
468480

469481
final freeSpacesWidgets = [
@@ -679,7 +691,7 @@ class FlexChildVisualizer extends StatelessWidget {
679691
return Positioned(
680692
top: renderOffset.dy,
681693
left: renderOffset.dx,
682-
child: InkWell(
694+
child: GestureDetector(
683695
onTap: () => state.onTap(properties),
684696
onDoubleTap: () => state.onDoubleTap(properties),
685697
onLongPress: () => state.onDoubleTap(properties),

packages/devtools_app/lib/src/inspector/layout_explorer/ui/utils.dart

Lines changed: 83 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import '../../diagnostics_node.dart';
1313
import '../../inspector_data_models.dart';
1414
import 'overflow_indicator_painter.dart';
1515
import 'theme.dart';
16+
import 'widgets_theme.dart';
1617

1718
/// A widget for positioning sized widgets that follows layout as follows:
1819
/// | top |
@@ -142,7 +143,10 @@ class WidgetVisualizer extends StatelessWidget {
142143

143144
final OverflowSide overflowSide;
144145

145-
static const overflowIndicatorSize = 20.0;
146+
static const _overflowIndicatorSize = 20.0;
147+
static const _borderUnselectedWidth = 1.0;
148+
static const _borderSelectedWidth = 3.0;
149+
static const _selectedPadding = 4.0;
146150

147151
bool get drawOverflow => overflowSide != null;
148152

@@ -151,80 +155,96 @@ class WidgetVisualizer extends StatelessWidget {
151155
final theme = Theme.of(context);
152156
final colorScheme = theme.colorScheme;
153157
final properties = layoutProperties;
154-
Color borderColor = regularWidgetColor;
155-
if (properties is FlexLayoutProperties) {
156-
borderColor =
157-
properties?.direction == Axis.horizontal ? rowColor : columnColor;
158-
}
159-
if (isSelected) {
160-
borderColor = selectedWidgetColor;
161-
}
162-
return Container(
163-
child: Stack(
164-
children: [
165-
if (drawOverflow)
166-
Positioned.fill(
167-
child: CustomPaint(
168-
painter: OverflowIndicatorPainter(
169-
overflowSide,
170-
overflowIndicatorSize,
171-
),
172-
),
173-
),
174-
Container(
175-
margin: EdgeInsets.only(
176-
right: overflowSide == OverflowSide.right
177-
? overflowIndicatorSize
178-
: 0.0,
179-
bottom: overflowSide == OverflowSide.bottom
180-
? overflowIndicatorSize
181-
: 0.0,
182-
),
183-
color: isSelected ? colorScheme.backgroundColorSelected : null,
184-
child: Column(
185-
crossAxisAlignment: CrossAxisAlignment.stretch,
186-
mainAxisSize: MainAxisSize.min,
158+
final borderColor = WidgetTheme.fromName(properties.node.description).color;
159+
final boxAdjust = isSelected ? _selectedPadding : 0.0;
160+
161+
return LayoutBuilder(
162+
builder: (context, constraints) {
163+
return OverflowBox(
164+
minWidth: constraints.minWidth + boxAdjust,
165+
maxWidth: constraints.maxWidth + boxAdjust,
166+
maxHeight: constraints.maxHeight + boxAdjust,
167+
minHeight: constraints.minHeight + boxAdjust,
168+
child: Container(
169+
child: Stack(
187170
children: [
188-
IntrinsicHeight(
189-
child: Row(
171+
if (drawOverflow)
172+
Positioned.fill(
173+
child: CustomPaint(
174+
painter: OverflowIndicatorPainter(
175+
overflowSide,
176+
_overflowIndicatorSize,
177+
),
178+
),
179+
),
180+
Container(
181+
margin: EdgeInsets.only(
182+
right: overflowSide == OverflowSide.right
183+
? _overflowIndicatorSize
184+
: 0.0,
185+
bottom: overflowSide == OverflowSide.bottom
186+
? _overflowIndicatorSize
187+
: 0.0,
188+
),
189+
child: Column(
190190
crossAxisAlignment: CrossAxisAlignment.stretch,
191-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
191+
mainAxisSize: MainAxisSize.min,
192192
children: [
193-
Flexible(
194-
child: Container(
195-
constraints: BoxConstraints(
196-
maxWidth: largeTitle
197-
? defaultMaxRenderWidth
198-
: minRenderWidth *
199-
widgetTitleMaxWidthPercentage),
200-
child: Center(
201-
child: Text(
202-
title,
203-
style:
204-
TextStyle(color: colorScheme.widgetNameColor),
205-
overflow: TextOverflow.ellipsis,
193+
IntrinsicHeight(
194+
child: Row(
195+
crossAxisAlignment: CrossAxisAlignment.stretch,
196+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
197+
children: [
198+
Flexible(
199+
child: Container(
200+
constraints: BoxConstraints(
201+
maxWidth: largeTitle
202+
? defaultMaxRenderWidth
203+
: minRenderWidth *
204+
widgetTitleMaxWidthPercentage),
205+
child: Center(
206+
child: Text(
207+
title,
208+
style: TextStyle(
209+
color: colorScheme.widgetNameColor),
210+
overflow: TextOverflow.ellipsis,
211+
),
212+
),
213+
decoration: BoxDecoration(color: borderColor),
214+
padding: const EdgeInsets.all(4.0),
215+
),
206216
),
207-
),
208-
decoration: BoxDecoration(color: borderColor),
209-
padding: const EdgeInsets.all(4.0),
217+
if (hint != null) Flexible(child: hint),
218+
],
210219
),
211220
),
212-
if (hint != null) Flexible(child: hint),
221+
if (child != null) Expanded(child: child),
213222
],
214223
),
215224
),
216-
if (child != null) Expanded(child: child),
217225
],
218226
),
227+
decoration: BoxDecoration(
228+
border: Border.all(
229+
color: borderColor,
230+
width:
231+
isSelected ? _borderSelectedWidth : _borderUnselectedWidth,
232+
),
233+
color: isSelected
234+
? theme.canvasColor.brighten()
235+
: theme.canvasColor.darken(),
236+
boxShadow: isSelected
237+
? [
238+
BoxShadow(
239+
color: Colors.black.withOpacity(.5),
240+
blurRadius: 20,
241+
),
242+
]
243+
: null,
244+
),
219245
),
220-
],
221-
),
222-
decoration: BoxDecoration(
223-
border: Border.all(
224-
color: borderColor,
225-
),
226-
color: theme.canvasColor.darken(),
227-
),
246+
);
247+
},
228248
);
229249
}
230250
}

0 commit comments

Comments
 (0)