Skip to content

Commit c3a03dc

Browse files
committed
Add type info and have all inputs used fixed font
1 parent e90c6ac commit c3a03dc

File tree

2 files changed

+60
-9
lines changed

2 files changed

+60
-9
lines changed

packages/devtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_view.dart

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,15 @@ class _PropertyInputState extends State<_PropertyInput> {
148148

149149
@override
150150
Widget build(BuildContext context) {
151+
// TODO(elliette): Refactor to split each argument type into its own input
152+
// widget class for readability.
153+
final theme = Theme.of(context);
151154
final argument = widget.argument;
152155
final decoration = InputDecoration(
153156
helperText: argument.isRequired ? '*required' : '',
154157
errorText: argument.errorText,
155158
isDense: true,
156-
label: Text('${argument.name}${argument.isRequired ? '*' : ''}'),
159+
label: _inputLabel(argument, theme: theme),
157160
border: const OutlineInputBorder(),
158161
);
159162
final argType = widget.argument.type;
@@ -179,7 +182,7 @@ class _PropertyInputState extends State<_PropertyInput> {
179182
value: option,
180183
// TODO(https://github.com/flutter/devtools/issues/8531) Handle onTap.
181184
onTap: () {},
182-
child: Text(option),
185+
child: Text(option, style: theme.fixedFontStyle),
183186
);
184187
}).toList(),
185188
onChanged: (newValue) async {
@@ -214,6 +217,54 @@ class _PropertyInputState extends State<_PropertyInput> {
214217
}
215218
}
216219

220+
Widget _inputLabel(EditableArgument argument, {required ThemeData theme}) {
221+
final type = _typeForLabel(argument);
222+
return RichText(
223+
overflow: TextOverflow.ellipsis,
224+
text: TextSpan(
225+
text: type != null ? '$type ' : ':',
226+
style: theme.fixedFontStyle,
227+
children: [
228+
TextSpan(
229+
text: argument.name,
230+
style: theme.fixedFontStyle.copyWith(
231+
fontWeight: FontWeight.bold,
232+
color: theme.colorScheme.primary,
233+
),
234+
children: [
235+
TextSpan(
236+
text: argument.isRequired ? '*' : '',
237+
style: theme.fixedFontStyle,
238+
),
239+
],
240+
),
241+
],
242+
),
243+
);
244+
}
245+
246+
String? _typeForLabel(EditableArgument argument) {
247+
String? typeName;
248+
switch (argument.type) {
249+
case 'string':
250+
typeName = 'String';
251+
break;
252+
case 'int':
253+
case 'double':
254+
case 'bool':
255+
typeName = argument.type;
256+
break;
257+
case 'enum':
258+
typeName = argument.options?.first.split('.').first;
259+
break;
260+
default:
261+
break;
262+
}
263+
264+
if (typeName == null) return null;
265+
return argument.isNullable ? '$typeName?' : typeName;
266+
}
267+
217268
Future<void> _editArgument(String? valueAsString) async {
218269
final argName = widget.argument.name;
219270

packages/devtools_app/test/standalone_ui/ide_shared/property_editor_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ void main() {
137137
controller.initForTestsOnly(editableArgs: result1.args);
138138
await tester.pumpAndSettle();
139139

140-
final titleInput = _findTextFormField('title');
141-
final widthInput = _findTextFormField('width');
142-
final heightInput = _findTextFormField('height');
140+
final titleInput = _findTextFormField('String? title');
141+
final widthInput = _findTextFormField('double width');
142+
final heightInput = _findTextFormField('double? height');
143143

144144
// Verify the inputs are expected.
145145
expect(_findNoPropertiesMessage, findsNothing);
@@ -169,8 +169,8 @@ void main() {
169169
controller.initForTestsOnly(editableArgs: result2.args);
170170
await tester.pumpAndSettle();
171171

172-
final softWrapInput = _findDropdownButtonFormField('softWrap');
173-
final alignInput = _findDropdownButtonFormField('align');
172+
final softWrapInput = _findDropdownButtonFormField('bool softWrap');
173+
final alignInput = _findDropdownButtonFormField('Alignment? align');
174174

175175
// Verify the inputs are expected.
176176
expect(_findNoPropertiesMessage, findsNothing);
@@ -422,7 +422,7 @@ final _findNoPropertiesMessage = find.text(
422422
);
423423

424424
Finder _findTextFormField(String inputName) => find.ancestor(
425-
of: find.textContaining(inputName),
425+
of: find.richTextContaining(inputName),
426426
matching: find.byType(TextFormField),
427427
);
428428

@@ -444,7 +444,7 @@ Finder _helperTextForInput(Finder inputFinder, {required String matching}) {
444444
}
445445

446446
Finder _findDropdownButtonFormField(String inputName) => find.ancestor(
447-
of: find.text(inputName),
447+
of: find.richTextContaining(inputName),
448448
matching: find.byType(DropdownButtonFormField<String>),
449449
);
450450

0 commit comments

Comments
 (0)