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

[Help] Custom style for Tabs #125

Closed
carlocorradini opened this issue May 25, 2023 · 2 comments · Fixed by #138
Closed

[Help] Custom style for Tabs #125

carlocorradini opened this issue May 25, 2023 · 2 comments · Fixed by #138

Comments

@carlocorradini
Copy link
Contributor

How to implement custom style for Tabs?
I'm trying to add a Dark style when the current theme is Dark
I've tried to do the following:

#[derive(Debug, Clone, Copy, Eq, PartialEq, Display, Default)]
pub enum MyTheme {
    Light,
    #[default]
    Dark,
}

impl iced_aw::tab_bar::StyleSheet for iced::Theme {
    type Style = MyTheme;

    fn active(&self, style: Self::Style, is_active: bool) -> iced_aw::style::tab_bar::Appearance {
        // ...
    }

    fn hovered(&self, style: Self::Style, is_active: bool) -> iced_aw::style::tab_bar::Appearance {
        // ...
    }
}

This does not work due to one of Rust's principles:
"Only traits defined in the current crate can be implemented for types defined outside of the crate define and implement a trait or new type instead"

If this approach is not feasible, what is the correct one? Thanks 😊🎉

PS: What do you think if we add Dark in TabBarStyles?
PSPS: I think styling is not strictly related to Tabs but also for other widgets too... Add an example on how to override a style? 👀

@genusistimelord
Copy link
Collaborator

I think it would be fine to add Dark to the Tab styles. The issue with Themes atm is if you want anything outside of the current theme you have to create an Entire New theme for all of iced to get the smaller parts the way you want them too. We have been working out more ways to customize this to be able to still do it the old way where you can set a Custom theme per Image. Just have not gotten around to it.

@carlocorradini
Copy link
Contributor Author

I'll try to create a PR with the new Style 🥳
Thanks for your reply 😎

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 a pull request may close this issue.

2 participants