Skip to content

Commit f445668

Browse files
Initial frame based timeline flame chart. (#1336)
* Initial frame based timeline flame chart.
1 parent 2484da0 commit f445668

12 files changed

+588
-43
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright 2019 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
import 'package:flutter/material.dart';
5+
6+
import '../../flutter/common_widgets.dart';
7+
import '../../ui/colors.dart';
8+
import '../../ui/fake_flutter/_real_flutter.dart';
9+
10+
const double rowPadding = 2.0;
11+
const double rowHeight = 25.0;
12+
const double rowHeightWithPadding = rowHeight + rowPadding;
13+
const double sectionSpacing = 15.0;
14+
const double topOffset = rowHeightWithPadding;
15+
const double sideInset = 70.0;
16+
17+
class FlameChartRow {
18+
const FlameChartRow({
19+
@required this.nodes,
20+
@required this.index,
21+
});
22+
23+
final List<FlameChartNode> nodes;
24+
final int index;
25+
}
26+
27+
class FlameChartNode<T> extends StatelessWidget {
28+
const FlameChartNode({
29+
Key key,
30+
@required this.text,
31+
@required this.tooltip,
32+
@required this.rect,
33+
@required this.backgroundColor,
34+
@required this.textColor,
35+
@required this.data,
36+
@required this.selected,
37+
@required this.onSelected,
38+
}) : super(key: key);
39+
40+
FlameChartNode.sectionLabel({
41+
Key key,
42+
@required this.text,
43+
@required this.textColor,
44+
@required this.backgroundColor,
45+
@required double top,
46+
@required double width,
47+
}) : rect = Rect.fromLTRB(rowPadding, top, width, top + rowHeight),
48+
tooltip = '',
49+
data = null,
50+
selected = false,
51+
onSelected = ((_) {});
52+
53+
static const _selectedNodeColor = mainUiColorSelectedLight;
54+
55+
final Rect rect;
56+
final String text;
57+
final String tooltip;
58+
final Color backgroundColor;
59+
final Color textColor;
60+
final T data;
61+
final bool selected;
62+
final void Function(T) onSelected;
63+
64+
@override
65+
Widget build(BuildContext context) {
66+
return Positioned.fromRect(
67+
rect: rect,
68+
child: Tooltip(
69+
message: tooltip,
70+
waitDuration: tooltipWait,
71+
preferBelow: false,
72+
child: InkWell(
73+
onTap: () => onSelected(data),
74+
child: Container(
75+
padding: const EdgeInsets.only(left: 6.0),
76+
alignment: Alignment.centerLeft,
77+
color: selected ? _selectedNodeColor : backgroundColor,
78+
child: Text(
79+
text,
80+
textAlign: TextAlign.left,
81+
overflow: TextOverflow.ellipsis,
82+
style: TextStyle(
83+
color: selected ? Colors.black : textColor,
84+
),
85+
),
86+
),
87+
),
88+
),
89+
);
90+
}
91+
}

packages/devtools_app/lib/src/flutter/common_widgets.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'package:flutter_widgets/flutter_widgets.dart';
77

88
import '../framework/framework_core.dart';
99

10+
const tooltipWait = Duration(milliseconds: 500);
11+
1012
/// Convenience [Divider] with [Padding] that provides a good divider in forms.
1113
class PaddedDivider extends StatelessWidget {
1214
const PaddedDivider({

0 commit comments

Comments
 (0)