-
Notifications
You must be signed in to change notification settings - Fork 362
[Property Editor] Better messages when panel is empty #9076
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
8 commits
Select commit
Hold shift + click to select a range
77cce4a
Property Editor empty state messages
elliette a2d7ffd
grammar
elliette a1fabfe
Add tests
elliette 0284577
Merge branch 'master' into issue-9068
elliette 14608ee
Update test
elliette d30b715
Handle highlighting for dark theme
elliette 84cf978
Make selectable
elliette b69c939
Respond to PR comments
elliette 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
165 changes: 165 additions & 0 deletions
165
...vtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_messages.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,165 @@ | ||
| // Copyright 2025 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. | ||
|
|
||
| import 'package:devtools_app_shared/ui.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| import '../../../shared/ui/colors.dart'; | ||
|
|
||
| class HowToUseMessage extends StatelessWidget { | ||
| const HowToUseMessage({super.key}); | ||
|
|
||
| static const _lightHighlighterColor = Colors.yellow; | ||
| static const _darkHighlighterColor = Color.fromARGB(168, 191, 17, 196); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final theme = Theme.of(context); | ||
| final colorScheme = theme.colorScheme; | ||
| final fixedFontStyle = theme.fixedFontStyle; | ||
| TextSpan colorA(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.declarationsSyntaxColor, | ||
| ); | ||
| TextSpan colorB(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.modifierSyntaxColor, | ||
| ); | ||
| TextSpan colorC(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.variableSyntaxColor, | ||
| ); | ||
| TextSpan colorD(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.controlFlowSyntaxColor, | ||
| ); | ||
| TextSpan colorE(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.stringSyntaxColor, | ||
| ); | ||
| TextSpan colorF(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.functionSyntaxColor, | ||
| ); | ||
| TextSpan colorG(String text) => _coloredSpan( | ||
| text, | ||
| style: fixedFontStyle, | ||
| color: colorScheme.numericConstantSyntaxColor, | ||
| ); | ||
| TextSpan highlight(TextSpan original) => _highlight( | ||
| original, | ||
| highlighterColor: | ||
| theme.isDarkTheme ? _darkHighlighterColor : _lightHighlighterColor, | ||
| ); | ||
|
|
||
| return Text.rich( | ||
| TextSpan( | ||
| children: [ | ||
| const TextSpan(text: '\nPlease move your cursor anywhere inside a '), | ||
| TextSpan( | ||
| text: 'Flutter widget constructor invocation', | ||
| style: theme.boldTextStyle, | ||
| ), | ||
| const TextSpan(text: ' to view and edit its properties.\n\n'), | ||
| const TextSpan( | ||
| text: | ||
| 'For example, the highlighted code below is a constructor invocation of a ', | ||
| ), | ||
| TextSpan( | ||
| text: 'Text', | ||
| style: Theme.of( | ||
| context, | ||
| ).fixedFontStyle.copyWith(color: colorScheme.primary), | ||
| ), | ||
| const TextSpan(text: ' widget:\n\n'), | ||
| colorA('@override\n'), | ||
| colorB('Widget '), | ||
| colorG('build'), | ||
| colorC('('), | ||
| colorB('BuildContext '), | ||
| colorA('context'), | ||
| colorC(') '), | ||
| colorC('{\n'), | ||
| colorD(' return '), | ||
| highlight(colorB('Text')), | ||
| highlight(colorC('(\n')), | ||
| highlight(colorE(' "Hello World!"')), | ||
| highlight(colorF(',\n')), | ||
| highlight(colorA(' overflow')), | ||
| highlight(colorF(': ')), | ||
| highlight(colorB('TextOveflow')), | ||
| highlight(colorF('.')), | ||
| highlight(colorG('clip')), | ||
| highlight(colorF(',\n')), | ||
| highlight(colorC(' )')), | ||
| highlight(colorF(';\n')), | ||
| colorC('}'), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| TextSpan _coloredSpan( | ||
| String text, { | ||
| required TextStyle style, | ||
| required Color color, | ||
| }) => TextSpan(text: text, style: style.copyWith(color: color)); | ||
|
|
||
| TextSpan _highlight(TextSpan original, {required Color highlighterColor}) => | ||
| TextSpan( | ||
| text: original.text, | ||
| style: original.style!.copyWith(backgroundColor: highlighterColor), | ||
| ); | ||
| } | ||
|
|
||
| class NoDartCodeMessage extends StatelessWidget { | ||
| const NoDartCodeMessage({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Text( | ||
| 'No Dart code found at the current cursor location.', | ||
| style: Theme.of(context).textTheme.bodyLarge, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class NoMatchingPropertiesMessage extends StatelessWidget { | ||
| const NoMatchingPropertiesMessage({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const Text('No properties matching the current filter.'); | ||
| } | ||
| } | ||
|
|
||
| class NoWidgetAtLocationMessage extends StatelessWidget { | ||
| const NoWidgetAtLocationMessage({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Text( | ||
| 'No Flutter widget found at the current cursor location.', | ||
| style: Theme.of(context).textTheme.bodyLarge, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class WelcomeMessage extends StatelessWidget { | ||
| const WelcomeMessage({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Text( | ||
| '👋 Welcome to the Flutter Property Editor!', | ||
| style: Theme.of(context).textTheme.bodyLarge, | ||
| ); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.