Skip to content

Commit

Permalink
fixed focus border of password field
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikwilkowski committed Jan 20, 2024
1 parent 999f0af commit fee8715
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ui/password_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn password_view(
) -> impl View {
let value = create_rw_signal(String::from(""));
let show_password = create_rw_signal(false);
let is_focused = create_rw_signal(false);

let see_icon = include_str!("./icons/see.svg");
let hide_icon = include_str!("./icons/hide.svg");
Expand All @@ -41,6 +42,14 @@ pub fn password_view(
.hover(|s| s.background(Color::TRANSPARENT))
.focus(|s| s.hover(|s| s.background(Color::TRANSPARENT)))
})
.on_event(EventListener::FocusGained, move |_| {
is_focused.set(true);
EventPropagation::Continue
})
.on_event(EventListener::FocusLost, move |_| {
is_focused.set(false);
EventPropagation::Continue
})
.placeholder("Enter password")
.request_focus(move || password.track())
.on_event(EventListener::KeyDown, move |event| {
Expand Down Expand Up @@ -91,6 +100,7 @@ pub fn password_view(
.padding(4)
.border(1)
.border_color(C_TEXT_TOP)
.apply_if(is_focused.get(), |s| s.border_color(C_FOCUS))
.border_left(0)
.cursor(CursorStyle::Pointer)
}),
Expand Down

0 comments on commit fee8715

Please sign in to comment.