Compare commits
7
Commits
143f43a407
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5932990be | ||
|
|
aa4d0d8e61 | ||
|
|
cbcf5a3fa4 | ||
|
|
d8a9a5bb7d | ||
|
|
d272adcc4c | ||
|
|
f720fa00f4 | ||
|
|
1f5da251dc |
No files matched your search
+2507
-69
File diff suppressed because it is too large.
Load diff
+127
-9
@@ -8,7 +8,7 @@ use std::env;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use iced::widget::container;
|
use iced::widget::{button, container, text_input};
|
||||||
use iced::{Border, Color, Theme};
|
use iced::{Border, Color, Theme};
|
||||||
|
|
||||||
/// Accent red used for destructive/close affordances in both themes.
|
/// Accent red used for destructive/close affordances in both themes.
|
||||||
@@ -131,6 +131,132 @@ pub fn tab(theme: &Theme, active: bool) -> container::Style {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Style for the currently selected option in a group of choice buttons.
|
||||||
|
pub fn selected_option(theme: &Theme, _status: button::Status) -> button::Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
|
||||||
|
button::Style {
|
||||||
|
background: Some(palette.primary.base.color.into()),
|
||||||
|
text_color: palette.primary.base.text,
|
||||||
|
border: Border {
|
||||||
|
color: palette.primary.base.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
},
|
||||||
|
..button::Style::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Style for an unselected choice button: outlined so it reads as a button
|
||||||
|
/// rather than a plain text label.
|
||||||
|
pub fn outlined_option(theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
|
||||||
|
button::Style {
|
||||||
|
border: Border {
|
||||||
|
color: palette.background.strong.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
},
|
||||||
|
..button::text(theme, status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Style for a confirming action button (green).
|
||||||
|
pub fn positive_option(theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let success = theme.extended_palette().success;
|
||||||
|
filled_option(match status {
|
||||||
|
button::Status::Hovered | button::Status::Pressed => success.strong,
|
||||||
|
_ => success.base,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Style for a destructive/cancelling action button (red).
|
||||||
|
pub fn danger_option(theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let danger = theme.extended_palette().danger;
|
||||||
|
filled_option(match status {
|
||||||
|
button::Status::Hovered | button::Status::Pressed => danger.strong,
|
||||||
|
_ => danger.base,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn filled_option(pair: iced::theme::palette::Pair) -> button::Style {
|
||||||
|
button::Style {
|
||||||
|
background: Some(pair.color.into()),
|
||||||
|
text_color: pair.text,
|
||||||
|
border: Border {
|
||||||
|
color: pair.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
},
|
||||||
|
..button::Style::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Style for the password eye button while the password is revealed.
|
||||||
|
pub fn revealed_eye(theme: &Theme, status: button::Status) -> button::Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
|
||||||
|
button::Style {
|
||||||
|
background: None,
|
||||||
|
text_color: palette.background.base.text,
|
||||||
|
border: Border {
|
||||||
|
color: palette.primary.base.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
},
|
||||||
|
..button::text(theme, status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Style for a selectable list row; the selected one gets a tinted background.
|
||||||
|
pub fn selectable_row(theme: &Theme, status: button::Status, selected: bool) -> button::Style {
|
||||||
|
if selected {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
|
||||||
|
button::Style {
|
||||||
|
background: Some(palette.primary.weak.color.into()),
|
||||||
|
text_color: palette.primary.weak.text,
|
||||||
|
border: Border {
|
||||||
|
radius: 3.0.into(),
|
||||||
|
..Border::default()
|
||||||
|
},
|
||||||
|
..button::Style::default()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let mut style = button::text(theme, status);
|
||||||
|
|
||||||
|
if matches!(status, button::Status::Hovered) {
|
||||||
|
style.background =
|
||||||
|
Some(theme.extended_palette().background.weak.color.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
style
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Style for filter/text fields: a thicker outline while focused.
|
||||||
|
pub fn filter_field(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||||
|
let palette = theme.extended_palette();
|
||||||
|
let mut style = text_input::default(theme, status);
|
||||||
|
|
||||||
|
style.border = if matches!(status, text_input::Status::Focused { .. }) {
|
||||||
|
Border {
|
||||||
|
color: palette.primary.strong.color,
|
||||||
|
width: 2.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Border {
|
||||||
|
color: palette.background.strong.color,
|
||||||
|
width: 1.0,
|
||||||
|
radius: 4.0.into(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
style
|
||||||
|
}
|
||||||
|
|
||||||
/// Style for the settings window frame.
|
/// Style for the settings window frame.
|
||||||
pub fn settings_frame(theme: &Theme) -> container::Style {
|
pub fn settings_frame(theme: &Theme) -> container::Style {
|
||||||
let palette = theme.extended_palette();
|
let palette = theme.extended_palette();
|
||||||
@@ -146,14 +272,6 @@ pub fn settings_frame(theme: &Theme) -> container::Style {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Style for a label that sits over the outline of an input.
|
|
||||||
pub fn field_label(theme: &Theme) -> container::Style {
|
|
||||||
container::Style {
|
|
||||||
background: Some(theme.extended_palette().background.weak.color.into()),
|
|
||||||
..container::Style::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::Preference;
|
use super::Preference;
|
||||||
|
|||||||
Reference in new issue
Block a user