fix: language selector for M2

This commit is contained in:
2026-04-04 19:40:18 +02:00
parent cbac412390
commit e2ef6c925a
8 changed files with 62 additions and 77 deletions

View File

@@ -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

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40">
<rect width="60" height="14" fill="#000000"/>
<rect y="14" width="60" height="13" fill="#DD0000"/>
<rect y="27" width="60" height="13" fill="#FFCC00"/>
</svg>

Before

Width:  |  Height:  |  Size: 226 B

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40">
<rect width="60" height="10" fill="#AA151B"/>
<rect y="10" width="60" height="20" fill="#F1BF00"/>
<rect y="30" width="60" height="10" fill="#AA151B"/>
</svg>

Before

Width:  |  Height:  |  Size: 226 B

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40">
<rect width="20" height="40" fill="#002395"/>
<rect x="20" width="20" height="40" fill="#FFFFFF"/>
<rect x="40" width="20" height="40" fill="#ED2939"/>
</svg>

Before

Width:  |  Height:  |  Size: 226 B

View File

@@ -1,7 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40">
<rect width="60" height="40" fill="#012169"/>
<path d="M0 0 L60 40 M60 0 L0 40" stroke="#FFFFFF" stroke-width="8"/>
<path d="M0 0 L60 40 M60 0 L0 40" stroke="#C8102E" stroke-width="4"/>
<path d="M30 0 V40 M0 20 H60" stroke="#FFFFFF" stroke-width="12"/>
<path d="M30 0 V40 M0 20 H60" stroke="#C8102E" stroke-width="6"/>
</svg>

Before

Width:  |  Height:  |  Size: 397 B

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 40">
<rect width="20" height="40" fill="#009246"/>
<rect x="20" width="20" height="40" fill="#FFFFFF"/>
<rect x="40" width="20" height="40" fill="#CE2B37"/>
</svg>

Before

Width:  |  Height:  |  Size: 226 B

View File

@@ -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<Element<'static, Message>> = 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()
}

View File

@@ -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<Element<'static, Message>> = 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
}
}