-
-
Notifications
You must be signed in to change notification settings - Fork 12
Split mvu and component #255
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
Conversation
3dabe55 to
482b9bc
Compare
2a5e230 to
29a851d
Compare
29a851d to
7ad8e14
Compare
d60fa07 to
8065959
Compare
# Conflicts: # src/Fabulous.Avalonia/Attributes.fs # src/Fabulous.Avalonia/Program.fs # src/Fabulous.Avalonia/Views/Application.fs # src/Fabulous.Avalonia/Views/Controls/Documents/_Inline.fs # src/Fabulous.Avalonia/Views/Controls/TextBlock.fs # src/Fabulous.Avalonia/Views/Controls/ToggleSwitch.fs # src/Fabulous.Avalonia/Views/ItemsControl.fs # src/Fabulous.Avalonia/Views/Menu/MenuFlyout.fs # src/Fabulous.Avalonia/Views/_Animatable.fs
| [<AbstractClass; Sealed>] | ||
| type ThemeAware = | ||
| static member With(light: 'T, dark: 'T) = | ||
| if Application.Current.ActualThemeVariant = ThemeVariant.Dark then | ||
| dark | ||
| else | ||
| light |
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.
@edgarfgp Will this helper be dropped without replacement or is there another mechanism I can use to switch between dark an light widget colors without an if statement?
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.
We have added support for Environment objects similar t SwiftUI. See
| let! theme = Context.Environment(EnvironmentKeys.Theme) |
| let color = | ||
| if theme = ThemeVariant.Light then | ||
| Colors.Red | ||
| else | ||
| Colors.Green | ||
|
|
||
| TextBlock("I'm a text that is theme aware.") | ||
| .foreground(SolidColorBrush(ThemeAware.With(Colors.Red, Colors.Green))) | ||
| .foreground(SolidColorBrush(color)) |
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.
I see... My question was regarding how the theme is used here. This if statement was hidden by the ThemeAware.With helper before. Will there be a helper to replace it?
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.
Hum I guess we can add it back. It would be 2 ways of doing the same. But I think these can co-exist with not problem.
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.
Thanks, that'd make widgets with themed colors and the migration to pre7 easier.
No description provided.