Fix styling example when system theme is selected
This commit is contained in:
parent
0111f514a1
commit
4d32e733b7
1 changed files with 19 additions and 14 deletions
|
|
@ -46,21 +46,26 @@ impl Styling {
|
||||||
Message::CheckboxToggled(value) => self.checkbox_value = value,
|
Message::CheckboxToggled(value) => self.checkbox_value = value,
|
||||||
Message::TogglerToggled(value) => self.toggler_value = value,
|
Message::TogglerToggled(value) => self.toggler_value = value,
|
||||||
Message::PreviousTheme | Message::NextTheme => {
|
Message::PreviousTheme | Message::NextTheme => {
|
||||||
if let Some(current) = Theme::ALL.iter().position(|candidate| {
|
let current = Theme::ALL.iter().position(|candidate| {
|
||||||
self.theme.as_ref() == Some(candidate)
|
self.theme.as_ref() == Some(candidate)
|
||||||
}) {
|
});
|
||||||
self.theme =
|
|
||||||
Some(if matches!(message, Message::NextTheme) {
|
self.theme = Some(if matches!(message, Message::NextTheme) {
|
||||||
Theme::ALL[(current + 1) % Theme::ALL.len()].clone()
|
Theme::ALL[current.map(|current| current + 1).unwrap_or(0)
|
||||||
} else if current == 0 {
|
% Theme::ALL.len()]
|
||||||
Theme::ALL
|
.clone()
|
||||||
.last()
|
} else {
|
||||||
.expect("Theme::ALL must not be empty")
|
let current = current.unwrap_or(0);
|
||||||
.clone()
|
|
||||||
} else {
|
if current == 0 {
|
||||||
Theme::ALL[current - 1].clone()
|
Theme::ALL
|
||||||
});
|
.last()
|
||||||
}
|
.expect("Theme::ALL must not be empty")
|
||||||
|
.clone()
|
||||||
|
} else {
|
||||||
|
Theme::ALL[current - 1].clone()
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue