Hide password while authenticating
This commit is contained in:
parent
7b52add24e
commit
c661984d1c
3 changed files with 53 additions and 6 deletions
|
|
@ -19,6 +19,7 @@ use crate::ui::chat::{ChatState, Reaction};
|
|||
use crate::ui::input::{key, InputEvent, KeyBindingsList, KeyEvent};
|
||||
use crate::ui::widgets::background::Background;
|
||||
use crate::ui::widgets::border::Border;
|
||||
use crate::ui::widgets::cursor::Cursor;
|
||||
use crate::ui::widgets::editor::EditorState;
|
||||
use crate::ui::widgets::empty::Empty;
|
||||
use crate::ui::widgets::join::{HJoin, Segment, VJoin};
|
||||
|
|
@ -193,7 +194,7 @@ impl EuphRoom {
|
|||
|
||||
match &self.state {
|
||||
State::Normal => {}
|
||||
State::Auth(editor) => layers.push(Self::auth_widget(editor)),
|
||||
State::Auth(_) => layers.push(Self::auth_widget()),
|
||||
State::Nick(editor) => layers.push(Self::nick_widget(editor)),
|
||||
}
|
||||
|
||||
|
|
@ -204,11 +205,17 @@ impl EuphRoom {
|
|||
Layer::new(layers).into()
|
||||
}
|
||||
|
||||
fn auth_widget(editor: &EditorState) -> BoxedWidget {
|
||||
Popup::new(Padding::new(editor.widget()).left(1))
|
||||
.title("Enter password")
|
||||
.inner_padding(false)
|
||||
.build()
|
||||
fn auth_widget() -> BoxedWidget {
|
||||
Popup::new(
|
||||
Padding::new(Cursor::new(Text::new((
|
||||
"<hidden>",
|
||||
ContentStyle::default().grey().italic(),
|
||||
))))
|
||||
.left(1),
|
||||
)
|
||||
.title("Enter password")
|
||||
.inner_padding(false)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn nick_widget(editor: &EditorState) -> BoxedWidget {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
pub mod background;
|
||||
pub mod border;
|
||||
pub mod cursor;
|
||||
pub mod editor;
|
||||
pub mod empty;
|
||||
pub mod float;
|
||||
|
|
|
|||
39
src/ui/widgets/cursor.rs
Normal file
39
src/ui/widgets/cursor.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use async_trait::async_trait;
|
||||
use toss::frame::{Frame, Pos, Size};
|
||||
|
||||
use super::{BoxedWidget, Widget};
|
||||
|
||||
pub struct Cursor {
|
||||
inner: BoxedWidget,
|
||||
pos: Pos,
|
||||
}
|
||||
|
||||
impl Cursor {
|
||||
pub fn new<W: Into<BoxedWidget>>(inner: W) -> Self {
|
||||
Self {
|
||||
inner: inner.into(),
|
||||
pos: Pos::ZERO,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn at(mut self, pos: Pos) -> Self {
|
||||
self.pos = pos;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn at_xy(self, x: i32, y: i32) -> Self {
|
||||
self.at(Pos::new(x, y))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Widget for Cursor {
|
||||
fn size(&self, frame: &mut Frame, max_width: Option<u16>, max_height: Option<u16>) -> Size {
|
||||
self.inner.size(frame, max_width, max_height)
|
||||
}
|
||||
|
||||
async fn render(self: Box<Self>, frame: &mut Frame) {
|
||||
self.inner.render(frame).await;
|
||||
frame.set_cursor(Some(self.pos));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue