forked from martijn00/MvvmCross-Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigation from Mvx-Non Forms Activity to Forms Activity is available by ShowViewModel<..> now. Issue #49
- Loading branch information
Showing
15 changed files
with
250 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
MvvmCross.Forms.Presenter.Droid/MvxDroidFormsPagePresenter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using Android.Content; | ||
using MvvmCross.Core.ViewModels; | ||
using MvvmCross.Forms.Presenter.Core; | ||
using MvvmCross.Platform; | ||
using MvvmCross.Platform.Droid.Platform; | ||
using Newtonsoft.Json; | ||
|
||
namespace MvvmCross.Forms.Presenter.Droid | ||
{ | ||
public class MvxDroidFormsPagePresenter : MvxFormsPagePresenter | ||
{ | ||
private readonly Type _formsAppCompatActivityType; | ||
public static readonly string FirstNavigationRequestPackageExtraKey = "FirstNavigationRequestPackageKey"; | ||
|
||
|
||
public MvxDroidFormsPagePresenter(Type formsAppCompatActivityType) : base() | ||
{ | ||
_formsAppCompatActivityType = formsAppCompatActivityType; | ||
|
||
if (!typeof(MvxFormsAppCompatActivity).IsAssignableFrom(_formsAppCompatActivityType)) | ||
throw new InvalidOperationException($"Passed type should inherit from {nameof(MvxFormsAppCompatActivity)}"); | ||
} | ||
|
||
public MvxDroidFormsPagePresenter(Type formsAppCompatActivityType, Xamarin.Forms.Application mvxFormsApp) : base(mvxFormsApp) | ||
{ | ||
_formsAppCompatActivityType = formsAppCompatActivityType; | ||
|
||
if (!typeof(MvxFormsAppCompatActivity).IsAssignableFrom(_formsAppCompatActivityType)) | ||
throw new InvalidOperationException($"Passed type should inherit from {nameof(MvxFormsAppCompatActivity)}"); | ||
} | ||
|
||
protected override bool IsNativeFormPageActive() | ||
{ | ||
Type baseDroidFormPage = typeof(MvxFormsAppCompatActivity); | ||
Type currentActivityType = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity.GetType(); | ||
|
||
return baseDroidFormPage.IsAssignableFrom(currentActivityType); | ||
} | ||
|
||
protected override void NavigateToNativeFormPage(MvxViewModelRequest withViewModelRequest) | ||
{ | ||
var currentActivity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity; | ||
var requestText = JsonConvert.SerializeObject(withViewModelRequest); | ||
var intent = new Intent(currentActivity, _formsAppCompatActivityType); | ||
intent.PutExtra(FirstNavigationRequestPackageExtraKey, requestText); | ||
|
||
currentActivity.StartActivity(intent); | ||
} | ||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 16 additions & 8 deletions
24
...ss.Forms.Sample.Integration/IntegrationSample/IntegrationSample.Droid/FeedbackActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using Android.App; | ||
using Android.Content; | ||
using Android.Content.PM; | ||
using Android.OS; | ||
using Android.Runtime; | ||
using Android.Views; | ||
using Android.Widget; | ||
using IntegrationSample.ViewModels; | ||
using MvvmCross.Droid.Views; | ||
|
||
namespace IntegrationSample.Droid | ||
{ | ||
class FeedbackActivity | ||
[Activity(Label = "Feedback", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] | ||
public class FeedbackActivity : MvxActivity<FeedbackViewModel> | ||
{ | ||
public FeedbackActivity() | ||
{ | ||
|
||
} | ||
|
||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
base.OnCreate(bundle); | ||
|
||
SetContentView(Resource.Layout.FeedbackLayout); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 22 additions & 11 deletions
33
MvvmCross.Forms.Sample.Integration/IntegrationSample/IntegrationSample.Droid/Setup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Runtime; | ||
using Android.Views; | ||
using Android.Widget; | ||
using MvvmCross.Core.ViewModels; | ||
using MvvmCross.Core.Views; | ||
using MvvmCross.Droid.Platform; | ||
using MvvmCross.Droid.Views; | ||
using MvvmCross.Forms.Presenter.Core; | ||
using MvvmCross.Forms.Presenter.Droid; | ||
using MvvmCross.Platform; | ||
|
||
namespace IntegrationSample.Droid | ||
{ | ||
class Setup : MvxAndroidSetup | ||
public class Setup : MvxAndroidSetup | ||
{ | ||
public Setup(Context applicationContext) : base(applicationContext) | ||
{ | ||
} | ||
|
||
protected override IMvxApplication CreateApp() | ||
=> new IntegrationSampleMvxApp(); | ||
protected override IMvxAndroidViewPresenter CreateViewPresenter() | ||
{ | ||
var baseAndroidPresenter = base.CreateViewPresenter(); | ||
|
||
var presenter = new MvxDroidFormsPresenterProxy(baseAndroidPresenter, new MvxDroidFormsPagePresenter(typeof(MainActivity))); | ||
Mvx.RegisterSingleton<IMvxViewPresenter>(presenter); | ||
|
||
return presenter; | ||
} | ||
} | ||
} |
Oops, something went wrong.