Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar menu doesn't get initialised for first root controller in 5.2 #2188

Closed
1 of 4 tasks
Oglan opened this issue Sep 14, 2017 · 2 comments · Fixed by #2314
Closed
1 of 4 tasks

Sidebar menu doesn't get initialised for first root controller in 5.2 #2188

Oglan opened this issue Sep 14, 2017 · 2 comments · Fixed by #2314
Assignees
Labels
p/ios iOS platform t/bug Bug type
Milestone

Comments

@Oglan
Copy link

Oglan commented Sep 14, 2017

Steps to reproduce

  1. Run MvvmCross.iOS.Support.XamarinSidebarSample.iOS project from main MvvmCross solution.

Expected behavior

Menu icon should be visible.
Left menu should appear if swiping from left side.

Actual behavior

There is no menu icon in the top left corner.
Menu is appearing if swiping from right side.

Configuration

Version: 5.2.0

Platform:

  • iOS
  • Android
  • WPF
  • UWP
@Oglan
Copy link
Author

Oglan commented Sep 14, 2017

Call stack for the first time presentation of the root controller with sidebar presentation attribute(MvxSidebarPresentation(MvxPanelEnum.Center, MvxPanelHintType.ResetRoot...)):

  1. MvxSidebarPresenter.ShowSidebarViewController
  2. MvxSidebarViewController.ctor
  3. ShowMenuButton extension from MvxSidebarPresenter.ShowPanelAndResetToRoot // left and right panels are nulls here, as result there is no information about icons yet
  4. MvxSidebarViewController.ViewDidLoad
  5. MvxSidebarViewController.SetupSideMenu // left and right panels are being initialised here

@Oglan
Copy link
Author

Oglan commented Sep 14, 2017

Workaround: call ShowMenuButton from ViewDidLoad of the first root view. For this we have to have access to SideBarViewController. It is accessible for derived ViewPresenters only.

// declare custom presenter
public class MyPresenter : MvxSidebarPresenter
{
    public MvxSidebarViewController SideBar => SideBarViewController as MvxSidebarViewController;
    public MyPresenter(IUIApplicationDelegate appDelegate, UIWindow window) : base(appDelegate, window)
    {
    }
}

// replace presenter in Setup.cs
protected override IMvxIosViewPresenter CreatePresenter()
{
    return new MyPresenter((MvxApplicationDelegate)ApplicationDelegate, Window);
}

// initialize menu from initial root view controller
public override void ViewDidLoad()
{
    // ...
    this.ShowMenuButton(((MyPresenter)Mvx.Resolve<IMvxIosViewPresenter>()).SideBar);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/ios iOS platform t/bug Bug type
Development

Successfully merging a pull request may close this issue.

4 participants