Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public abstract class ViewModelBase : MvxViewModel
{
protected void ClearStackAndShowViewModel<TViewModel>()
where TViewModel : ViewModelBase
{
var presentationBundle = new MvxBundle(new Dictionary<string, string> { { PresentationBundleFlagKeys.ClearStack, "" } });
ShowViewModel<TViewModel>(presentationBundle: presentationBundle);
}
}
public static class PresentationBundleFlagKeys
{
public const string ClearStack = "__CLEAR_STACK__";
}
public class SlidingMenuViewPresenter : MvxModalNavSupportTouchViewPresenter
{
public override void Show(MvxViewModelRequest request)
{
if (request.PresentationValues != null)
{
if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.ClearStack))
{
var nextViewController = (UIViewController)ViewCreator.CreateView(request);
if (MasterNavigationController.TopViewController.GetType() != nextViewController.GetType())
{
MasterNavigationController.PopToRootViewController(false);
MasterNavigationController.PushViewController(nextViewController, false);
}
return;
}
}
base.Show(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment