Skip to content

Conversation

@edgarfgp
Copy link
Member

No description provided.

@edgarfgp edgarfgp force-pushed the split-mvu-and-component branch from 3dabe55 to 482b9bc Compare July 26, 2024 18:58
@edgarfgp edgarfgp force-pushed the split-mvu-and-component branch from 2a5e230 to 29a851d Compare September 6, 2024 21:58
@edgarfgp edgarfgp force-pushed the split-mvu-and-component branch from 29a851d to 7ad8e14 Compare September 8, 2024 09:01
@edgarfgp edgarfgp force-pushed the split-mvu-and-component branch from d60fa07 to 8065959 Compare September 26, 2024 21:04
# 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
@edgarfgp edgarfgp marked this pull request as ready for review November 4, 2024 18:07
@edgarfgp edgarfgp requested a review from TimLariviere November 4, 2024 21:38
@edgarfgp edgarfgp merged commit 417d16a into main Nov 9, 2024
@edgarfgp edgarfgp deleted the split-mvu-and-component branch November 9, 2024 10:15
Comment on lines -8 to -14
[<AbstractClass; Sealed>]
type ThemeAware =
static member With(light: 'T, dark: 'T) =
if Application.Current.ActualThemeVariant = ThemeVariant.Dark then
dark
else
light
Copy link
Contributor

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?

Copy link
Member Author

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)
for an example

Comment on lines +70 to +77
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))
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants