Skip to content

Commit

Permalink
SVG color is now equal to body text color
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Dec 21, 2023
1 parent 0884170 commit 223352e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 4 additions & 1 deletion resources/countries_flags/4x3/zz-broadcast.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion resources/countries_flags/4x3/zz-multicast.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::countries::flags_pictures::{
};
use crate::countries::types::country::Country;
use crate::gui::styles::container::ContainerType;
use crate::gui::styles::svg::SvgType;
use crate::gui::types::message::Message;
use crate::networking::types::traffic_type::TrafficType;
use crate::translations::translations_2::{
Expand All @@ -35,6 +36,7 @@ fn get_flag_from_country(
) -> (Svg<Renderer<StyleType>>, String) {
#![allow(clippy::too_many_lines)]
let mut tooltip = country.to_string();
let mut svg_style = SvgType::Standard;
let svg = Svg::new(Handle::from_memory(Vec::from(match country {
Country::AD => AD,
Country::AE => AE,
Expand Down Expand Up @@ -284,19 +286,24 @@ fn get_flag_from_country(
Country::ZZ => {
if is_local {
tooltip = local_translation(language);
svg_style = SvgType::AdaptColor;
HOME
} else if traffic_type.eq(&TrafficType::Multicast) {
tooltip = "Multicast".to_string();
svg_style = SvgType::AdaptColor;
MULTICAST
} else if traffic_type.eq(&TrafficType::Broadcast) {
tooltip = "Broadcast".to_string();
svg_style = SvgType::AdaptColor;
BROADCAST
} else {
tooltip = unknown_translation(language);
svg_style = SvgType::AdaptColor;
UNKNOWN
}
}
})))
.style(svg_style)
.width(Length::Fixed(width))
.height(Length::Fixed(width * 0.75));

Expand Down Expand Up @@ -340,6 +347,7 @@ pub fn get_computer_tooltip(
(false, TrafficType::Unicast) => UNKNOWN,
},
)))
.style(SvgType::AdaptColor)
.width(Length::Fixed(FLAGS_WIDTH_BIG))
.height(Length::Fixed(FLAGS_WIDTH_BIG * 0.75));

Expand Down
12 changes: 9 additions & 3 deletions src/gui/styles/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@

use iced::widget::svg::Appearance;

use crate::StyleType;
use crate::{get_colors, StyleType};

#[derive(Clone, Copy, Default)]
pub enum SvgType {
AdaptColor,
#[default]
Standard,
}

impl iced::widget::svg::StyleSheet for StyleType {
type Style = SvgType;

fn appearance(&self, _: &Self::Style) -> Appearance {
Appearance { color: None }
fn appearance(&self, style: &Self::Style) -> Appearance {
Appearance {
color: match style {
SvgType::AdaptColor => Some(get_colors(*self).text_body),
SvgType::Standard => None,
},
}
}
}

0 comments on commit 223352e

Please sign in to comment.