From 6c7a78ce76a2653ea39af079d770bd66e92244e0 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 20 Jan 2026 14:58:57 +0100 Subject: [PATCH] use RmlUi animation syntax for toast Animation syntax: - toast-show class triggers toast-in animation (slide up, fade in) - toast-hide class triggers toast-out animation (slide down, fade out) --- src/main/assets/apps/shell/shell.lua | 21 ++++++----------- src/main/assets/apps/shell/shell.rml | 34 ++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/main/assets/apps/shell/shell.lua b/src/main/assets/apps/shell/shell.lua index 98edc8e..2e78673 100644 --- a/src/main/assets/apps/shell/shell.lua +++ b/src/main/assets/apps/shell/shell.lua @@ -252,30 +252,23 @@ function showToast(message, type) type_class = " toast-warning" end - -- Create toast in hidden state (opacity 0, translated down) - local toast_html = '
' .. message .. '
' + -- Create toast with show animation class + local toast_html = '
' .. message .. '
' container.inner_rml = toast_html - -- Add toast-show class after brief delay to trigger transition + -- Auto-hide after 2.5 seconds if setTimeout then - setTimeout(function() - local toast = shell_document:GetElementById("active-toast") - if toast then - toast:SetClass("toast-show", true) - end - end, 10) - - -- Auto-hide after 2.5 seconds active_toast_id = setTimeout(function() local toast = shell_document:GetElementById("active-toast") if toast then - -- Remove show class to animate out + -- Switch to hide animation toast:SetClass("toast-show", false) - -- Remove element after transition + toast:SetClass("toast-hide", true) + -- Remove element after animation setTimeout(function() container.inner_rml = "" active_toast_id = nil - end, 300) + end, 250) end end, 2500) end diff --git a/src/main/assets/apps/shell/shell.rml b/src/main/assets/apps/shell/shell.rml index 8c335f3..f5d0e03 100644 --- a/src/main/assets/apps/shell/shell.rml +++ b/src/main/assets/apps/shell/shell.rml @@ -125,16 +125,36 @@ font-weight: bold; text-align: center; pointer-events: auto; - /* Initial hidden state */ - opacity: 0; - transform: translateY(30dp); - /* Transition for smooth animation */ - transition: opacity transform 0.3s back-out; } .toast-show { - opacity: 1; - transform: translateY(0); + animation: 0.3s back-out toast-in; + } + + .toast-hide { + animation: 0.25s quadratic-in toast-out; + } + + @keyframes toast-in { + from { + opacity: 0; + transform: translateY(30dp); + } + to { + opacity: 1; + transform: translateY(0); + } + } + + @keyframes toast-out { + from { + opacity: 1; + transform: translateY(0); + } + to { + opacity: 0; + transform: translateY(30dp); + } } .toast-success {