-
Notifications
You must be signed in to change notification settings - Fork 819
Open
Labels
a:language-slintCompiler for the .slint language (mO,bF)Compiler for the .slint language (mO,bF)
Description
It would be nice to have a way to propagate information to children without explicitly passing them as properties on each level aka. "property drilling".
enum ThemeMode { light, dark }
context Theme {
property<ThemeMode> mode;
property<brush> background;
property<brush> foreground;
}
// Adapts its looks according to the theme in the context
component MyThemableWidget {
Rectangle {
background: Theme.background; // <--
Text {
color: Theme.foreground; // <--
}
}
}
export component MyWindow inherits Window {
Theme {
mode: ThemeMode.light;
MyThemableWidget {}
}
Theme {
mode: ThemeMode.dark;
Dialog {
MyThemableWidget {}
}
}
}
This is conceptually similar to Context in React and InheritedWidget in Flutter. In Flutter, inherited widgets are used for implementing many core framework features including theming, localization, layout direction, navigation, and many external packages for dependency injection and state management.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a:language-slintCompiler for the .slint language (mO,bF)Compiler for the .slint language (mO,bF)