Reputation: 2439
I want to code a splash screen which, after clicking in a presentation´s image start to do an animation (over the image) and, 5 seconds after, go to a Login page.
I tried to find the solution of it, but the answer use to be related with a specific plataform.
My idea is to code it over cross plataform.
Upvotes: 1
Views: 1289
Reputation: 2439
After researching, I found the solution coming from Xamarin offical page (animation´s samples) and another page (for the delay) I don´t remember the site...
I´m posting this question and answer because I think could be really interesting for the community.
Button startButton = new Button() { Image = "splashlogo.png", BackgroundColor = Xamarin.Forms.Color.Transparent, HorizontalOptions = Xamarin.Forms.LayoutOptions.Center, Scale = 3.5};
startButton.Clicked += async (object sender, EventArgs e) =>
{
var parentAnimation = new Animation();
var scaleUpAnimation = new Animation(v => startButton.Scale = v, 1, 2, Easing.SpringIn);
var rotateAnimation = new Animation(v => startButton.Rotation = v, 0, 360);
var scaleDownAnimation = new Animation(v => startButton.Scale = v, 2, 1, Easing.SpringOut);
parentAnimation.Add(0, 0.5, scaleUpAnimation);
parentAnimation.Add(0, 1, rotateAnimation);
parentAnimation.Add(0.5, 1, scaleDownAnimation);
parentAnimation.Commit(startButton, "ChildAnimations", 16, 4000, null);
await Task.Delay(5000);
await App.Current.MainPage.Navigation.PushModalAsync(new Login());
};
public static async Task Sleep(int ms)
{
await Task.Delay(ms);
}
Upvotes: 2