Skip to content

Commit

Permalink
fix(login): Set min size and increase size for phrase window (#1992)
Browse files Browse the repository at this point in the history
Co-authored-by: Flemmli97 <Flemmli97@users.noreply.github.com>
  • Loading branch information
Flemmli97 and Flemmli97 authored May 23, 2024
1 parent 36a31be commit 385d787
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
8 changes: 3 additions & 5 deletions ui/src/layouts/log_in/copy_seed_words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ use std::time::Duration;
use arboard::Clipboard;
use common::{icons, language::get_local_text, state::State};
use dioxus::prelude::*;
use dioxus_desktop::{use_window, LogicalSize};
use dioxus_desktop::use_window;
use kit::elements::{button::Button, label::Label, Appearance};
use tokio::time::sleep;

use super::AuthPages;
use crate::get_app_style;
use crate::layouts::log_in::update_window_size;
use common::state::configuration::Configuration;
use common::{
sounds,
Expand All @@ -26,10 +27,7 @@ pub fn Layout(cx: Scope, page: UseState<AuthPages>, username: String, pin: Strin
let window = use_window(cx);

if !matches!(&*page.current(), AuthPages::Success(_)) {
window.set_inner_size(LogicalSize {
width: 500.0,
height: 480.0,
});
update_window_size(window, 500.0, 500.0);
}

let words = use_future(cx, (), |_| async move {
Expand Down
9 changes: 3 additions & 6 deletions ui/src/layouts/log_in/create_or_recover.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use common::{language::get_local_text, state::State};
use dioxus::prelude::*;
use dioxus_desktop::{use_window, LogicalSize};
use dioxus_desktop::use_window;
use kit::elements::{button::Button, label::Label};

use crate::get_app_style;
use crate::{get_app_style, layouts::log_in::update_window_size};

use super::AuthPages;

Expand All @@ -14,10 +14,7 @@ pub fn Layout(cx: Scope, page: UseState<AuthPages>) -> Element {
let window = use_window(cx);

if !matches!(&*page.current(), AuthPages::Success(_)) {
window.set_inner_size(LogicalSize {
width: 500.0,
height: 250.0,
});
update_window_size(window, 500.0, 250.0);
}
cx.render(rsx!(
style {get_app_style(&state.read())},
Expand Down
9 changes: 3 additions & 6 deletions ui/src/layouts/log_in/enter_seed_words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use common::{
WARP_CMD_CH,
};
use dioxus::prelude::*;
use dioxus_desktop::{use_window, LogicalSize};
use dioxus_desktop::use_window;
use futures::{channel::oneshot, StreamExt};
use kit::elements::{
button::Button,
Expand All @@ -15,7 +15,7 @@ use kit::elements::{
Appearance,
};

use crate::get_app_style;
use crate::{get_app_style, layouts::log_in::update_window_size};

use super::AuthPages;

Expand Down Expand Up @@ -50,10 +50,7 @@ pub fn Layout(cx: Scope, pin: UseRef<String>, page: UseState<AuthPages>) -> Elem
let window = use_window(cx);

if !matches!(&*page.current(), AuthPages::Success(_)) {
window.set_inner_size(LogicalSize {
width: 500.0,
height: 480.0,
});
update_window_size(window, 500.0, 500.0);
}

let eval = use_eval(cx);
Expand Down
8 changes: 3 additions & 5 deletions ui/src/layouts/log_in/enter_username.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use common::icons::outline::Shape as Icon;
use common::language::get_local_text;
use dioxus::prelude::*;
use dioxus_desktop::{use_window, LogicalSize};
use dioxus_desktop::use_window;
use kit::elements::label::Label;
use kit::elements::{
button::Button,
input::{Input, Options, Validation},
};
use tracing::log;

use crate::layouts::log_in::update_window_size;
use crate::AuthPages;

pub const MIN_USERNAME_LEN: i32 = 4;
Expand All @@ -20,10 +21,7 @@ pub fn Layout(cx: Scope, page: UseState<AuthPages>, user_name: UseRef<String>) -
let window = use_window(cx);

if !matches!(&*page.current(), AuthPages::Success(_)) {
window.set_inner_size(LogicalSize {
width: 500.0,
height: 250.0,
});
update_window_size(window, 500.0, 250.0);
}

//let error = use_state(cx, String::new);
Expand Down
17 changes: 10 additions & 7 deletions ui/src/layouts/log_in/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod entry_point;
mod recover_account;

use dioxus::prelude::*;
use dioxus_desktop::{use_window, LogicalSize};
use dioxus_desktop::{use_window, DesktopService, LogicalSize};
use kit::components::topbar_controls::TopbarControls;
use kit::STYLE as UIKIT_STYLES;
use warp::multipass;
Expand Down Expand Up @@ -35,17 +35,13 @@ pub fn AuthGuard(cx: Scope, page: UseState<AuthPages>) -> Element {

let pin = use_ref(cx, String::new);
let user_name = use_ref(cx, String::new);
let desktop = use_window(cx);
let theme = "";

// make the window smaller while the user authenticates
let window = use_window(cx);

if !matches!(&*page.current(), AuthPages::Success(_)) {
window.set_inner_size(LogicalSize {
width: 500.0,
height: 350.0,
});
update_window_size(window, 500.0, 350.0);
}

cx.render(rsx! (
Expand All @@ -57,7 +53,7 @@ pub fn AuthGuard(cx: Scope, page: UseState<AuthPages>) -> Element {
id: "lockscreen-controls",
div {
class: "draggable-topbar",
onmousedown: move |_| { desktop.drag(); },
onmousedown: move |_| { window.drag(); },
},
TopbarControls {},
},
Expand All @@ -73,3 +69,10 @@ pub fn AuthGuard(cx: Scope, page: UseState<AuthPages>) -> Element {
}
))
}

// Sets both inner and min size for logins
pub fn update_window_size(window: &DesktopService, width: f64, height: f64) {
let size = LogicalSize { width, height };
window.set_min_inner_size(Some(size));
window.set_inner_size(size);
}

0 comments on commit 385d787

Please sign in to comment.