-
Notifications
You must be signed in to change notification settings - Fork 388
Add json prettyprinting detail view to the log details page. #1375
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aff9dad
Add json prettyprinting detail view to the log details page.
1145e45
Leave TODOs on monospaced fonts
ec3b6a9
Fix tests
c72d472
Merge branch 'master' of github.com:flutter/devtools into logging-det…
5a78d3c
Manage animations in tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import 'package:flutter_icons/flutter_icons.dart'; | |
|
|
||
| import '../../flutter/controllers.dart'; | ||
| import '../../flutter/screen.dart'; | ||
| import '../../flutter/split.dart'; | ||
| import '../../flutter/table.dart'; | ||
| import '../../table_data.dart'; | ||
| import '../../ui/flutter/service_extension_widgets.dart'; | ||
|
|
@@ -37,6 +38,7 @@ class LoggingScreenBody extends StatefulWidget { | |
|
|
||
| class _LoggingScreenState extends State<LoggingScreenBody> { | ||
| LoggingController controller; | ||
| LogData selected; | ||
|
|
||
| @override | ||
| void didChangeDependencies() { | ||
|
|
@@ -68,13 +70,23 @@ class _LoggingScreenState extends State<LoggingScreenBody> { | |
| ], | ||
| ), | ||
| Expanded( | ||
| child: LogsTable( | ||
| data: controller.data, | ||
| child: Split( | ||
| axis: Split.axisFor(context, 1.0), | ||
| firstChild: LogsTable( | ||
| data: controller.data, | ||
| onItemSelected: _select, | ||
| ), | ||
| secondChild: LogDetails(log: selected), | ||
| initialFirstFraction: 0.6, | ||
| ), | ||
| ), | ||
| ]); | ||
| } | ||
|
|
||
| void _select(LogData log) { | ||
| setState(() => selected = log); | ||
| } | ||
|
|
||
| void _clearLogs() { | ||
| setState(() { | ||
| controller.clear(); | ||
|
|
@@ -83,8 +95,9 @@ class _LoggingScreenState extends State<LoggingScreenBody> { | |
| } | ||
|
|
||
| class LogsTable extends StatelessWidget { | ||
| const LogsTable({Key key, this.data}) : super(key: key); | ||
| const LogsTable({Key key, this.data, this.onItemSelected}) : super(key: key); | ||
| final List<LogData> data; | ||
| final ItemCallback<LogData> onItemSelected; | ||
|
|
||
| List<ColumnData<LogData>> get columns => [ | ||
| _WhenColumn(), | ||
|
|
@@ -98,6 +111,114 @@ class LogsTable extends StatelessWidget { | |
| columns: columns, | ||
| data: data, | ||
| keyFactory: (LogData data) => ValueKey<LogData>(data), | ||
| onItemSelected: onItemSelected, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class LogDetails extends StatefulWidget { | ||
| const LogDetails({Key key, @required this.log}) : super(key: key); | ||
| final LogData log; | ||
|
|
||
| @override | ||
| _LogDetailsState createState() => _LogDetailsState(); | ||
| } | ||
|
|
||
| class _LogDetailsState extends State<LogDetails> | ||
| with SingleTickerProviderStateMixin { | ||
| AnimationController crossFade; | ||
|
|
||
| @override | ||
| void initState() { | ||
| super.initState(); | ||
| crossFade = AnimationController( | ||
| vsync: this, | ||
| duration: const Duration(milliseconds: 200), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should soon do an audit of all durations used and add some top level duration constants used throughout the app. |
||
| )..addStatusListener((status) { | ||
| if (status == AnimationStatus.completed) { | ||
| setState(() { | ||
| _oldLog = widget.log; | ||
| crossFade.value = 0.0; | ||
| }); | ||
| } | ||
| }); | ||
| // We'll use a linear curve for this animation, so no curve needed. | ||
| _computeLogDetails(); | ||
| } | ||
|
|
||
| @override | ||
| void dispose() { | ||
| crossFade.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| @override | ||
| void didUpdateWidget(LogDetails oldWidget) { | ||
| super.didUpdateWidget(oldWidget); | ||
| if (widget.log != oldWidget.log) { | ||
| _oldLog = oldWidget.log; | ||
| crossFade.forward(); | ||
| } | ||
| _computeLogDetails(); | ||
| } | ||
|
|
||
| Future<void> _computeLogDetails() async { | ||
| if (widget.log?.needsComputing ?? false) { | ||
| await widget.log.compute(); | ||
| setState(() {}); | ||
| } | ||
| } | ||
|
|
||
| LogData _oldLog; | ||
|
|
||
| bool showInspector(LogData log) => log != null && log.node != null; | ||
| bool showSimple(LogData log) => | ||
| log != null && log.node == null && !log.needsComputing; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return AnimatedBuilder( | ||
| animation: crossFade, | ||
| builder: (context, _) { | ||
| return Container( | ||
| color: Theme.of(context).cardColor, | ||
| child: Stack(children: [ | ||
| Opacity( | ||
| opacity: crossFade.value, | ||
| child: _buildContent(context, widget.log), | ||
| ), | ||
| Opacity( | ||
| opacity: 1 - crossFade.value, | ||
| child: _buildContent(context, _oldLog), | ||
| ), | ||
| ]), | ||
| ); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| Widget _buildContent(BuildContext context, LogData log) { | ||
| if (log == null) return const SizedBox(); | ||
| if (log.needsComputing) { | ||
| return const Center(child: CircularProgressIndicator()); | ||
| } | ||
| if (showInspector(log)) return _buildInspector(context, log); | ||
| if (showSimple(log)) return _buildSimpleLog(context, log); | ||
| return const SizedBox(); | ||
| } | ||
|
|
||
| // TODO(https://github.com/flutter/devtools/issues/1370): implement this. | ||
| Widget _buildInspector(BuildContext context, LogData log) => const SizedBox(); | ||
|
|
||
| Widget _buildSimpleLog(BuildContext context, LogData log) { | ||
| // TODO(https://github.com/flutter/devtools/issues/1339): Present with monospaced fonts. | ||
| return Scrollbar( | ||
| child: SingleChildScrollView( | ||
| child: Text( | ||
| log.prettyPrinted ?? '', | ||
| style: Theme.of(context).textTheme.subhead, | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -127,5 +248,6 @@ class _MessageColumn extends LogMessageColumn { | |
|
|
||
| /// TODO(djshuckerow): Do better than showing raw HTML here. | ||
| @override | ||
| String getValue(LogData dataObject) => render(dataObject); | ||
| String getValue(LogData dataObject) => | ||
| dataObject.summary ?? dataObject.details; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we not think expandable table children are practical? showing a separate details view in the existing logging page was more for expediency than by design. I'd hope we can do better in Flutter and actually show the details inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is doable, just out of scope for this PR, as discussed offline.