Skip to content

Commit

Permalink
Grouped country mappings
Browse files Browse the repository at this point in the history
The main changes are:

Grouped country mappings at the top of the match statement in get_flag_from_country

Kept all other functionality identical

Maintained the same structure and logic for the rest of the code
  • Loading branch information
ZeroDot1 committed Feb 13, 2025
1 parent 09c96ef commit 36ab8d3
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/countries/country_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ fn get_flag_from_country<'a>(
let mut tooltip = country.to_string();
let mut svg_style = SvgType::Standard;
let svg = Svg::new(Handle::from_memory(Vec::from(match country {
// Grouped country mappings
Country::FR | Country::BL | Country::GF | Country::GP | Country::MF | Country::MQ | Country::PM | Country::RE | Country::WF | Country::YT => FR,
Country::NL | Country::BQ => NL,
Country::NO | Country::SJ => NO,
Country::US | Country::UM => US,
Country::AU | Country::HM => AU,

// Individual country mappings
Country::AD => AD,
Country::AE => AE,
Country::AF => AF,
Expand All @@ -54,7 +62,6 @@ fn get_flag_from_country<'a>(
Country::AR => AR,
Country::AS => AS,
Country::AT => AT,
Country::AU | Country::HM => AU,
Country::AW => AW,
Country::AX => AX,
Country::AZ => AZ,
Expand Down Expand Up @@ -114,16 +121,6 @@ fn get_flag_from_country<'a>(
Country::FK => FK,
Country::FM => FM,
Country::FO => FO,
Country::FR
| Country::BL
| Country::GF
| Country::GP
| Country::MF
| Country::MQ
| Country::PM
| Country::RE
| Country::WF
| Country::YT => FR,
Country::GA => GA,
Country::GB => GB,
Country::GD => GD,
Expand Down Expand Up @@ -209,8 +206,6 @@ fn get_flag_from_country<'a>(
Country::NF => NF,
Country::NG => NG,
Country::NI => NI,
Country::NL | Country::BQ => NL,
Country::NO | Country::SJ => NO,
Country::NP => NP,
Country::NR => NR,
Country::NU => NU,
Expand Down Expand Up @@ -272,7 +267,6 @@ fn get_flag_from_country<'a>(
Country::TZ => TZ,
Country::UA => UA,
Country::UG => UG,
Country::US | Country::UM => US,
Country::UY => UY,
Country::UZ => UZ,
Country::VA => VA,
Expand Down Expand Up @@ -402,4 +396,4 @@ pub fn get_computer_tooltip<'a>(
)
.snap_within_viewport(true)
.class(ContainerType::Tooltip)
}
}

0 comments on commit 36ab8d3

Please sign in to comment.