-
Notifications
You must be signed in to change notification settings - Fork 42
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
Dynamic Properties #47
Comments
Hey, thanks for the suggestion. I think I got the idea but I am not 100% sure. Could elaborate more? Would be cool if you could put an example of what you would expect the API would look like. |
Sure! We add options to the It would be valuable to add some logic conditional on another property's key/value pair. Here is some high-level pseudocode that I'm sure would bring in some edge-cases or handling that needs to be accounted for somewhere else, but it provides the gist of the ask here. class DashbookContext {
/// Contain the current BoxConstraints of the area available for the Chapter
BoxConstraints? constraints;
Map<String, Property> properties = {};
String textProperty(
String name,
String defaultValue, {
Map<String, dynamic>? removeWhen,
}) {
// FIXME: Would have to check all the key/value pairs.
if (removeWhen != null &&
properties[removeWhen.keys.first]?.getValue() ==
removeWhen.values.first) {
properties.remove(name);
// FIXME: Verify what we'd want to return.
return '';
}
if (properties.containsKey(name)) {
return properties[name]!.getValue();
} else {
final property = Property<String>(name, defaultValue);
properties[name] = property;
return property.getValue();
}
}
... This does work, but currently it doesn't until you rebuild the Properties tab. This would then enable consumers to do something like: ...
text: dashbookContext.textProperty(
'Error Text',
'Oops, something went wrong!',
removeWhen: {
'state': 'success',
},
),
... Where the user would only see the "Error Text" property (on the Properties tab) if the Property who's key "state" and current value is not I'm not saying this approach is the best way to accomplish this as I haven't looked too in-depth into the source code, but hopefully it provides more context and an example of the intent behind this ask. Let me know if not. |
Got it @jeffscaturro-aka, thanks for the further explanation, I made some adaptations to your suggestion and just submitted #49 |
It would be nice to have dynamic properties that become visible or hidden based on another property.
For instance, you can have a type property that drives subsequent properties that are visible, such as an additional label only present if that type were selected.
The text was updated successfully, but these errors were encountered: