Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to replace view with another of different size #622

Closed
hamboomger opened this issue Feb 4, 2018 · 5 comments
Closed

How to replace view with another of different size #622

hamboomger opened this issue Feb 4, 2018 · 5 comments

Comments

@hamboomger
Copy link

I have a LoginForm view with some fields and link "Sign up". When it pressed, I need to replace this view with another, RegistrationWizard view, which is about 2 times larger then LoginForm.
When I'm using replaceWith() function with transition effect, the window becomes larger first(without any animation, and this is an issue I want to address), and only after this begins the transition effect:

replaceWith(
    component = RegistrationWizard::class,
    centerOnScreen = true,
    sizeToScene = true,
    transition = ViewTransition.Metro(500.millis))

Is there any way to make this transition smoothly?

@edvin
Copy link
Owner

edvin commented Feb 4, 2018

There is no support for gradually increasing the window size, but you could let sizeToScene be false and resize in the onDock callback of RegistrationWizard.

@hamboomger
Copy link
Author

Thank you for fast response :)
Ok, I tried to solve it by closing the LoginForm, and then opening the RegistrationWizard view. I've tried this:

close()
find<RegistrationWizard>().openWindow()

When I run this inside the LoginForm view, the new window with registration appears correctly, but the previous view doesn't close.

@edvin
Copy link
Owner

edvin commented Feb 4, 2018

I just discovered a bug in UIComponent.close(). It didn't properly close top level windows. The fix has been committed, but the workaround is easy, just call currentStage?.close() instead. However, if you close as stage, it will also close any child stages, and calling openModal() without an owner parameter will make the new modal a child of the current, so calling currentStage?.close() would infact close the newly opened window and even exit the application unless Platform.explicitExit was set to false.

What you need to do to avoid this is simply pass null to the owner parameter. Here is a complete application showcasing this:

class MyApp : App(FirstView::class)

class FirstView : View("First View") {
    override val root = button("Go to View 2") {
        action {
            find<SecondView>().openModal(owner = null)
            currentStage?.close()
        }
    }
}

class SecondView : View("Second View") {
    override val root = label(title)
}

After 1.7.15 you can replace currentSage?.close() with just close().

@hamboomger
Copy link
Author

Ok, thank you!

@edvin
Copy link
Owner

edvin commented Feb 4, 2018

You're welcome, and thanks for reporting. Nice to have this bug squashed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants