Skip to content

Initial frame based timeline flame chart. #1336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
91 changes: 91 additions & 0 deletions packages/devtools_app/lib/src/charts/flutter/flame_chart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';

import '../../flutter/common_widgets.dart';
import '../../ui/colors.dart';
import '../../ui/fake_flutter/_real_flutter.dart';

const double rowPadding = 2.0;
const double rowHeight = 25.0;
const double rowHeightWithPadding = rowHeight + rowPadding;
const double sectionSpacing = 15.0;
const double topOffset = rowHeightWithPadding;
const double sideInset = 70.0;

class FlameChartRow {
const FlameChartRow({
@required this.nodes,
@required this.index,
});

final List<FlameChartNode> nodes;
final int index;
}

class FlameChartNode<T> extends StatelessWidget {
const FlameChartNode({
Key key,
@required this.text,
@required this.tooltip,
@required this.rect,
@required this.backgroundColor,
@required this.textColor,
@required this.data,
@required this.selected,
@required this.onSelected,
}) : super(key: key);

FlameChartNode.sectionLabel({
Key key,
@required this.text,
@required this.textColor,
@required this.backgroundColor,
@required double top,
@required double width,
}) : rect = Rect.fromLTRB(rowPadding, top, width, top + rowHeight),
tooltip = '',
data = null,
selected = false,
onSelected = ((_) {});

static const _selectedNodeColor = mainUiColorSelectedLight;

final Rect rect;
final String text;
final String tooltip;
final Color backgroundColor;
final Color textColor;
final T data;
final bool selected;
final void Function(T) onSelected;

@override
Widget build(BuildContext context) {
return Positioned.fromRect(
rect: rect,
child: Tooltip(
message: tooltip,
waitDuration: tooltipWait,
preferBelow: false,
child: InkWell(
onTap: () => onSelected(data),
child: Container(
padding: const EdgeInsets.only(left: 6.0),
alignment: Alignment.centerLeft,
color: selected ? _selectedNodeColor : backgroundColor,
child: Text(
text,
textAlign: TextAlign.left,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: selected ? Colors.black : textColor,
),
),
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions packages/devtools_app/lib/src/flutter/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:flutter_widgets/flutter_widgets.dart';

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

const tooltipWait = Duration(milliseconds: 500);

/// Convenience [Divider] with [Padding] that provides a good divider in forms.
class PaddedDivider extends StatelessWidget {
const PaddedDivider({
Expand Down
Loading