revault-gui
revault-gui copied to clipboard
UI: refac components module
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.
Was this addressed?
Maybe implements trait like https://github.com/revault/revault-gui/pull/332/files#diff-4590e6fa70bf623f72fd7ab3d7d7666c8f5209b4d2db04821f958e8b0dd967c4