mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-12-24 12:29:44 +00:00
Remove redundant code in themes
Removed redundant match statement with a function
This commit is contained in:
parent
1aa1dfe382
commit
3b7e859af8
|
@ -14,95 +14,70 @@ pub enum Theme {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Theme {
|
impl Theme {
|
||||||
pub fn dir_color(&self) -> Color {
|
fn get_color_variant(&self, default: Color, compatible: Color) -> Color {
|
||||||
match self {
|
match self {
|
||||||
Theme::Default => Color::Blue,
|
Theme::Default => default,
|
||||||
Theme::Compatible => Color::Blue,
|
Theme::Compatible => compatible,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_icon_variant(&self, default: &'static str, compatible: &'static str) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Theme::Default => default,
|
||||||
|
Theme::Compatible => compatible,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn dir_color(&self) -> Color {
|
||||||
|
self.get_color_variant(Color::Blue, Color::Blue)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cmd_color(&self) -> Color {
|
pub fn cmd_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::Rgb(204, 224, 208), Color::LightGreen)
|
||||||
Theme::Default => Color::Rgb(204, 224, 208),
|
|
||||||
Theme::Compatible => Color::LightGreen,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multi_select_disabled_color(&self) -> Color {
|
pub fn multi_select_disabled_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::DarkGray, Color::DarkGray)
|
||||||
Theme::Default => Color::DarkGray,
|
|
||||||
Theme::Compatible => Color::DarkGray,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_color(&self) -> Color {
|
pub fn tab_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::Rgb(255, 255, 85), Color::Yellow)
|
||||||
Theme::Default => Color::Rgb(255, 255, 85),
|
|
||||||
Theme::Compatible => Color::Yellow,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dir_icon(&self) -> &'static str {
|
pub fn dir_icon(&self) -> &'static str {
|
||||||
match self {
|
self.get_icon_variant(" ", "[DIR]")
|
||||||
Theme::Default => " ",
|
|
||||||
Theme::Compatible => "[DIR]",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_icon(&self) -> &'static str {
|
pub fn cmd_icon(&self) -> &'static str {
|
||||||
match self {
|
self.get_icon_variant(" ", "[CMD]")
|
||||||
Theme::Default => " ",
|
|
||||||
Theme::Compatible => "[CMD]",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tab_icon(&self) -> &'static str {
|
pub fn tab_icon(&self) -> &'static str {
|
||||||
match self {
|
self.get_icon_variant(" ", ">> ")
|
||||||
Theme::Default => " ",
|
|
||||||
Theme::Compatible => ">> ",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multi_select_icon(&self) -> &'static str {
|
pub fn multi_select_icon(&self) -> &'static str {
|
||||||
match self {
|
self.get_icon_variant("", "*")
|
||||||
Theme::Default => "",
|
|
||||||
Theme::Compatible => "*",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn success_color(&self) -> Color {
|
pub fn success_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::Rgb(5, 255, 55), Color::Green)
|
||||||
Theme::Default => Color::Rgb(5, 255, 55),
|
|
||||||
Theme::Compatible => Color::Green,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fail_color(&self) -> Color {
|
pub fn fail_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::Rgb(199, 55, 44), Color::Red)
|
||||||
Theme::Default => Color::Rgb(199, 55, 44),
|
|
||||||
Theme::Compatible => Color::Red,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focused_color(&self) -> Color {
|
pub fn focused_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::LightBlue, Color::LightBlue)
|
||||||
Theme::Default => Color::LightBlue,
|
|
||||||
Theme::Compatible => Color::LightBlue,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn search_preview_color(&self) -> Color {
|
pub fn search_preview_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::DarkGray, Color::DarkGray)
|
||||||
Theme::Default => Color::DarkGray,
|
|
||||||
Theme::Compatible => Color::DarkGray,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unfocused_color(&self) -> Color {
|
pub fn unfocused_color(&self) -> Color {
|
||||||
match self {
|
self.get_color_variant(Color::Gray, Color::Gray)
|
||||||
Theme::Default => Color::Gray,
|
|
||||||
Theme::Compatible => Color::Gray,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user