Skip to content

Conversation

@DevTKSS
Copy link
Contributor

@DevTKSS DevTKSS commented Apr 30, 2025

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

  • Documentation content changes

What is the current behavior?

Only Mvvm sample but none for State binding commonly used in MVUX Applications

What is the new behavior?

Added sample to documentation to show how it can be done in a mvux app

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs => Works fine at my SkiaDesktop target app
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal) => Has been asked at Discord few days ago

Other information

Internal Issue (If applicable):

Comment on lines 96 to 97
> [!NOTE]
> In case, you try to bind a `CommandExtension.Command` to a ToggleSwitch, you will need to use the `IsOn` property to bind it, because `Toggled` Behaviour is not triggering the `CommandExtensions.Command`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this part, I think we should add this functionality to the CommandExtensions. Issue created here: unoplatform/uno.toolkit.ui#1391

We don't need to call this out here so I think we can remove this NOTE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kazo0 does removing this note mean, to also remove the IsOn Property Binding? I could consider a way that might be a usecase for BindBack but I honestly do not know how to use that correctly same as the FallbackValue or TargetNullValue (e.g. considered this for workaround the roslyn issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed note in b55486c Replaced as comment to be applyed after fixing this issues

}
```

### [MVUX](#tab/mvux)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion here is that we don't include this as part of the ThemeService docs but we should create a Recipe Book docs entry for this usage in Chefs: https://github.com/unoplatform/uno.chefs/blob/198923fcd69d416fd3901be2fe4d58fecd74421b/Chefs/Presentation/SettingsModel.cs#L26-L38

https://platform.uno/docs/articles/external/uno.chefs/doc/RecipeBooksOverview.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that ThemeChangedMessage in there is quite cool and the ISettingsService... Can we not get a SettingsService generally available in extensions? that would really be cool! to have just to call this to automatically switch theme or localization! is this think-able?

@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 16:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds MVUX state binding examples to the ThemeService documentation, expanding beyond the existing MVVM examples. The documentation now provides developers with guidance on how to implement theme switching in MVUX applications using state binding patterns.

  • Adds MVUX tab section with Model and View examples showing state-based theme binding
  • Includes practical code samples for implementing theme switching with IState and ToggleSwitch
  • Updates source code link format to use markdown code syntax

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


In case you want to use it together with a State, e.g. to bind a control to the current theme trigger a Task with each Time, the Value changes, here is a simple example:

```cssharp
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code block language identifier should be 'csharp' not 'cssharp'.

Suggested change
```cssharp
```csharp

Copilot uses AI. Check for mistakes.
public IState<bool> IsDarkMode => State<bool>.Value(this, () => _themeService.Theme == AppTheme.Dark)
.ForEach(SwitchThemeAsync);

public async ValueTask SwitchThemeAsync(bool item,CancellationToken ctk = default)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in parameter list. Should be 'bool item, CancellationToken ctk = default'.

Suggested change
public async ValueTask SwitchThemeAsync(bool item,CancellationToken ctk = default)
public async ValueTask SwitchThemeAsync(bool item, CancellationToken ctk = default)

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +69
true => await _themeService.SetThemeAsync(AppTheme.Light),
false => await _themeService.SetThemeAsync(AppTheme.Dark)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean logic is inverted. When item is true (toggle is on), it should set Dark theme, not Light theme. The switch cases should be reversed.

Suggested change
true => await _themeService.SetThemeAsync(AppTheme.Light),
false => await _themeService.SetThemeAsync(AppTheme.Dark)
true => await _themeService.SetThemeAsync(AppTheme.Dark),
false => await _themeService.SetThemeAsync(AppTheme.Light)

Copilot uses AI. Check for mistakes.
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.

2 participants