From 0044e52336262f0d0c3213f1493ee4e136d42d29 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 01:34:47 +0000 Subject: [PATCH] =?UTF-8?q?Toasts=20carry=20bullet=20lines:=20a=20card=20s?= =?UTF-8?q?hows=20up=20to=20eight=20under=20its=20message,=20then=20one=20?= =?UTF-8?q?faint=20"=E2=80=A6and=20n=20more"=20line;=20NoticeCenter=20post?= =?UTF-8?q?s=20the=20title=20and=20its=20lines=20instead=20of=20joining=20?= =?UTF-8?q?them=20into=20the=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/ui-contract/src/contract/toast.rs | 9 +- crates/ui-contract/src/runtime/toast.rs | 9 ++ crates/ui-widgets/src/notices/center.rs | 9 +- crates/ui-widgets/src/notices/notice.rs | 108 ++++++++++++++++++++--- crates/ui-widgets/src/notices/toasts.rs | 3 +- crates/ui-widgets/src/notices/words.rs | 2 + crates/ui-widgets/tests/it/notices.rs | 19 +++- 7 files changed, 131 insertions(+), 28 deletions(-) diff --git a/crates/ui-contract/src/contract/toast.rs b/crates/ui-contract/src/contract/toast.rs index 679eb6621..8ec5ea4e1 100644 --- a/crates/ui-contract/src/contract/toast.rs +++ b/crates/ui-contract/src/contract/toast.rs @@ -92,12 +92,9 @@ fn corner(env: &Env) -> Align2 { if env.direction.is_rtl() { Align2::LEFT_BOTTOM } else { Align2::RIGHT_BOTTOM } } -/// What the card announces when it first shows: the title and the message. +/// What the card announces when it first shows: the title, the message and the lines, the empty ones left out. fn announcement(env: &Env, toast: &Toast) -> String { let view = env.view(); - let message = view.resolve(&toast.message); - match &toast.title { - Some(title) => format!("{}, {}", view.resolve(title).as_str(), message.as_str()), - None => message.as_str().to_owned(), - } + let texts = toast.title.iter().chain(std::iter::once(&toast.message)).chain(&toast.lines); + texts.map(|text| view.resolve(text).as_str().to_owned()).filter(|text| !text.is_empty()).collect::>().join(", ") } diff --git a/crates/ui-contract/src/runtime/toast.rs b/crates/ui-contract/src/runtime/toast.rs index e3d3d80ee..3a21fa255 100644 --- a/crates/ui-contract/src/runtime/toast.rs +++ b/crates/ui-contract/src/runtime/toast.rs @@ -60,6 +60,8 @@ pub struct Toast { pub tone: Tone, /// A title above the message. pub title: Option