Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new themes optimised for OLED displays and visually impaired users #708

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All Sniffnet releases with the relative changes are documented in this file.
- Updated some of the existing translations to v1.3:
- Portuguese ([#690](https://github.com/GyulyVGC/sniffnet/pull/690))
- Ukrainian ([#692](https://github.com/GyulyVGC/sniffnet/pull/692))
- Added new themes _OLED (Night)_ and _OLED (Day)_ based on palettes optimized for OLED displays and users with visual impairments ([#708](https://github.com/GyulyVGC/sniffnet/pull/708))

## [1.3.2] - 2025-01-06
- Dropdown menus for network host filters ([#659](https://github.com/GyulyVGC/sniffnet/pull/659) — fixes [#354](https://github.com/GyulyVGC/sniffnet/issues/354))
Expand Down
1 change: 1 addition & 0 deletions src/gui/styles/custom_themes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod dracula;
pub mod gruvbox;
pub mod nord;
pub mod oled;
pub mod solarized;
34 changes: 34 additions & 0 deletions src/gui/styles/custom_themes/oled.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#![allow(clippy::unreadable_literal)]

//! Themes optimized for OLED displays and visually impaired users
//! <https://github.com/GyulyVGC/sniffnet/pull/708>

use iced::color;
use once_cell::sync::Lazy;

use crate::gui::styles::types::palette::Palette;
use crate::gui::styles::types::palette_extension::PaletteExtension;

pub static OLED_DARK_PALETTE: Lazy<Palette> = Lazy::new(|| Palette {
primary: color!(0x000000),
secondary: color!(0x934900),
outgoing: color!(0xF0F0F0),
starred: color!(0xFFFF00),
text_headers: color!(0xE0E0E0),
text_body: color!(0xfcfaf0),
});

pub static OLED_DARK_PALETTE_EXTENSION: Lazy<PaletteExtension> =
Lazy::new(|| OLED_DARK_PALETTE.generate_palette_extension());

pub static OLED_LIGHT_PALETTE: Lazy<Palette> = Lazy::new(|| Palette {
primary: color!(0xFFFFFF),
secondary: color!(0x6CB6FF),
outgoing: color!(0x0F0F0F),
starred: color!(0x0000FF),
text_headers: color!(0x1F1F1F),
text_body: color!(0x03050F),
});

pub static OLED_LIGHT_PALETTE_EXTENSION: Lazy<PaletteExtension> =
Lazy::new(|| OLED_LIGHT_PALETTE.generate_palette_extension());
14 changes: 14 additions & 0 deletions src/gui/styles/types/custom_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use crate::gui::styles::custom_themes::nord::{
NORD_DARK_PALETTE, NORD_DARK_PALETTE_EXTENSION, NORD_LIGHT_PALETTE,
NORD_LIGHT_PALETTE_EXTENSION,
};
use crate::gui::styles::custom_themes::oled::{
OLED_DARK_PALETTE, OLED_DARK_PALETTE_EXTENSION, OLED_LIGHT_PALETTE,
OLED_LIGHT_PALETTE_EXTENSION,
};
use crate::gui::styles::custom_themes::solarized::{
SOLARIZED_DARK_PALETTE, SOLARIZED_DARK_PALETTE_EXTENSION, SOLARIZED_LIGHT_PALETTE,
SOLARIZED_LIGHT_PALETTE_EXTENSION,
Expand Down Expand Up @@ -51,6 +55,8 @@ pub enum ExtraStyles {
NordLight,
SolarizedDark,
SolarizedLight,
OledDark,
OledLight,
CustomToml(CustomPalette),
}

Expand All @@ -66,6 +72,8 @@ impl ExtraStyles {
ExtraStyles::NordLight => *NORD_LIGHT_PALETTE,
ExtraStyles::SolarizedDark => *SOLARIZED_DARK_PALETTE,
ExtraStyles::SolarizedLight => *SOLARIZED_LIGHT_PALETTE,
ExtraStyles::OledDark => *OLED_DARK_PALETTE,
ExtraStyles::OledLight => *OLED_LIGHT_PALETTE,
ExtraStyles::CustomToml(custom_palette) => custom_palette.palette,
}
}
Expand All @@ -81,6 +89,8 @@ impl ExtraStyles {
ExtraStyles::NordLight => *NORD_LIGHT_PALETTE_EXTENSION,
ExtraStyles::SolarizedDark => *SOLARIZED_DARK_PALETTE_EXTENSION,
ExtraStyles::SolarizedLight => *SOLARIZED_LIGHT_PALETTE_EXTENSION,
ExtraStyles::OledDark => *OLED_DARK_PALETTE_EXTENSION,
ExtraStyles::OledLight => *OLED_LIGHT_PALETTE_EXTENSION,
ExtraStyles::CustomToml(custom_palette) => custom_palette.extension,
}
}
Expand All @@ -96,6 +106,8 @@ impl ExtraStyles {
ExtraStyles::NordLight,
ExtraStyles::SolarizedDark,
ExtraStyles::SolarizedLight,
ExtraStyles::OledDark,
ExtraStyles::OledLight,
]
}
}
Expand All @@ -111,6 +123,8 @@ impl fmt::Display for ExtraStyles {
ExtraStyles::NordDark => write!(f, "Nord (Night)"),
ExtraStyles::SolarizedLight => write!(f, "Solarized (Day)"),
ExtraStyles::SolarizedDark => write!(f, "Solarized (Night)"),
ExtraStyles::OledLight => write!(f, "OLED (Day)"),
ExtraStyles::OledDark => write!(f, "OLED (Night)"),
// Custom style names aren't used anywhere so this shouldn't be reached
ExtraStyles::CustomToml(_) => unreachable!(),
}
Expand Down