ui: optimize panel width calculation

This commit is contained in:
ardocrat 2023-08-11 17:28:13 +03:00
parent e9fa5a140a
commit 3635b7abe6

View file

@ -96,14 +96,12 @@ impl WalletCreation {
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
// Setup content width. // Setup content width.
let mut rect = ui.available_rect_before_wrap(); let available_width = ui.available_width();
let mut width = f32::min( if available_width == 0.0 {
ui.available_width(),
Root::SIDE_PANEL_WIDTH * 2.0
);
if width == 0.0 {
return; return;
} }
let mut rect = ui.available_rect_before_wrap();
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 2.0);
rect.set_width(width); rect.set_width(width);
// Draw step control content. // Draw step control content.
@ -140,14 +138,12 @@ impl WalletCreation {
.show(ui, |ui| { .show(ui, |ui| {
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {
// Setup content width. // Setup content width.
let mut rect = ui.available_rect_before_wrap(); let available_width = ui.available_width();
let mut width = f32::min( if available_width == 0.0 {
ui.available_width(),
Root::SIDE_PANEL_WIDTH * 2.0
);
if width == 0.0 {
return; return;
} }
let mut rect = ui.available_rect_before_wrap();
let width = f32::min(available_width, Root::SIDE_PANEL_WIDTH * 2.0);
rect.set_width(width); rect.set_width(width);
// Draw step content. // Draw step content.
@ -267,7 +263,7 @@ impl WalletCreation {
match step { match step {
Step::EnterMnemonic => self.mnemonic_setup.ui(ui, frame, cb), Step::EnterMnemonic => self.mnemonic_setup.ui(ui, frame, cb),
Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, frame, cb), Step::ConfirmMnemonic => self.mnemonic_setup.confirm_ui(ui, frame, cb),
Step::SetupConnection => self.network_setup.ui(ui, frame, cb) Step::SetupConnection => self.network_setup.create_ui(ui, frame, cb)
} }
} }
} }