-
Notifications
You must be signed in to change notification settings - Fork 323
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
Add the extension settings dialog #6138
Add the extension settings dialog #6138
Conversation
packages/devtools_app/lib/src/extensions/extension_service.dart
Outdated
Show resolved
Hide resolved
rootPath: appRootPath, | ||
extensionName: extension.name, | ||
); | ||
final stateNotifier = _extensionEnabledStates.putIfAbsent( |
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.
Consider making the following changes to enabledStateListenable
:
ValueListenable<ExtensionEnabledState> enabledStateListenable(
String extensionName,
{ExtensionEnabledState initialState = ExtensionEnabledState.none,}
) {
return _extensionEnabledStates.putIfAbsent(
extensionName.toLowerCase(),
() => ValueNotifier<ExtensionEnabledState>(initialState),
);
}
and then invoke it here:
final stateNotifier = enabledStateListenable(
extension.name,
initialState: stateFromOptionsFile,
);
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.
Ah, totally forgot this is returning a ValueListenable
and you need a ValueNotifier
...
Another option is to create _enabledStateNotifier(...)
and change enabledStateListenable
to ValueListenable<ExtensionEnabledState> enabledStateListenable(String extensionName) => _enabledStateNotifier(extensionName);
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.
This wouldn't really save us much complexity since we would still need to call stateNotifier.value = stateFromOptionsFile;
below in _refreshExtensionEnabledStates
because the ifAbsent
function wouldn't always be called.
packages/devtools_app/lib/src/extensions/extension_settings.dart
Outdated
Show resolved
Hide resolved
packages/devtools_app/lib/src/extensions/extension_settings.dart
Outdated
Show resolved
Hide resolved
onPressed: (index) => states[index].$3(), | ||
selectedStates: | ||
states.map((option) => option.$2(enabledState)).toList(), | ||
children: states |
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.
Nit: something like this would be cleaner
selectedStates: [
for (final (_, state, __) in states)
state(enabledState),
],
children: [
for (final (name, _, __) in states)
Padding(
padding: const EdgeInsets.symmetric(
vertical: densePadding,
horizontal: denseSpacing,
),
child: Text(name),
),
]
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.
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.
Ah, this would have worked with the positional records.
This should work now that we're using named properties:
selectedStates: [
for (final state in states)
state.isSelected(enabledState),
],
children: [
for (final state in states)
Padding(
padding: const EdgeInsets.symmetric(
vertical: densePadding,
horizontal: denseSpacing,
),
child: Text(state.name),
),
]
packages/devtools_app/test/extensions/extension_settings_test.dart
Outdated
Show resolved
Hide resolved
onPressed: (index) => states[index].$3(), | ||
selectedStates: | ||
states.map((option) => option.$2(enabledState)).toList(), | ||
children: states |
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.
Ah, this would have worked with the positional records.
This should work now that we're using named properties:
selectedStates: [
for (final state in states)
state.isSelected(enabledState),
],
children: [
for (final state in states)
Padding(
padding: const EdgeInsets.symmetric(
vertical: densePadding,
horizontal: denseSpacing,
),
child: Text(state.name),
),
]
Will clean up the last comment as part of will clean up as part of #6140 |
Add extension settings dialog that is accessible from an "Extensions" toolbar action:
Each extension will also be possible to enable / disable from its own tab, but this extensions menu will always show all available extensions, so that if a user disables one that they later want to enable, they have a way to do that.
Work towards #1632