From bd99a0c2b24b119b0a66264ef795de76dfadac10 Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Mon, 14 Dec 2020 13:39:47 +0100 Subject: [PATCH] align auth popup error to center --- CHANGELOG.md | 2 ++ src/ui/activities/auth_activity.rs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64bb387..151512d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Released on 14/12/2020 - File explorer: - Fixed color mismatch in local explorer - Explorer tabs have now 70% of layout height, while logging area is 30% + - Auth page: + - align popup text to center - Bugfix: - Fixed memory vulnerability in Windows version diff --git a/src/ui/activities/auth_activity.rs b/src/ui/activities/auth_activity.rs index 6ba23f1..11205c7 100644 --- a/src/ui/activities/auth_activity.rs +++ b/src/ui/activities/auth_activity.rs @@ -31,6 +31,7 @@ extern crate unicode_width; // locals use super::{Activity, Context}; use crate::filetransfer::FileTransferProtocol; +use crate::utils::align_text_center; // Includes use crossterm::event::Event as InputEvent; @@ -397,9 +398,9 @@ impl AuthActivity { .direction(Direction::Vertical) .constraints( [ - Constraint::Percentage((80) / 2), - Constraint::Percentage(20), - Constraint::Percentage((80) / 2), + Constraint::Percentage(30), // Offset top + Constraint::Percentage(10), // Actual height + Constraint::Percentage(60), // Offset bottom ] .as_ref(), ) @@ -415,9 +416,12 @@ impl AuthActivity { .as_ref(), ) .split(popup_layout[1])[1]; - let popup: Paragraph = Paragraph::new(self.popup_message.as_ref().unwrap().as_ref()) - .style(Style::default().fg(Color::Red)) - .block(Block::default().borders(Borders::ALL).title("Alert")); + let popup: Paragraph = Paragraph::new(align_text_center( + self.popup_message.as_ref().unwrap().as_ref(), + area.width, + )) + .style(Style::default().fg(Color::Red)) + .block(Block::default().borders(Borders::ALL).title("Alert")); (popup, area) } }