Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,30 @@ class ImportController {
this._pushSnapshotScreenForImport,
);

static const repeatImportTimeBufferMs = 500;

final void Function(String screenId) _pushSnapshotScreenForImport;

final NotificationService _notifications;

bool importing = false;
DateTime previousImportTime;

// TODO(kenz): improve error handling here or in snapshot_screen.dart.
void importData(Map<String, dynamic> json) {
if (importing) return;
importing = true;
// Do not allow two different imports within 500 ms of each other. This is a
// workaround for the fact that we get two drop events for the same file.
final now = DateTime.now();
if (previousImportTime != null &&
(now.millisecondsSinceEpoch - previousImportTime.millisecondsSinceEpoch)
.abs() <
repeatImportTimeBufferMs) {
return;
}
previousImportTime = now;

final isDevToolsSnapshot = json[devToolsSnapshotKey];
if (isDevToolsSnapshot == null || !isDevToolsSnapshot) {
_notifications.push(nonDevToolsFileMessage);
importing = false;
return;
}

Expand All @@ -54,8 +63,6 @@ class ImportController {
offlineDataJson = json;
_notifications.push(attemptingToImportMessage(activeScreenId));
_pushSnapshotScreenForImport(activeScreenId);

importing = false;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/devtools_app/lib/src/flutter/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ Color titleSolidBackgroundColor(ThemeData theme) {
return theme.isDarkTheme ? devtoolsGrey[900] : devtoolsGrey[50];
}

final chartBackgroundColor = ThemedColor(Colors.grey[50], Colors.grey[850]);
// This is the same as Theme.of(context).scaffoldBackgroundColor, but we use
// this in places where we do not have access to the context.
final defaultBackgroundColor = ThemedColor(Colors.grey[50], Colors.grey[850]);
const chartAccentColor = ThemedColor(Color(0xFFCCCCCC), Color(0xFF585858));
const chartTextColor = ThemedColor(Colors.black, Colors.white);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class MemoryChartState extends State<MemoryChart> with AutoDisposeMixin {
..textSize = 2.0;
*/
},
backgroundColor: chartBackgroundColor,
backgroundColor: defaultBackgroundColor,
doubleTapToZoomEnabled: false,
// TODO(terry): For now disable zoom with double-click.
pinchZoomEnabled: false,
Expand Down Expand Up @@ -342,7 +342,7 @@ class MemoryChartState extends State<MemoryChart> with AutoDisposeMixin {
..textSize = 2.0;
*/
},
backgroundColor: chartBackgroundColor,
backgroundColor: defaultBackgroundColor,
// TOD(terry): Disable zoom via double-click. Consider +/- button
// for a controlled zoom in/zoom out.
scaleXEnabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class TimelineGridPainter extends CustomPainter {
constraints.maxWidth,
math.min(constraints.maxHeight, rowHeight),
),
Paint()..color = chartBackgroundColor,
Paint()..color = defaultBackgroundColor,
);

// Paint the timeline grid lines and corresponding timestamps in the flame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class TimelineScreenBodyState extends State<TimelineScreenBody>

// Refresh data on page load if data is null. On subsequent tab changes,
// this should not be called.
if (controller.data == null) {
if (controller.data == null && !offlineMode) {
controller.refreshData();
}

Expand Down Expand Up @@ -181,7 +181,7 @@ class TimelineScreenBodyState extends State<TimelineScreenBody>
timelineScreen,
if (loadingOfflineData)
Container(
color: Colors.grey[50],
color: Theme.of(context).scaffoldBackgroundColor,
child: const Center(
child: CircularProgressIndicator(),
),
Expand Down