Skip to content

Instantly share code, notes, and snippets.

@vackup
Forked from gshackles/gist:5735595
Created October 7, 2016 18:24
Show Gist options
  • Save vackup/1b35904812726c93117760ba65d72b63 to your computer and use it in GitHub Desktop.
Save vackup/1b35904812726c93117760ba65d72b63 to your computer and use it in GitHub Desktop.
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