diff --git a/widget/src/show_popup.rs b/widget/src/show_popup.rs index da7bba1..56d5658 100644 --- a/widget/src/show_popup.rs +++ b/widget/src/show_popup.rs @@ -4,6 +4,15 @@ use slint::SharedString; slint::include_modules!(); +fn unit_symbol(units: &str) -> char { + match units { + "metric" => 'C', + "imperial" => 'F', + "standard" => 'K', + _ => '?', + } +} + pub fn show_popup(resp: &WeatherResponse, cfg: &Config) -> Result<(), Box> { let ui = MainWindow::new()?; @@ -22,12 +31,7 @@ pub fn show_popup(resp: &WeatherResponse, cfg: &Config) -> Result<(), Box 'C', - "imperial" => 'F', - "standard" => 'K', - _ => '?', - }; + let unit_symbol = unit_symbol(cfg.query_params.units.as_str()); ui.set_city(SharedString::from(city)); ui.set_country(SharedString::from(country)); @@ -35,7 +39,7 @@ pub fn show_popup(resp: &WeatherResponse, cfg: &Config) -> Result<(), Box