Merge pull request #2558 from martijn00/align-presenters
Align view presenters, registration and remove modal host
This commit is contained in:
Коммит
0107cb305a
|
@ -63,7 +63,7 @@ namespace MvvmCross.Forms.iOS
|
|||
|
||||
protected abstract MvxFormsApplication CreateFormsApplication();
|
||||
|
||||
protected override IMvxMacViewPresenter CreatePresenter()
|
||||
protected override IMvxMacViewPresenter CreateViewPresenter()
|
||||
{
|
||||
var presenter = new MvxFormsMacViewPresenter(ApplicationDelegate, FormsApplication);
|
||||
Mvx.RegisterSingleton<IMvxFormsViewPresenter>(presenter);
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MvvmCross.Forms.iOS
|
|||
|
||||
protected abstract MvxFormsApplication CreateFormsApplication();
|
||||
|
||||
protected override IMvxIosViewPresenter CreatePresenter()
|
||||
protected override IMvxIosViewPresenter CreateViewPresenter()
|
||||
{
|
||||
var presenter = new MvxFormsIosViewPresenter(ApplicationDelegate, Window, FormsApplication);
|
||||
Mvx.RegisterSingleton<IMvxFormsViewPresenter>(presenter);
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace MvvmCross.Forms.iOS.Presenters
|
|||
public virtual bool ClosePlatformViews()
|
||||
{
|
||||
CloseMasterNavigationController();
|
||||
CleanupModalViewControllers();
|
||||
CloseModalViewControllers();
|
||||
CloseTabBarViewController();
|
||||
CloseSplitViewController();
|
||||
return true;
|
||||
|
|
|
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Foundation;
|
||||
using MessageUI;
|
||||
using MvvmCross.iOS.Support.Views;
|
||||
using MvvmCross.Platform;
|
||||
using MvvmCross.Platform.Exceptions;
|
||||
using MvvmCross.Platform.iOS.Platform;
|
||||
|
@ -23,12 +24,10 @@ namespace MvvmCross.Plugins.Email.iOS
|
|||
: MvxIosTask
|
||||
, IMvxComposeEmailTaskEx
|
||||
{
|
||||
private readonly IMvxIosModalHost _modalHost;
|
||||
private MFMailComposeViewController _mail;
|
||||
|
||||
public MvxComposeEmailTask()
|
||||
{
|
||||
_modalHost = Mvx.Resolve<IMvxIosModalHost>();
|
||||
}
|
||||
|
||||
public void ComposeEmail(string to, string cc = null, string subject = null, string body = null,
|
||||
|
@ -69,7 +68,7 @@ namespace MvvmCross.Plugins.Email.iOS
|
|||
}
|
||||
_mail.Finished += HandleMailFinished;
|
||||
|
||||
_modalHost.PresentModalViewController(_mail, true);
|
||||
UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_mail, true, null);
|
||||
}
|
||||
|
||||
public bool CanSendEmail => MFMailComposeViewController.CanSendMail;
|
||||
|
@ -84,8 +83,9 @@ namespace MvvmCross.Plugins.Email.iOS
|
|||
throw new ArgumentException("sender");
|
||||
}
|
||||
|
||||
_mail.Finished -= HandleMailFinished;
|
||||
uiViewController.DismissViewController(true, () => { });
|
||||
_modalHost.NativeModalViewControllerDisappearedOnItsOwn();
|
||||
_mail = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ using System.Runtime.InteropServices;
|
|||
using System.Threading.Tasks;
|
||||
using CoreGraphics;
|
||||
using Foundation;
|
||||
using MvvmCross.iOS.Support.Views;
|
||||
using MvvmCross.Platform;
|
||||
using MvvmCross.Platform.iOS.Platform;
|
||||
using MvvmCross.Platform.iOS.Views;
|
||||
|
@ -24,7 +25,6 @@ namespace MvvmCross.Plugins.PictureChooser.iOS
|
|||
: MvxIosTask, IMvxPictureChooserTask
|
||||
{
|
||||
private readonly UIImagePickerController _picker;
|
||||
private readonly IMvxIosModalHost _modalHost;
|
||||
private bool _currentlyActive;
|
||||
private int _maxPixelDimension;
|
||||
private int _percentQuality;
|
||||
|
@ -33,7 +33,6 @@ namespace MvvmCross.Plugins.PictureChooser.iOS
|
|||
|
||||
public MvxImagePickerTask()
|
||||
{
|
||||
_modalHost = Mvx.Resolve<IMvxIosModalHost>();
|
||||
_picker = new UIImagePickerController
|
||||
{
|
||||
//CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo,
|
||||
|
@ -91,7 +90,7 @@ namespace MvvmCross.Plugins.PictureChooser.iOS
|
|||
_pictureAvailable = pictureAvailable;
|
||||
_assumeCancelled = assumeCancelled;
|
||||
|
||||
_modalHost.PresentModalViewController(_picker, true);
|
||||
UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_picker, true, null);
|
||||
}
|
||||
|
||||
private void HandleImagePick(UIImage image, string name)
|
||||
|
@ -120,7 +119,6 @@ namespace MvvmCross.Plugins.PictureChooser.iOS
|
|||
}
|
||||
|
||||
_picker.DismissViewController(true, () => { });
|
||||
_modalHost.NativeModalViewControllerDisappearedOnItsOwn();
|
||||
}
|
||||
|
||||
private void Picker_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
|
||||
|
@ -141,8 +139,7 @@ namespace MvvmCross.Plugins.PictureChooser.iOS
|
|||
{
|
||||
ClearCurrentlyActive();
|
||||
_assumeCancelled?.Invoke();
|
||||
_picker.DismissViewController(true, () => { });
|
||||
_modalHost.NativeModalViewControllerDisappearedOnItsOwn();
|
||||
_picker.DismissViewController(true, () => { });
|
||||
}
|
||||
|
||||
private void SetCurrentlyActive()
|
||||
|
|
|
@ -9,7 +9,9 @@ using Foundation;
|
|||
using MvvmCross.Platform;
|
||||
using MvvmCross.Platform.iOS.Platform;
|
||||
using MvvmCross.Platform.iOS.Views;
|
||||
using MvvmCross.iOS.Support.Views;
|
||||
using Twitter;
|
||||
using UIKit;
|
||||
|
||||
namespace MvvmCross.Plugins.Share.iOS
|
||||
{
|
||||
|
@ -17,12 +19,10 @@ namespace MvvmCross.Plugins.Share.iOS
|
|||
public class MvxShareTask
|
||||
: MvxIosTask, IMvxShareTask
|
||||
{
|
||||
private readonly IMvxIosModalHost _modalHost;
|
||||
private TWTweetComposeViewController _tweet;
|
||||
|
||||
public MvxShareTask()
|
||||
{
|
||||
_modalHost = Mvx.Resolve<IMvxIosModalHost>();
|
||||
}
|
||||
|
||||
public void ShareShort(string message)
|
||||
|
@ -33,7 +33,8 @@ namespace MvvmCross.Plugins.Share.iOS
|
|||
_tweet = new TWTweetComposeViewController();
|
||||
_tweet.SetInitialText(message);
|
||||
_tweet.CompletionHandler = TWTweetComposeHandler;
|
||||
_modalHost.PresentModalViewController(_tweet, true);
|
||||
|
||||
UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_tweet, true, null);
|
||||
}
|
||||
|
||||
public void ShareLink(string title, string message, string link)
|
||||
|
@ -45,12 +46,13 @@ namespace MvvmCross.Plugins.Share.iOS
|
|||
_tweet.SetInitialText(title + " " + message);
|
||||
_tweet.AddUrl(new NSUrl(link));
|
||||
_tweet.CompletionHandler = TWTweetComposeHandler;
|
||||
_modalHost.PresentModalViewController(_tweet, true);
|
||||
|
||||
UIApplication.SharedApplication.KeyWindow.GetTopModalHostViewController().PresentViewController(_tweet, true, null);
|
||||
}
|
||||
|
||||
private void TWTweetComposeHandler(TWTweetComposeViewControllerResult result)
|
||||
{
|
||||
_modalHost.NativeModalViewControllerDisappearedOnItsOwn();
|
||||
_tweet.DismissViewController(true, () => { });
|
||||
_tweet = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using MvvmCross.Core.ViewModels;
|
||||
using MvvmCross.Core.ViewModels;
|
||||
using MvvmCross.Core.Views;
|
||||
using MvvmCross.iOS.Support.XamarinSidebar.Extensions;
|
||||
using MvvmCross.iOS.Support.XamarinSidebar.Views;
|
||||
|
@ -152,7 +152,7 @@ namespace MvvmCross.iOS.Support.XamarinSidebar
|
|||
|
||||
Mvx.RegisterSingleton<IMvxSidebarViewController>(SideBarViewController);
|
||||
|
||||
CleanupModalViewControllers();
|
||||
CloseModalViewControllers();
|
||||
CloseTabBarViewController();
|
||||
CloseSplitViewController();
|
||||
CloseMasterNavigationController();
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace MvvmCross.Droid.Platform
|
|||
: MvxSetup, IMvxAndroidGlobals
|
||||
{
|
||||
private readonly Context _applicationContext;
|
||||
private IMvxAndroidViewPresenter _presenter;
|
||||
|
||||
protected MvxAndroidSetup(Context applicationContext)
|
||||
{
|
||||
|
@ -62,6 +63,7 @@ namespace MvvmCross.Droid.Platform
|
|||
{
|
||||
InitializeLifetimeMonitor();
|
||||
InitializeAndroidCurrentTopActivity();
|
||||
RegisterPresenter();
|
||||
|
||||
Mvx.RegisterSingleton<IMvxAndroidGlobals>(this);
|
||||
|
||||
|
@ -74,6 +76,7 @@ namespace MvvmCross.Droid.Platform
|
|||
|
||||
var viewModelMultiTemporaryCache = new MvxMultipleViewModelCache();
|
||||
Mvx.RegisterSingleton<IMvxMultipleViewModelCache>(viewModelMultiTemporaryCache);
|
||||
base.InitializePlatformServices();
|
||||
}
|
||||
|
||||
protected virtual void InitializeAndroidCurrentTopActivity()
|
||||
|
@ -132,6 +135,15 @@ namespace MvvmCross.Droid.Platform
|
|||
return viewsContainer;
|
||||
}
|
||||
|
||||
protected IMvxAndroidViewPresenter Presenter
|
||||
{
|
||||
get
|
||||
{
|
||||
_presenter = _presenter ?? CreateViewPresenter();
|
||||
return _presenter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IMvxAndroidViewPresenter CreateViewPresenter()
|
||||
{
|
||||
return new MvxAndroidViewPresenter(AndroidViewAssemblies);
|
||||
|
@ -139,9 +151,14 @@ namespace MvvmCross.Droid.Platform
|
|||
|
||||
protected override IMvxViewDispatcher CreateViewDispatcher()
|
||||
{
|
||||
var presenter = CreateViewPresenter();
|
||||
return new MvxAndroidViewDispatcher(Presenter);
|
||||
}
|
||||
|
||||
protected virtual void RegisterPresenter()
|
||||
{
|
||||
var presenter = Presenter;
|
||||
Mvx.RegisterSingleton(presenter);
|
||||
return new MvxAndroidViewDispatcher(presenter);
|
||||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
|
||||
}
|
||||
|
||||
protected override void InitializeLastChance()
|
||||
|
|
|
@ -90,6 +90,7 @@ namespace MvvmCross.Mac.Platform
|
|||
{
|
||||
RegisterPresenter();
|
||||
RegisterLifetime();
|
||||
base.InitializePlatformServices();
|
||||
}
|
||||
|
||||
protected virtual void RegisterLifetime()
|
||||
|
@ -101,12 +102,12 @@ namespace MvvmCross.Mac.Platform
|
|||
{
|
||||
get
|
||||
{
|
||||
_presenter = _presenter ?? CreatePresenter();
|
||||
_presenter = _presenter ?? CreateViewPresenter();
|
||||
return _presenter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IMvxMacViewPresenter CreatePresenter()
|
||||
protected virtual IMvxMacViewPresenter CreateViewPresenter()
|
||||
{
|
||||
return new MvxMacViewPresenter(_applicationDelegate);
|
||||
}
|
||||
|
@ -115,6 +116,7 @@ namespace MvvmCross.Mac.Platform
|
|||
{
|
||||
var presenter = this.Presenter;
|
||||
Mvx.RegisterSingleton(presenter);
|
||||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
|
||||
}
|
||||
|
||||
protected override void InitializeLastChance()
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// IMvxTvosModalHost.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
//
|
||||
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
|
||||
|
||||
using UIKit;
|
||||
|
||||
namespace MvvmCross.Platform.tvOS.Views
|
||||
{
|
||||
public interface IMvxTvosModalHost
|
||||
{
|
||||
bool PresentModalViewController(UIViewController controller, bool animated);
|
||||
|
||||
void NativeModalViewControllerDisappearedOnItsOwn();
|
||||
}
|
||||
}
|
|
@ -85,6 +85,7 @@ namespace MvvmCross.tvOS.Platform
|
|||
RegisterPlatformProperties();
|
||||
RegisterPresenter();
|
||||
RegisterLifetime();
|
||||
base.InitializePlatformServices();
|
||||
}
|
||||
|
||||
protected virtual void RegisterPlatformProperties()
|
||||
|
@ -106,12 +107,12 @@ namespace MvvmCross.tvOS.Platform
|
|||
{
|
||||
get
|
||||
{
|
||||
_presenter = _presenter ?? CreatePresenter();
|
||||
_presenter = _presenter ?? CreateViewPresenter();
|
||||
return _presenter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IMvxTvosViewPresenter CreatePresenter()
|
||||
protected virtual IMvxTvosViewPresenter CreateViewPresenter()
|
||||
{
|
||||
return new MvxTvosViewPresenter(_applicationDelegate, _window);
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ namespace MvvmCross.tvOS.Platform
|
|||
{
|
||||
var presenter = Presenter;
|
||||
Mvx.RegisterSingleton(presenter);
|
||||
Mvx.RegisterSingleton<IMvxTvosModalHost>(presenter);
|
||||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
|
||||
}
|
||||
|
||||
protected override void InitializeLastChance()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// IMvxTvosViewPresenter.cs
|
||||
// IMvxTvosViewPresenter.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
|
@ -13,7 +13,6 @@ namespace MvvmCross.tvOS.Views.Presenters
|
|||
public interface IMvxTvosViewPresenter
|
||||
: IMvxViewPresenter
|
||||
, IMvxCanCreateTvosView
|
||||
, IMvxTvosModalHost
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace MvvmCross.Uwp.Platform
|
|||
{
|
||||
private readonly IMvxWindowsFrame _rootFrame;
|
||||
private readonly string _suspensionManagerSessionStateKey;
|
||||
private IMvxWindowsViewPresenter _presenter;
|
||||
|
||||
protected MvxWindowsSetup(Frame rootFrame, string suspensionManagerSessionStateKey = null)
|
||||
: this(new MvxWrappedFrame(rootFrame))
|
||||
|
@ -47,6 +48,7 @@ namespace MvvmCross.Uwp.Platform
|
|||
protected override void InitializePlatformServices()
|
||||
{
|
||||
InitializeSuspensionManager();
|
||||
RegisterPresenter();
|
||||
base.InitializePlatformServices();
|
||||
}
|
||||
|
||||
|
@ -89,6 +91,15 @@ namespace MvvmCross.Uwp.Platform
|
|||
{
|
||||
return CreateViewDispatcher(_rootFrame);
|
||||
}
|
||||
|
||||
protected IMvxWindowsViewPresenter Presenter
|
||||
{
|
||||
get
|
||||
{
|
||||
_presenter = _presenter ?? CreateViewPresenter(_rootFrame);
|
||||
return _presenter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
|
||||
{
|
||||
|
@ -97,8 +108,14 @@ namespace MvvmCross.Uwp.Platform
|
|||
|
||||
protected virtual MvxWindowsViewDispatcher CreateViewDispatcher(IMvxWindowsFrame rootFrame)
|
||||
{
|
||||
var presenter = CreateViewPresenter(_rootFrame);
|
||||
return new MvxWindowsViewDispatcher(presenter, rootFrame);
|
||||
return new MvxWindowsViewDispatcher(Presenter, rootFrame);
|
||||
}
|
||||
|
||||
protected virtual void RegisterPresenter()
|
||||
{
|
||||
var presenter = Presenter;
|
||||
Mvx.RegisterSingleton(presenter);
|
||||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
|
||||
}
|
||||
|
||||
protected override void InitializeLastChance()
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace MvvmCross.Wpf.Platform
|
|||
: MvxSetup
|
||||
{
|
||||
private readonly Dispatcher _uiThreadDispatcher;
|
||||
private readonly ContentControl _root;
|
||||
private IMvxWpfViewPresenter _presenter;
|
||||
|
||||
protected MvxWpfSetup(Dispatcher uiThreadDispatcher, IMvxWpfViewPresenter presenter)
|
||||
|
@ -33,7 +34,13 @@ namespace MvvmCross.Wpf.Platform
|
|||
protected MvxWpfSetup(Dispatcher uiThreadDispatcher, ContentControl root)
|
||||
{
|
||||
_uiThreadDispatcher = uiThreadDispatcher;
|
||||
_presenter = CreateViewPresenter(root);
|
||||
_root = root;
|
||||
}
|
||||
|
||||
protected override void InitializePlatformServices()
|
||||
{
|
||||
RegisterPresenter();
|
||||
base.InitializePlatformServices();
|
||||
}
|
||||
|
||||
protected sealed override IMvxViewsContainer CreateViewsContainer()
|
||||
|
@ -48,6 +55,15 @@ namespace MvvmCross.Wpf.Platform
|
|||
return new MvxWpfViewsContainer();
|
||||
}
|
||||
|
||||
protected IMvxWpfViewPresenter Presenter
|
||||
{
|
||||
get
|
||||
{
|
||||
_presenter = _presenter ?? CreateViewPresenter(_root);
|
||||
return _presenter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IMvxWpfViewPresenter CreateViewPresenter(ContentControl root)
|
||||
{
|
||||
return new MvxWpfViewPresenter(root);
|
||||
|
@ -55,7 +71,14 @@ namespace MvvmCross.Wpf.Platform
|
|||
|
||||
protected override IMvxViewDispatcher CreateViewDispatcher()
|
||||
{
|
||||
return new MvxWpfViewDispatcher(_uiThreadDispatcher, _presenter);
|
||||
return new MvxWpfViewDispatcher(_uiThreadDispatcher, Presenter);
|
||||
}
|
||||
|
||||
protected virtual void RegisterPresenter()
|
||||
{
|
||||
var presenter = Presenter;
|
||||
Mvx.RegisterSingleton(presenter);
|
||||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
|
||||
}
|
||||
|
||||
protected override IMvxPluginManager CreatePluginManager()
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// IMvxIosModalHost.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
//
|
||||
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
|
||||
|
||||
using UIKit;
|
||||
|
||||
namespace MvvmCross.Platform.iOS.Views
|
||||
{
|
||||
public interface IMvxIosModalHost
|
||||
{
|
||||
bool PresentModalViewController(UIViewController controller, bool animated);
|
||||
|
||||
void NativeModalViewControllerDisappearedOnItsOwn();
|
||||
}
|
||||
}
|
|
@ -85,6 +85,7 @@ namespace MvvmCross.iOS.Platform
|
|||
RegisterPlatformProperties();
|
||||
RegisterPresenter();
|
||||
RegisterLifetime();
|
||||
base.InitializePlatformServices();
|
||||
}
|
||||
|
||||
protected virtual void RegisterPlatformProperties()
|
||||
|
@ -106,12 +107,12 @@ namespace MvvmCross.iOS.Platform
|
|||
{
|
||||
get
|
||||
{
|
||||
_presenter = _presenter ?? CreatePresenter();
|
||||
_presenter = _presenter ?? CreateViewPresenter();
|
||||
return _presenter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IMvxIosViewPresenter CreatePresenter()
|
||||
protected virtual IMvxIosViewPresenter CreateViewPresenter()
|
||||
{
|
||||
return new MvxIosViewPresenter(_applicationDelegate, _window);
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ namespace MvvmCross.iOS.Platform
|
|||
{
|
||||
var presenter = Presenter;
|
||||
Mvx.RegisterSingleton(presenter);
|
||||
Mvx.RegisterSingleton<IMvxIosModalHost>(presenter);
|
||||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
|
||||
}
|
||||
|
||||
protected override void InitializeLastChance()
|
||||
|
|
|
@ -176,5 +176,17 @@ namespace MvvmCross.iOS.Support.Views
|
|||
|
||||
return descendantViews;
|
||||
}
|
||||
|
||||
public static UIViewController GetTopModalHostViewController(this UIWindow window)
|
||||
{
|
||||
var vc = window.RootViewController;
|
||||
do {
|
||||
if (vc.PresentedViewController != null)
|
||||
vc = vc.PresentedViewController;
|
||||
|
||||
} while (vc.PresentedViewController != null);
|
||||
|
||||
return vc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// IMvxIosViewPresenter.cs
|
||||
// IMvxIosViewPresenter.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
|
@ -6,11 +6,11 @@
|
|||
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
|
||||
|
||||
using MvvmCross.Core.Views;
|
||||
using MvvmCross.Platform.iOS.Views;
|
||||
using UIKit;
|
||||
|
||||
namespace MvvmCross.iOS.Views.Presenters
|
||||
{
|
||||
public interface IMvxIosViewPresenter : IMvxViewPresenter, IMvxCanCreateIosView, IMvxIosModalHost
|
||||
{
|
||||
public interface IMvxIosViewPresenter : IMvxViewPresenter, IMvxCanCreateIosView
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
// set root
|
||||
SetupWindowRootNavigation(viewController, attribute);
|
||||
|
||||
CleanupModalViewControllers();
|
||||
CloseModalViewControllers();
|
||||
CloseSplitViewController();
|
||||
|
||||
return;
|
||||
|
@ -187,7 +187,7 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
// set root
|
||||
SetupWindowRootNavigation(viewController, attribute);
|
||||
|
||||
CleanupModalViewControllers();
|
||||
CloseModalViewControllers();
|
||||
CloseTabBarViewController();
|
||||
|
||||
return;
|
||||
|
@ -196,7 +196,7 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
// set root initiating stack navigation or just a plain controller
|
||||
SetupWindowRootNavigation(viewController, attribute);
|
||||
|
||||
CleanupModalViewControllers();
|
||||
CloseModalViewControllers();
|
||||
CloseTabBarViewController();
|
||||
CloseSplitViewController();
|
||||
}
|
||||
|
@ -325,12 +325,6 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
SplitViewController.ShowDetailView(viewController, attribute.WrapInNavigationController);
|
||||
}
|
||||
|
||||
public virtual bool PresentModalViewController(UIViewController viewController, bool animated)
|
||||
{
|
||||
ShowModalViewController(viewController, new MvxModalPresentationAttribute { Animated = animated }, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void Close(IMvxViewModel viewModel)
|
||||
|
@ -474,12 +468,7 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
TabBarViewController = tabBarController;
|
||||
}
|
||||
|
||||
public virtual void NativeModalViewControllerDisappearedOnItsOwn()
|
||||
{
|
||||
CloseModalViewController(ModalViewControllers.Last());
|
||||
}
|
||||
|
||||
protected void CloseMasterNavigationController()
|
||||
protected virtual void CloseMasterNavigationController()
|
||||
{
|
||||
if (MasterNavigationController == null)
|
||||
return;
|
||||
|
@ -492,22 +481,22 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
MasterNavigationController = null;
|
||||
}
|
||||
|
||||
protected virtual void CloseModalViewController(UIViewController modalController)
|
||||
public virtual void CloseModalViewController(UIViewController viewController)
|
||||
{
|
||||
if (modalController == null)
|
||||
if (viewController == null)
|
||||
return;
|
||||
|
||||
if (modalController is UINavigationController modalNavController)
|
||||
if (viewController is UINavigationController modalNavController)
|
||||
{
|
||||
foreach (var item in modalNavController.ViewControllers)
|
||||
item.DidMoveToParentViewController(null);
|
||||
}
|
||||
|
||||
modalController.DismissViewController(true, null);
|
||||
ModalViewControllers.Remove(modalController);
|
||||
viewController.DismissViewController(true, null);
|
||||
ModalViewControllers.Remove(viewController);
|
||||
}
|
||||
|
||||
protected void CleanupModalViewControllers()
|
||||
public virtual void CloseModalViewControllers()
|
||||
{
|
||||
while (ModalViewControllers.Any())
|
||||
{
|
||||
|
@ -515,7 +504,7 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
}
|
||||
}
|
||||
|
||||
public void CloseTabBarViewController()
|
||||
public virtual void CloseTabBarViewController()
|
||||
{
|
||||
if (TabBarViewController == null)
|
||||
return;
|
||||
|
@ -529,7 +518,7 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
TabBarViewController = null;
|
||||
}
|
||||
|
||||
protected void CloseSplitViewController()
|
||||
protected virtual void CloseSplitViewController()
|
||||
{
|
||||
if (SplitViewController == null)
|
||||
return;
|
||||
|
@ -549,6 +538,11 @@ namespace MvvmCross.iOS.Views.Presenters
|
|||
v.RemoveFromSuperview();
|
||||
}
|
||||
|
||||
public virtual void ShowModalViewController(UIViewController viewController, bool animated)
|
||||
{
|
||||
ShowModalViewController(viewController, new MvxModalPresentationAttribute { Animated = animated }, null);
|
||||
}
|
||||
|
||||
protected virtual void SetWindowRootViewController(UIViewController controller, MvxRootPresentationAttribute attribute = null)
|
||||
{
|
||||
RemoveWindowSubviews();
|
||||
|
|
Загрузка…
Ссылка в новой задаче