From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id DD6001FF17A for ; Tue, 1 Jul 2025 10:38:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3C0EC39605; Tue, 1 Jul 2025 10:39:04 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Tue, 1 Jul 2025 10:38:59 +0200 Message-Id: <20250701083859.2088138-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250701083859.2088138-1-d.csapak@proxmox.com> References: <20250701083859.2088138-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-comp 4/4] login panel: use snackbar for errors when on mobile X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" when mobile is set, use the snackbar for errors if a snackbar controller is available. Otherwise show the erros like before. Signed-off-by: Dominik Csapak --- src/login_panel.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/login_panel.rs b/src/login_panel.rs index 3c16ed4..11c7ade 100644 --- a/src/login_panel.rs +++ b/src/login_panel.rs @@ -2,6 +2,7 @@ use std::rc::Rc; use pwt::props::PwtSpace; use pwt::state::PersistentState; +use pwt::touch::{SnackBar, SnackBarContextExt}; use yew::html::IntoEventCallback; use yew::prelude::*; use yew::virtual_dom::{VComp, VNode}; @@ -34,7 +35,8 @@ pub struct LoginPanel { /// Mobile Layout /// - /// Use special layout for mobile apps. + /// Use special layout for mobile apps. For example shows error in a [SnackBar] + /// if a [SnackBarController] context is available. /// /// Note: Always use saved userid to avoid additional checkbox. #[prop_or(false)] @@ -450,6 +452,9 @@ impl Component for ProxmoxLoginPanel { let realm = self.form_ctx.read().get_field_text("realm"); self.send_login(ctx, username, password, realm); + if let (true, Some(controller)) = (props.mobile, ctx.link().snackbar_controller()) { + controller.dismiss_all() + } true } Msg::Login(info) => { @@ -465,7 +470,14 @@ impl Component for ProxmoxLoginPanel { Msg::LoginError(msg) => { self.loading = false; self.challenge = None; - self.login_error = Some(msg); + match (props.mobile, ctx.link().snackbar_controller()) { + (true, Some(controller)) => { + controller.show_snackbar(SnackBar::new().message(msg)); + } + _ => { + self.login_error = Some(msg); + } + } true } } -- 2.39.5 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel