Skip to content
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

PaneItem and TabView Color #1057

Open
mahery01 opened this issue Apr 22, 2024 · 3 comments
Open

PaneItem and TabView Color #1057

mahery01 opened this issue Apr 22, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@mahery01
Copy link

mahery01 commented Apr 22, 2024

Hello to all,
How to change the background PaneItem and selected TabView?
fluent01

@bdlukaa
Copy link
Owner

bdlukaa commented Apr 23, 2024

You can provide a navigationPaneTheme in FluentTheme:

theme: FluentThemeData(
  navigationPaneTheme: NavigationPaneThemeData(
    tileColor: ButtonState.resolveWith((states) {
      return ...; // return color here based on the state.
    }),
  ),
)

We don't have an option to change background color on TabView. One hack is to change the FluentThemeData.resources values that are used in TabView.

final foregroundColor = ButtonState.resolveWith<Color>((states) {
if (widget.selected) {
return res.textFillColorPrimary;
} else if (states.isPressing) {
return res.textFillColorSecondary;
} else if (states.isHovering) {
return res.textFillColorPrimary;
} else if (states.isDisabled) {
return res.textFillColorDisabled;
} else {
return res.textFillColorSecondary;
}
}).resolve(states);
/// https://github.com/microsoft/microsoft-ui-xaml/blob/main/dev/TabView/TabView_themeresources.xaml#L10-L14
final backgroundColor = ButtonState.resolveWith<Color>((states) {
if (widget.selected) {
return res.solidBackgroundFillColorTertiary;
} else if (states.isPressing) {
return res.layerOnMicaBaseAltFillColorDefault;
} else if (states.isHovering) {
return res.layerOnMicaBaseAltFillColorSecondary;
} else if (states.isDisabled) {
return res.layerOnMicaBaseAltFillColorTransparent;
} else {
return res.layerOnMicaBaseAltFillColorTransparent;
}
}).resolve(states);

@bdlukaa bdlukaa added the enhancement New feature or request label Apr 23, 2024
@mahery01
Copy link
Author

@bdlukaa
Thank you for your response. Could you please provide an example for both questions? I've tried but I can't seem to do it. Thank you in advance

@bdlukaa
Copy link
Owner

bdlukaa commented May 20, 2024

¹ is provided at the previous response.

²

FluentTheme(
  data: FluentTheme.of(context).copyWith(
    resources: ResourceDictionary(
      layerOnMicaBaseAltFillColorTransparent: Color(...),
      ...,
    ),
  ),
  child: TabView( ... )
),

The previous response shows what colors are used on the TabView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants