From e2ef6c925a68360f34caa51470b0c01ffbf5e314 Mon Sep 17 00:00:00 2001 From: Chili Palmer Date: Sat, 4 Apr 2026 19:40:18 +0200 Subject: [PATCH] fix: language selector for M2 --- AGENTS.md | 1 + crates/bds-ui/assets/flags/de.svg | 5 --- crates/bds-ui/assets/flags/es.svg | 5 --- crates/bds-ui/assets/flags/fr.svg | 5 --- crates/bds-ui/assets/flags/gb.svg | 7 ---- crates/bds-ui/assets/flags/it.svg | 5 --- crates/bds-ui/src/views/status_bar.rs | 52 ++++------------------- crates/bds-ui/src/views/workspace.rs | 59 ++++++++++++++++++++++++--- 8 files changed, 62 insertions(+), 77 deletions(-) delete mode 100644 crates/bds-ui/assets/flags/de.svg delete mode 100644 crates/bds-ui/assets/flags/es.svg delete mode 100644 crates/bds-ui/assets/flags/fr.svg delete mode 100644 crates/bds-ui/assets/flags/gb.svg delete mode 100644 crates/bds-ui/assets/flags/it.svg diff --git a/AGENTS.md b/AGENTS.md index 1e2b4c1..efa9936 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,6 +30,7 @@ Invariants and behaviours in the allium spec should be covered by unit tests of - all automatic AI activities must be gated by airplane (offline) mode of the app and either use the local model or inform the user via toast - metadata needs to be flushed to the filesystem and needs to be included in metadata diff tool and in rebuild from filesystem. All three aspects have to be in sync with each other. - if you add new metadata, add them to publishing, metadata-diff and rebuild-from-database +- Rust and its ecosystem are new and moving fast. you're builtin knowledge is probably outdated. use the web to make sure you know what you are doing. ## important behaviour diff --git a/crates/bds-ui/assets/flags/de.svg b/crates/bds-ui/assets/flags/de.svg deleted file mode 100644 index 6a9c1cb..0000000 --- a/crates/bds-ui/assets/flags/de.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/crates/bds-ui/assets/flags/es.svg b/crates/bds-ui/assets/flags/es.svg deleted file mode 100644 index 6f7843c..0000000 --- a/crates/bds-ui/assets/flags/es.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/crates/bds-ui/assets/flags/fr.svg b/crates/bds-ui/assets/flags/fr.svg deleted file mode 100644 index 491bcf1..0000000 --- a/crates/bds-ui/assets/flags/fr.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/crates/bds-ui/assets/flags/gb.svg b/crates/bds-ui/assets/flags/gb.svg deleted file mode 100644 index 82a0a1e..0000000 --- a/crates/bds-ui/assets/flags/gb.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/crates/bds-ui/assets/flags/it.svg b/crates/bds-ui/assets/flags/it.svg deleted file mode 100644 index 118ee39..0000000 --- a/crates/bds-ui/assets/flags/it.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/crates/bds-ui/src/views/status_bar.rs b/crates/bds-ui/src/views/status_bar.rs index 61a12c9..93296eb 100644 --- a/crates/bds-ui/src/views/status_bar.rs +++ b/crates/bds-ui/src/views/status_bar.rs @@ -1,4 +1,4 @@ -use iced::widget::{button, column, container, row, text, Space}; +use iced::widget::{button, container, row, text, Space}; use iced::widget::text::Shaping; use iced::{Alignment, Background, Border, Color, Element, Length, Theme}; @@ -57,7 +57,7 @@ fn airplane_active(_theme: &Theme, status: button::Status) -> button::Style { } /// Dropdown trigger button style. -fn dropdown_trigger(_theme: &Theme, status: button::Status) -> button::Style { +pub fn dropdown_trigger(_theme: &Theme, status: button::Status) -> button::Style { let bg = match status { button::Status::Hovered => Color::from_rgb(0.22, 0.22, 0.27), _ => Color::TRANSPARENT, @@ -75,7 +75,7 @@ fn dropdown_trigger(_theme: &Theme, status: button::Status) -> button::Style { } /// Dropdown item style. -fn dropdown_item(_theme: &Theme, status: button::Status) -> button::Style { +pub fn dropdown_item(_theme: &Theme, status: button::Status) -> button::Style { let bg = match status { button::Status::Hovered => Color::from_rgb(0.25, 0.25, 0.30), _ => Color::from_rgb(0.18, 0.18, 0.22), @@ -93,7 +93,7 @@ fn dropdown_item(_theme: &Theme, status: button::Status) -> button::Style { } /// Dropdown container background. -fn dropdown_bg(_theme: &Theme) -> container::Style { +pub fn dropdown_bg(_theme: &Theme) -> container::Style { container::Style { background: Some(Background::Color(Color::from_rgb(0.18, 0.18, 0.22))), border: Border { @@ -115,7 +115,6 @@ pub fn view( media_count: usize, locale: UiLocale, offline_mode: bool, - locale_dropdown_open: bool, task_snapshots: &[TaskSnapshot], ) -> Element<'static, Message> { let label_color = Color::from_rgb(0.60, 0.60, 0.65); @@ -175,7 +174,7 @@ pub fn view( .spacing(8) .align_y(Alignment::Center); - let status_row = container( + container( row![ left, Space::with_width(Length::Fill), @@ -186,43 +185,6 @@ pub fn view( ) .width(Length::Fill) .height(Length::Fixed(24.0)) - .style(bar_style); - - // If dropdown is open, stack it above the status bar - if locale_dropdown_open { - let items: Vec> = UiLocale::all() - .iter() - .map(|&l| { - let flag_text = text(l.flag_emoji()) - .size(16) - .shaping(Shaping::Advanced); - - button(flag_text) - .on_press(Message::SetUiLocale(l)) - .padding([4, 8]) - .width(Length::Fill) - .style(dropdown_item) - .into() - }) - .collect(); - - let dropdown_menu = container( - iced::widget::Column::with_children(items).spacing(2).padding(4), - ) - .style(dropdown_bg); - - // Align dropdown to the right, above the status bar - let dropdown_row = row![ - Space::with_width(Length::Fill), - dropdown_menu, - // offset from right edge to roughly align with the flag trigger - Space::with_width(Length::Fixed(40.0)), - ]; - - column![dropdown_row, status_row] - .width(Length::Fill) - .into() - } else { - status_row.into() - } + .style(bar_style) + .into() } diff --git a/crates/bds-ui/src/views/workspace.rs b/crates/bds-ui/src/views/workspace.rs index 0456d52..aa69da0 100644 --- a/crates/bds-ui/src/views/workspace.rs +++ b/crates/bds-ui/src/views/workspace.rs @@ -1,5 +1,6 @@ -use iced::widget::{column, container, row, Space}; -use iced::{Background, Color, Element, Length, Theme}; +use iced::widget::{button, column, container, row, stack, text, Space}; +use iced::widget::text::Shaping; +use iced::{Alignment, Background, Color, Element, Length, Padding, Theme}; use bds_core::i18n::UiLocale; @@ -98,12 +99,60 @@ pub fn view( media_count, locale, offline_mode, - locale_dropdown_open, task_snapshots, ); - column![main_row, separator_h(), status] + let base_layout: Element<'static, Message> = column![main_row, separator_h(), status] .width(Length::Fill) .height(Length::Fill) - .into() + .into(); + + if locale_dropdown_open { + // Build the dropdown menu overlay + let items: Vec> = UiLocale::all() + .iter() + .map(|&l| { + let flag_text = text(l.flag_emoji()) + .size(16) + .shaping(Shaping::Advanced); + + button(flag_text) + .on_press(Message::SetUiLocale(l)) + .padding([4, 8]) + .style(status_bar::dropdown_item) + .into() + }) + .collect(); + + let dropdown_menu = container( + iced::widget::Column::with_children(items).spacing(2).padding(4), + ) + .style(status_bar::dropdown_bg); + + // Position the dropdown at bottom-right, above the status bar (24px) + let overlay: Element<'static, Message> = container( + container( + row![ + Space::with_width(Length::Fill), + dropdown_menu, + // Offset from right edge to align near the flag trigger + Space::with_width(Length::Fixed(40.0)), + ] + ) + .width(Length::Fill) + .align_y(Alignment::End) + .padding(Padding { top: 0.0, right: 0.0, bottom: 25.0, left: 0.0 }) // above status bar + ) + .width(Length::Fill) + .height(Length::Fill) + .align_y(Alignment::End) + .into(); + + stack![base_layout, overlay] + .width(Length::Fill) + .height(Length::Fill) + .into() + } else { + base_layout + } }