VaniaP
VaniaP

Reputation: 63

CustomPresenter errors on migration from 4.4 to 5.7 in MVVMCross

Hello stackoverflowers, I am working on a project that is built using MVVMCross and Xamarin for iOS and Android. I have found out that the project uses a quite old version of MVVMCross (4.4.0) and I am trying to bring it up to the current one (6.4). I thought it's a good idea to first upgrade to 5.7 and on a later stage, when I have the navigation switched to the new form etc, I will bump up to 6++. I have sucessfully run the android version to 5.7, however, the iOS version uses a customPresenter, that I don't quite know how to transform to the new Presenter introduced in 5.1. I think my custom presenter is based on https://github.com/MvvmCross/MvvmCross-Samples/tree/master/XPlatformMenus/XPlatformMenusTabs.iOS which hasn't been updated in a while.

In my MvxTabPresenter that subclasses MvxIosViewPresenter, the show function is no longer overridable. In addition IMvxModalIosView doesnt seem to exist anymore.

public override void Show(IMvxIosView view)
        {
            if (view is IMvxModalIosView)
            {
                if (this._currentModalViewController != null)
                {
                    return;
                }

                var currentModalViewController = view as MvxViewController;
                this._currentModalViewController = currentModalViewController;
                currentModalViewController.ModalPresentationStyle = UIModalPresentationStyle.Popover;
                CurrentTopViewController.AddChildViewController(currentModalViewController);
                currentModalViewController.View.Frame = CurrentTopViewController.View.Bounds.Inset(10, 10);
                currentModalViewController.View.Alpha = 0;
                CurrentTopViewController.View.Add(currentModalViewController.View);
                currentModalViewController.DidMoveToParentViewController(CurrentTopViewController);

                UIView.Animate(0.25, () =>
                {
                    currentModalViewController.View.Alpha = 1;
                });


                //this.PresentModalViewController(currentModalViewController, true);
                return;
            }

            if (view is HomeView)
            {
                if (this.CurrentTopViewController is MvxTabBarViewController)
                {
                    TabBarPresenter.SelectedIndex = 0;
                    return;
                } 


 public override void CloseModalViewController()
        {
            if (this._currentModalViewController != null)
            {
                this._currentModalViewController.DismissModalViewController(true);
                _currentModalViewController.WillMoveToParentViewController(null);
                _currentModalViewController.View.RemoveFromSuperview();
                _currentModalViewController.RemoveFromParentViewController();
                this._currentModalViewController = null;
                return;
            }

            base.CloseModalViewController();
        }

            }

Also this is no longer overridable from the superclass.

Any suggestions on how to approach this?

Kind regards, V

Upvotes: 0

Views: 154

Answers (1)

fmaccaroni
fmaccaroni

Reputation: 3916

As you may see in the MvxIosViewPresenter now the mvx attributes are registered with the action that should be called.

So, firstly you should inherit from MvxIosViewPresenter. Then, for modal you should override ShowModalViewController.

I suggest you to read the docs, the MvxIosViewPresenter and MvxAttributeViewPresenter files on the repo to check out how it works.

HIH

Upvotes: 1

Related Questions