Comments (3)
Got it @jeffscaturro-aka, thanks for the further explanation, I made some adaptations to your suggestion and just submitted #49
from dashbook.
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.
from dashbook.
Sure!
We add options to the DashbookContext
and store them in a map of properties
: https://github.com/erickzanardo/dashbook/blob/f2581ce298242a07302482b4eccb8045197ce2a4/lib/src/story.dart#L26-L38
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 success
. This would hide properties that may confuse or pollute the list of properties when not applicable.
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.
from dashbook.
Related Issues (20)
- Better contrast between selected item and the rest in the list HOT 4
- The "Padding" property value might overflow
- Remove spaces / replace them with underscore for the links HOT 3
- Crash on flutter run due to flutter_colorpicker 1.0.3 incompatibility with flutter 3.22 HOT 1
- Navigation? HOT 4
- Shrink side bar to fit content HOT 2
- Add option to have the navigation panel always open HOT 2
- [BUG] main canvas content is not properly clipped HOT 2
- Ability to set custom size for device preview HOT 2
- Add option to draw Info panel and the bottom and pin it
- Add custom languages
- Upgrading dependencies HOT 2
- Removing pubspec.lock HOT 1
- colorProperty is closing the page in Flutter Web HOT 4
- [HELP] I need some help with custom font/icons in Flutter Web HOT 1
- Theming of Dashbook breaks when adding multiple instances HOT 1
- Dashbook.dualTheme() doesn't assign any value to the variable theme
- Ability to set MediaQuery textScaleFactor HOT 4
- Move device properties to side panel instead of pop-up HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dashbook.