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

Fix Solid nickname color #277

Merged
merged 2 commits into from
Mar 18, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

Changed:

- Use primary text color instead of accent color for `Solid` nicknames

# 2024.4 (2024-03-15)

Added:
Expand Down
15 changes: 13 additions & 2 deletions src/theme/text.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use super::Theme;
use data::theme::{alpha, randomize_color};
use iced::widget::text::{Appearance, DefaultStyle};

use super::Theme;

impl DefaultStyle for Theme {
fn default_style(&self) -> Appearance {
none(self)
Expand Down Expand Up @@ -49,14 +50,24 @@ pub fn transparent(theme: &Theme) -> Appearance {
}

pub fn nickname(theme: &Theme, seed: Option<String>, transparent: bool) -> Appearance {
let dark_theme = theme.colors().is_dark_theme();

if seed.is_none() {
let color = match transparent {
true => theme.colors().text.med_alpha,
false => theme.colors().text.base,
};

return Appearance { color: Some(color) };
}

let original_color = theme.colors().action.base;
let randomized_color = seed
.as_deref()
.map(|seed| randomize_color(original_color, seed))
.unwrap_or_else(|| original_color);

let color = if transparent {
let dark_theme = theme.colors().is_dark_theme();
alpha(randomized_color, if dark_theme { 0.2 } else { 0.4 })
} else {
randomized_color
Expand Down
Loading