revault-gui icon indicating copy to clipboard operation
revault-gui copied to clipboard

UI: refac components module

Open edouardparis opened this issue 4 years ago • 2 comments

The current state is a little messy. Each component is often paired with a <Component>Style which is often a struct implementing the container::StyleSheet trait. Maybe it would be cleaner to implement a new module style in the component module with a generic struct implementing container::StyleSheet and with chained methods:

example:

pub struct ContainerStyle(iced::container::Style);

impl ContainerStyle {
    pub fn new() -> Self {
        ContainerStyle(iced::container::Style::default())
    }
    pub fn rounded(mut self) -> Self {
        self.0.border_radius = 10.0;
        self
    }
}

impl iced::container::StyleSheet for ContainerStyle {
    fn style(&self) -> container::Style {
        return self.0;
    }
}

usage:

        Container::new(content)
            .padding(15)
            .style(ContainerStyle::new().rounded().backround(color::BACKGROUND))

maybe use macro instead

In order to generate at build time the struct needed.

edouardparis avatar Feb 11 '21 09:02 edouardparis

Was this addressed?

darosior avatar Dec 15 '21 19:12 darosior

Maybe implements trait like https://github.com/revault/revault-gui/pull/332/files#diff-4590e6fa70bf623f72fd7ab3d7d7666c8f5209b4d2db04821f958e8b0dd967c4

edouardparis avatar Mar 10 '22 15:03 edouardparis