Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Replace application main page with animation #2957

Closed
mu-dawood opened this issue Jun 6, 2018 · 18 comments
Closed

Replace application main page with animation #2957

mu-dawood opened this issue Jun 6, 2018 · 18 comments

Comments

@mu-dawood
Copy link

Description

i know that we can change main page using this
App.Current.MainPage
but is it possible to change main page with some animation

@adrianknight89
Copy link
Contributor

Can you expand on what kind of animation you're wanting? Would the new MainPage animate onto the existing one? Would it reveal itself atop a blank background (changing opacity from 0 to 1)? Etc.

I'd also question the need for switching main pages. Whatever you're trying to do can possibly be done with modal pages (e.g. use login page modally without animation while the TabbedPage is the MainPage).

@mu-dawood
Copy link
Author

mu-dawood commented Jun 17, 2018

i have 2 application cycles
1- navigation page that will push security pages(select user type,login, forgot password,verify password, registration page)
2- main cycle that is master details page and many other pages

the two cycles need navigation bar so i can't use push modal without doing some extra code to handle navigation

i tried to use this method
capture

i have 2 cases

  • the application is not in background and started
    • the animation is slow and uggly
  • the application is in background and started
    • the animation is good

i used SizeChanged or LayoutChanged events because its occurs after Appearing event
this video is showing two cases
https://1drv.ms/v/s!Aqxak4UqqG0AbyK1xXk7Iu798tU

the marks shows when i replaced main page

@mu-dawood
Copy link
Author

mu-dawood commented Jun 17, 2018

i just want to replace main page with any kind of animation to make the app have a good look in the case i want to replace it

@mu-dawood
Copy link
Author

mu-dawood commented Jun 17, 2018

this video is for same app but with 1000 milliseconds animation
https://drive.google.com/file/d/1iJJ6-1Lpl0mEQT9D6icohJLnpKKKHybP/view

@Mikilll94
Copy link

I agree that this feature would be very useful because it is common in apps to separate login flow from normal application flow.

@AndreiMisiukevich
Copy link
Contributor

AndreiMisiukevich commented Oct 17, 2018

var oldPage = new ContentPage();
var navPage = new NavigationPage(oldPage);
...
await navPage.PushAsync(new ContentPage()); //push new page
navPage.RemovePage(oldPage); //remove old from navigation stack

@programmation
Copy link

programmation commented Oct 17, 2018

@Mikilll94 I use a ControlTemplate for this, with the login view as one of its subviews and the main view as the ContentPresenter. I use a Behavior to animate them visible/invisible depending on the user's authentication status.

@Mikilll94
Copy link

@programmation This approach becomes problematic if your app does not have a homepage (i.e. user after launching an app can see many different views)

@AndreiMisiukevich
Copy link
Contributor

@Mikilll94 why don't you want to use NavigationPage ?

@Mikilll94
Copy link

Because I want to have two separate navigation stacks: one for login flow and second for normal flow.

@GalaxiaGuy
Copy link
Contributor

GalaxiaGuy commented Oct 17, 2018

@Mikilll94 It's not perfect, but when I've needed to do this, I've used a NavigationPage and then after pushing, removed the previous page(s) from the stack.

@AndreiMisiukevich
Copy link
Contributor

@mu-dawood
Copy link
Author

in my case my first page is navigation page that have 5 pages until login
the second one is master details page that have a navigation page as its details page

@programmation
Copy link

@programmation This approach becomes problematic if your app does not have a homepage (i.e. user after launching an app can see many different views)

@Mikilll94 I solve that issue by making each of the potential startup views have the same ControlTemplate. In fact all pages in the app that require authentication for access have the "authentication" ControlTemplate. Then I have a master switch inside the app that toggles true or false to match the user's authenticated status. The ControlTemplate shows the content if the user is authenticated, and the login page if not. It's actually a lot simpler than I make it sound here, and with Behaviors I can animate transitions between the states.

@abdu292
Copy link

abdu292 commented Apr 10, 2019

Really looking for this as well!

@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Oct 7, 2019
@newky2k
Copy link

newky2k commented Oct 10, 2019

@samhouts samhouts added proposal-open and removed inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! labels Feb 6, 2020
@ChocoWhoopies
Copy link

ChocoWhoopies commented Feb 7, 2020

Hello,
I'm not sure if this is a direct answer but try to see how i solved my similar problem:

Navigation.InsertPageBefore(new Page(), this); //Insert page ontop of current Main Page
Navigation.RemovePage(Navigation.NavigationStack.First()); //Remove Main Page (root page)
Navigation.PopAsync(); //Pop off current page, there will be an animation here to the new Main Page (root page)

@samhouts
Copy link
Member

Duplicate of #6033

@samhouts samhouts marked this as a duplicate of #6033 Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests