-
Notifications
You must be signed in to change notification settings - Fork 390
feat: make kind chip clickable to filter logs by kind #9803
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,10 @@ import '../../shared/primitives/utils.dart'; | |
| import 'logging_controller.dart'; | ||
|
|
||
| class MetadataChips extends StatelessWidget { | ||
| const MetadataChips({super.key, required this.data}); | ||
| const MetadataChips({super.key, required this.data, this.onKindTapped}); | ||
|
|
||
| final LogData data; | ||
| final void Function(String kind)? onKindTapped; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
|
|
@@ -91,6 +92,7 @@ class MetadataChips extends StatelessWidget { | |
| iconAsset: kindIcon.iconAsset, | ||
| backgroundColor: kindColors.background, | ||
| foregroundColor: kindColors.foreground, | ||
| onTap: onKindTapped != null ? () => onKindTapped!(data.kind) : null, | ||
| ), | ||
| logLevelChip, | ||
| if (elapsedFrameTimeAsString != null) | ||
|
|
@@ -115,6 +117,7 @@ abstract class MetadataChip extends StatelessWidget { | |
| this.foregroundColor, | ||
| this.outlined = false, | ||
| this.includeLeadingMargin = true, | ||
| this.onTap, | ||
| }); | ||
|
|
||
| final IconData? icon; | ||
|
|
@@ -125,6 +128,7 @@ abstract class MetadataChip extends StatelessWidget { | |
| final Color? foregroundColor; | ||
| final bool outlined; | ||
| final bool includeLeadingMargin; | ||
| final VoidCallback? onTap; | ||
|
|
||
| static const horizontalPadding = densePadding; | ||
| static const verticalPadding = borderPadding; | ||
|
|
@@ -140,50 +144,69 @@ abstract class MetadataChip extends StatelessWidget { | |
| final foregroundColor = | ||
| this.foregroundColor ?? theme.colorScheme.onSecondaryContainer; | ||
|
|
||
| return maybeWrapWithTooltip( | ||
| tooltip: tooltip, | ||
| child: Container( | ||
| decoration: BoxDecoration( | ||
| color: backgroundColor, | ||
| borderRadius: BorderRadius.circular(_borderRadius), | ||
| border: outlined | ||
| ? Border.all(color: theme.colorScheme.subtleTextColor) | ||
| : null, | ||
| ), | ||
| margin: includeLeadingMargin | ||
| ? const EdgeInsets.only(left: denseSpacing) | ||
| Widget chip = Container( | ||
| decoration: BoxDecoration( | ||
| color: backgroundColor, | ||
| borderRadius: BorderRadius.circular(_borderRadius), | ||
| border: outlined | ||
| ? Border.all(color: theme.colorScheme.subtleTextColor) | ||
| : null, | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: horizontalPadding, | ||
| vertical: verticalPadding, | ||
| ), | ||
| child: Row( | ||
| mainAxisSize: MainAxisSize.min, | ||
| children: [ | ||
| if (icon != null || iconAsset != null) ...[ | ||
| DevToolsIcon( | ||
| icon: icon, | ||
| iconAsset: iconAsset, | ||
| size: _metadataIconSize, | ||
| color: foregroundColor, | ||
| ), | ||
| const SizedBox(width: iconPadding), | ||
| ] else | ||
| // Include an empty SizedBox to ensure a consistent height for the | ||
| // chips, regardless of whether the chip includes an icon. | ||
| const SizedBox(height: _metadataIconSize), | ||
| RichText( | ||
| text: TextSpan( | ||
| text: text, | ||
| style: theme | ||
| .regularTextStyleWithColor(foregroundColor) | ||
| .copyWith(fontSize: smallFontSize), | ||
| ), | ||
| ), | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: horizontalPadding, | ||
| vertical: verticalPadding, | ||
| ), | ||
| child: Row( | ||
| mainAxisSize: MainAxisSize.min, | ||
| children: [ | ||
| if (icon != null || iconAsset != null) ...[ | ||
| DevToolsIcon( | ||
| icon: icon, | ||
| iconAsset: iconAsset, | ||
| size: _metadataIconSize, | ||
| color: foregroundColor, | ||
| ), | ||
| ], | ||
| ), | ||
| const SizedBox(width: iconPadding), | ||
| ] else | ||
| // Include an empty SizedBox to ensure a consistent height for the | ||
| // chips, regardless of whether the chip includes an icon. | ||
| const SizedBox(height: _metadataIconSize), | ||
| RichText( | ||
| text: TextSpan( | ||
| text: text, | ||
| style: theme | ||
| .regularTextStyleWithColor(foregroundColor) | ||
| .copyWith(fontSize: smallFontSize), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ); | ||
|
|
||
| if (onTap != null) { | ||
| chip = Padding( | ||
| padding: includeLeadingMargin | ||
| ? const EdgeInsets.only(left: denseSpacing) | ||
| : EdgeInsets.zero, | ||
| child: MouseRegion( | ||
| cursor: SystemMouseCursors.click, | ||
| child: GestureDetector( | ||
|
Comment on lines
+191
to
+193
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. can we use an Inkwell instead of MouseRegion + GestureDetector?
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. furthermore, it should be possible to use an Inkwell with a null onTap handler that will behave as if the Inkwell were not present in the tree. This should make it possible to revert the changes above to store |
||
| onTap: onTap, | ||
| behavior: HitTestBehavior.opaque, | ||
| child: chip, | ||
| ), | ||
| ), | ||
| ); | ||
| } else { | ||
| chip = Padding( | ||
| padding: includeLeadingMargin | ||
| ? const EdgeInsets.only(left: denseSpacing) | ||
| : EdgeInsets.zero, | ||
| child: chip, | ||
| ); | ||
| } | ||
|
|
||
| return maybeWrapWithTooltip(tooltip: tooltip, child: chip); | ||
|
crackedhandle marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -195,6 +218,7 @@ class KindMetaDataChip extends MetadataChip { | |
| super.iconAsset, | ||
| super.backgroundColor, | ||
| super.foregroundColor, | ||
| super.onTap, | ||
| }) : super(text: kind, includeLeadingMargin: false); | ||
|
|
||
| static ({IconData? icon, String? iconAsset}) generateIcon(String kind) { | ||
|
|
||
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.
define the callback here directly instead of passing it in from the MetadataChips constructor. As is, there is an unnecessary level of abstraction to pass it in from MetadataChips.