With MvvmCross, if I want a button to open a new screen, I wire up the command handler and use ShowViewModel, like this:
ShowViewModel<InfoViewModel>();
Is there anyway to plug in custom animations, which are very platform specific, and still use ShowViewModel in the core? If I were doing this in a Droid project, it would look like this:
OverridePendingTransition(Resource.Animation.push_up_in, Resource.Animation.push_up_out);
So basically I want a way to hook into the MvvmCross Activity creation from the Droid project.
Finally managed to do it!
In the Setup override the CreateViewPresenter()
public class Setup : MvxAndroidSetup
{
...
...
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
return new CustomPresenter();
}
}
and created a CustomPresenter class to do the animation:
public class CustomPresenter : MvxAndroidViewPresenter
{
protected override void Show(Intent intent)
{
Activity.StartActivity(intent);
Activity.OverridePendingTransition(Resource.Animator.slide_in_left, Resource.Animator.slide_out_left);
}
}
Solved by calling the command from the MvxActivity in the UI.
var infoBtn = FindViewById<RelativeLayout>(Resource.Id.infobtn);
infoBtn.Click += delegate(object sender, EventArgs args)
{
((MainMenuViewModel)ViewModel).InfoCommand.Execute(null);
OverridePendingTransition(Resource.Animation.push_up_in, Resource.Animation.push_up_out);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With