Repository navigation
Inspector widget selection improvements (#3489) #3525
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
kenzieschmoll
merged 60 commits into
flutter:master
from
CodemateLtd:widget-selection-search
Jan 4, 2022
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
5009433
Improve widget selection in the inspector (Related ticket: #3489)
msavela 0607595
Removed details tree search (#3489)
alexlindroos 4203f88
Highlight search matches with orange color (#3489)
alexlindroos c5e15bd
Changed the orange color of search highlight (#3489)
alexlindroos 75b3046
Highlight preview only instead of the whole item (flutter#3489)
aednlaxer 8808813
Use different text background colors depending on whether the node is…
aednlaxer f6bf52e
Highlight searchValue in text preview (flutter#3489)
aednlaxer 3b72790
Reformat code (flutter#3489)
aednlaxer a8dd2d9
Use colors from ui/colors.dart for search matches (flutter#3489)
aednlaxer 2ee4c21
Find widget by tooltip instead of text in inspector_screen_test (flut…
aednlaxer ee4f81a
Add breadcrumbs widget and show it in the Widget detail tree (#3489)
aednlaxer b752bca
Merge pull request #26 from CodemateLtd/widget-search-alex
msavela 580ea85
Fix inspector_integration_test.dart (flutter#3489)
aednlaxer ec063b1
Update goldens (flutter#3489)
aednlaxer 17e117d
Remove unnecessary import (flutter#3489)
aednlaxer 3b79477
Revert goldens update (flutter#3489)
aednlaxer 87c6fae
Put FakeServiceManager to the global storage before running tests in …
aednlaxer 8df337a
Mock searchInProgressNotifier (flutter#3489)
aednlaxer cc61b2d
Update goldens (flutter#3489)
aednlaxer ff60690
Fix several nits (flutter#3489)
aednlaxer 7719e8f
Use regular text style when searchValue is null, empty or there's no …
aednlaxer 9ca2161
Add extra null checks to isChevron and isEllipsis (flutter#3489)
aednlaxer 7207269
Use Container's alignment instead of Align (flutter#3489)
aednlaxer 774a89d
Remove SizedBox (flutter#3489)
aednlaxer 6903577
Add constant for the max number of breadcrumbs (flutter#3489)
aednlaxer ae76768
Move search controls to InspectorSummaryTreeControls (flutter#3489)
aednlaxer 1e3f6c9
Add TODO comment regarding other values of SearchTargetType (flutter#…
aednlaxer 162dce7
Add named constructor to PaddedDivider for setting symmetric vertical…
aednlaxer b14178f
Add SmallCircularProgressIndicator and reuse it (flutter#3489)
aednlaxer 4ac247f
Use constants (flutter#3489)
aednlaxer c65d079
Prefix debug variables (flutter#3489)
aednlaxer 247d509
Cache selected inspector tree row (flutter#3489)
aednlaxer 9d43a70
Simplify the way search works in inspector_tree_controller.dart (flut…
aednlaxer 0951e4f
Rename searchPreventCloseOnBlur to searchPreventClose (flutter#3489)
aednlaxer fc71a46
Remove irrelevant comments (flutter#3489)
aednlaxer b1063f7
Change max number of breadcrumbs and the way displayed items are calc…
aednlaxer 243cfa8
Change isChevron and isEllipsis checks (flutter#3489)
aednlaxer 6987e58
Doc: wrap variables in brackets (flutter#3489)
aednlaxer 4d08128
Simplify horizontal padding (flutter#3489)
aednlaxer 0c6e704
Add tests for caseInsensitiveEquals and caseInsensitiveAllMatches (fl…
aednlaxer fbdbb5a
Merge branch 'master' into widget-selection-search
aednlaxer ea299df
Pull out search debounce to SearchControllerMixin (flutter#3489)
aednlaxer 1c0b711
Use refreshSearchMatches instead of matchesForSearch (flutter#3489)
aednlaxer d72570a
Search previous matches in widget search when asked to (flutter#3489)
aednlaxer 337bab1
Perform a global search when search inside previous matches fails (fl…
aednlaxer 2c42d9f
Fix nits (flutter#3489)
aednlaxer 5374d37
Remove setSearchMatch function (flutter#3489)
aednlaxer 6ab7258
Expand every node of the tree before search (flutter#3489)
aednlaxer a9ac6b6
Add a list of all cached tree rows for search (flutter#3489)
aednlaxer 6347a52
Use tree nodes instead of rows in InspectorBreadcrumbNavigator. Simpl…
aednlaxer eafc8bf
Fix nits (flutter#3489)
aednlaxer 20b2d60
Merge branch 'master' into widget-selection-search
aednlaxer 74a32a3
Optimize usage of variables (flutter#3489)
aednlaxer 7af5098
Update goldens (flutter#3489)
aednlaxer 72c9b5e
Merge branch 'master' into widget-selection-search
aednlaxer 1937d24
Update matchIndex when activeMatchIndex is greater than number of ite…
aednlaxer 90922d0
Set searchInProgress to false before calling _updateMatches (flutter#…
aednlaxer 1506ea9
Update memory_* goldens (flutter#3489)
aednlaxer 001cdd4
Update memory_* goldens (flutter#3489)
aednlaxer 035082f
Update memory_* goldens (flutter#3489)
aednlaxer 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 |
|---|---|---|
|
|
@@ -35,18 +35,22 @@ class DiagnosticsNodeDescription extends StatelessWidget { | |
| const DiagnosticsNodeDescription( | ||
|
Member
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. cc @matt-ragonese in case you are using this file for your custom screen |
||
| this.diagnostic, { | ||
| this.isSelected, | ||
| this.searchValue, | ||
| this.errorText, | ||
| this.multiline = false, | ||
| this.style, | ||
| @required this.debuggerController, | ||
| this.nodeDescriptionHighlightStyle, | ||
| }); | ||
|
|
||
| final RemoteDiagnosticsNode diagnostic; | ||
| final bool isSelected; | ||
| final String errorText; | ||
| final String searchValue; | ||
| final bool multiline; | ||
| final TextStyle style; | ||
| final DebuggerController debuggerController; | ||
| final TextStyle nodeDescriptionHighlightStyle; | ||
|
|
||
| Widget _paddedIcon(Widget icon) { | ||
| return Padding( | ||
|
|
@@ -90,8 +94,18 @@ class DiagnosticsNodeDescription extends StatelessWidget { | |
| if (textPreview is String) { | ||
| final preview = textPreview.replaceAll('\n', ' '); | ||
| yield TextSpan( | ||
| text: ': "$preview"', | ||
| style: textStyle.merge(inspector_text_styles.unimportant(colorScheme)), | ||
| children: [ | ||
| TextSpan( | ||
| text: ': ', | ||
| style: textStyle, | ||
| ), | ||
| _buildHighlightedSearchPreview( | ||
| preview, | ||
| searchValue, | ||
| textStyle, | ||
| textStyle.merge(nodeDescriptionHighlightStyle), | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -350,4 +364,60 @@ class DiagnosticsNodeDescription extends StatelessWidget { | |
| ), | ||
| ); | ||
| } | ||
|
|
||
| TextSpan _buildHighlightedSearchPreview( | ||
| String textPreview, | ||
| String searchValue, | ||
| TextStyle textStyle, | ||
| TextStyle highlightTextStyle, | ||
| ) { | ||
| if (searchValue == null || searchValue.isEmpty) { | ||
| return TextSpan( | ||
| text: '"$textPreview"', | ||
| style: textStyle, | ||
| ); | ||
| } | ||
|
|
||
| if (textPreview.caseInsensitiveEquals(searchValue)) { | ||
| return TextSpan( | ||
| text: '"$textPreview"', | ||
| style: highlightTextStyle, | ||
|
aednlaxer marked this conversation as resolved.
Resolved
|
||
| ); | ||
| } | ||
|
|
||
| final matches = searchValue.caseInsensitiveAllMatches(textPreview); | ||
| if (matches.isEmpty) { | ||
| return TextSpan( | ||
| text: '"$textPreview"', | ||
| style: textStyle, | ||
| ); | ||
| } | ||
|
|
||
| final quoteSpan = TextSpan(text: '"', style: textStyle); | ||
| final spans = <TextSpan>[quoteSpan]; | ||
| var previousItemEnd = 0; | ||
| for (final match in matches) { | ||
| if (match.start > previousItemEnd) { | ||
| spans.add(TextSpan( | ||
| text: textPreview.substring(previousItemEnd, match.start), | ||
| style: textStyle, | ||
| )); | ||
| } | ||
|
|
||
| spans.add(TextSpan( | ||
| text: textPreview.substring(match.start, match.end), | ||
| style: highlightTextStyle, | ||
| )); | ||
|
|
||
| previousItemEnd = match.end; | ||
| } | ||
|
|
||
| spans.add(TextSpan( | ||
| text: textPreview.substring(previousItemEnd, textPreview.length), | ||
| style: textStyle, | ||
| )); | ||
| spans.add(quoteSpan); | ||
|
|
||
| return TextSpan(children: spans); | ||
| } | ||
| } | ||
210 changes: 210 additions & 0 deletions
210
packages/devtools_app/lib/src/inspector/inspector_breadcrumbs.dart
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 |
|---|---|---|
| @@ -0,0 +1,210 @@ | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../theme.dart'; | ||
| import '../utils.dart'; | ||
| import 'inspector_text_styles.dart'; | ||
| import 'inspector_tree.dart'; | ||
|
|
||
| class InspectorBreadcrumbNavigator extends StatelessWidget { | ||
| const InspectorBreadcrumbNavigator({ | ||
| Key key, | ||
| @required this.items, | ||
| @required this.onTap, | ||
| }) : super(key: key); | ||
|
|
||
| /// Max number of visible breadcrumbs including root item but not 'more' item. | ||
| /// E.g. value 5 means root and 4 breadcrumbs can be displayed, other | ||
| /// breadcrumbs (if any) will be replaced by '...' item. | ||
| static const _maxNumberOfBreadcrumbs = 5; | ||
|
|
||
| final List<InspectorTreeNode> items; | ||
| final Function(InspectorTreeNode) onTap; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| if (items.isEmpty) { | ||
| return const SizedBox(); | ||
| } | ||
|
|
||
| final breadcrumbs = _generateBreadcrumbs(items); | ||
| return SizedBox( | ||
| height: isDense() ? 24 : 28, | ||
| child: Padding( | ||
| padding: const EdgeInsets.symmetric(horizontal: 6), | ||
| child: Row( | ||
| children: breadcrumbs.map((item) { | ||
| if (item.isChevron) { | ||
| return Icon( | ||
| Icons.chevron_right, | ||
| size: defaultIconSize, | ||
| ); | ||
| } | ||
|
|
||
| return Flexible( | ||
| child: _InspectorBreadcrumb( | ||
| data: item, | ||
| onTap: () => onTap(item.node), | ||
| ), | ||
| ); | ||
| }).toList(), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| List<_InspectorBreadcrumbData> _generateBreadcrumbs( | ||
| List<InspectorTreeNode> nodes, | ||
| ) { | ||
| final lastNode = nodes.safeLast; | ||
| final List<_InspectorBreadcrumbData> items = nodes.map((node) { | ||
| return _InspectorBreadcrumbData.wrap( | ||
| node: node, | ||
| isSelected: node == lastNode, | ||
| ); | ||
| }).toList(); | ||
| List<_InspectorBreadcrumbData> breadcrumbs; | ||
| if (items.length > _maxNumberOfBreadcrumbs) { | ||
| breadcrumbs = [ | ||
| items[0], | ||
| _InspectorBreadcrumbData.more(), | ||
| ...items.sublist( | ||
| items.length - _maxNumberOfBreadcrumbs + 1, | ||
| items.length, | ||
| ), | ||
| ]; | ||
| } else { | ||
| breadcrumbs = items; | ||
| } | ||
|
|
||
| return breadcrumbs.joinWith(_InspectorBreadcrumbData.chevron()); | ||
| } | ||
| } | ||
|
|
||
| class _InspectorBreadcrumb extends StatelessWidget { | ||
| const _InspectorBreadcrumb({ | ||
| Key key, | ||
| @required this.data, | ||
| @required this.onTap, | ||
| }) : assert(data != null), | ||
| super(key: key); | ||
|
|
||
| static const BorderRadius _borderRadius = | ||
| BorderRadius.all(Radius.circular(defaultBorderRadius)); | ||
|
|
||
| static const _iconScale = .75; | ||
|
|
||
| final _InspectorBreadcrumbData data; | ||
| final VoidCallback onTap; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final text = Text( | ||
| data.text, | ||
| maxLines: 1, | ||
| overflow: TextOverflow.ellipsis, | ||
| style: regular.copyWith(fontSize: scaleByFontFactor(11)), | ||
| ); | ||
|
|
||
| final icon = data.icon == null | ||
| ? null | ||
| : Transform.scale( | ||
| scale: _iconScale, | ||
| child: Padding( | ||
| padding: const EdgeInsets.only(right: iconPadding), | ||
| child: data.icon, | ||
| ), | ||
| ); | ||
|
|
||
| return InkWell( | ||
| onTap: data.isClickable ? onTap : null, | ||
| borderRadius: _borderRadius, | ||
| child: Container( | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: densePadding, | ||
| vertical: borderPadding, | ||
| ), | ||
| decoration: BoxDecoration( | ||
| borderRadius: _borderRadius, | ||
| color: data.isSelected | ||
| ? Theme.of(context).colorScheme.selectedRowBackgroundColor | ||
| : Colors.transparent, | ||
| ), | ||
| child: Row( | ||
| mainAxisSize: MainAxisSize.min, | ||
| children: [ | ||
| if (icon != null) icon, | ||
| Flexible(child: text), | ||
|
Member
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. use Expanded instead |
||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _InspectorBreadcrumbData { | ||
| const _InspectorBreadcrumbData._({ | ||
| @required this.node, | ||
| @required this.isSelected, | ||
| @required this.alternativeText, | ||
| @required this.alternativeIcon, | ||
| }); | ||
|
|
||
| factory _InspectorBreadcrumbData.wrap({ | ||
| @required InspectorTreeNode node, | ||
| @required bool isSelected, | ||
| }) { | ||
| return _InspectorBreadcrumbData._( | ||
| node: node, | ||
| isSelected: isSelected, | ||
| alternativeText: null, | ||
| alternativeIcon: null, | ||
| ); | ||
| } | ||
|
|
||
| /// Construct a special item for showing '…' symbol between other items | ||
| factory _InspectorBreadcrumbData.more() { | ||
| return const _InspectorBreadcrumbData._( | ||
| node: null, | ||
| isSelected: false, | ||
| alternativeText: _ellipsisValue, | ||
| alternativeIcon: null, | ||
| ); | ||
| } | ||
|
|
||
| factory _InspectorBreadcrumbData.chevron() { | ||
| return const _InspectorBreadcrumbData._( | ||
| node: null, | ||
| isSelected: false, | ||
| alternativeText: null, | ||
| alternativeIcon: _breadcrumbSeparatorIcon, | ||
| ); | ||
| } | ||
|
|
||
| static const _ellipsisValue = '…'; | ||
| static const _breadcrumbSeparatorIcon = Icons.chevron_right; | ||
|
|
||
| final InspectorTreeNode node; | ||
| final IconData alternativeIcon; | ||
| final String alternativeText; | ||
| final bool isSelected; | ||
|
|
||
| String get text => alternativeText ?? node?.diagnostic?.description; | ||
|
|
||
| Widget get icon { | ||
| if (alternativeIcon != null) { | ||
| return Icon( | ||
| _breadcrumbSeparatorIcon, | ||
| size: defaultIconSize, | ||
| ); | ||
| } | ||
|
|
||
| return node?.diagnostic?.icon; | ||
| } | ||
|
|
||
| bool get isChevron => | ||
|
aednlaxer marked this conversation as resolved.
Resolved
|
||
| node == null && alternativeIcon == _breadcrumbSeparatorIcon; | ||
|
|
||
| bool get isEllipsis => node == null && alternativeText == _ellipsisValue; | ||
|
|
||
| bool get isClickable => !isSelected && !isEllipsis; | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.