Skip to content

Instantly share code, notes, and snippets.

@gshackles
Last active April 6, 2017 19:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gshackles/5735595 to your computer and use it in GitHub Desktop.
Save gshackles/5735595 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