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

Feature request: Broader fragment usage #2495

Closed
Qwin opened this issue Dec 29, 2017 · 1 comment
Closed

Feature request: Broader fragment usage #2495

Qwin opened this issue Dec 29, 2017 · 1 comment
Labels
p/android Android platform t/feature Feature request type
Milestone

Comments

@Qwin
Copy link

Qwin commented Dec 29, 2017

Couple of things I have noted out that are still missing from MvvmCross (Of course you could get it to work with some overrides or hacks etc)

  1. Nested Fragment + Activity Fragment. Using a fragment as nested fragment as well as an activity fragment is really hard (isn't supported out of the box). You can only specify 1 attribute above each fragment meaning you can only choose to make it a nested attribute or a activity host fragment. The presenter currently checks if its a nested fragment and otherwise just expects its an activity fragment. But fragments should be mobile and can be a nested fragment in one instance or an activity fragment in a different instance.

Solution:
We should think of a better way to use MvxFragmentPresentationAttribute where I can add multiple activity hosts and multiple fragment hosts. (just by adding multiple attributes really). And the way to recognize which to use is based off of who calls the navigate.

  1. Child nesting on multiple levels isn't supported. (when I have time I will work on this further, currently busy with work)

  2. Navigating to a fragment should be possible without it having a host activity. This will give more consistency with iOS as iOS you can use a nested view anywhere. Right now the navigation of the Android vs iOS differs.

Example:
CookieView(Fragment - Android, ViewController - iOS) - CookieViewModel

Navigation from JarViewModel to CookieViewModel will be as follows:

iOS: _navigationService.Navigate<CookieViewModel>(); //all fine works as expected

Android: _navigationService.Navigate<CookieViewModel>() // we can't do this as we cannot navigate to a fragment without specifying an activity host for it to live in. we are using the same fragment else where as a nested one, so we cannot convert it to an activity.

So for android we would need to create a dummy host : SingleFragmentView (type: MvxFragmentActivity) and then do something like:

#if __ANDROID__
_navigationService.Navigate<SingleFragmentViewModel>(somebundle)
#endif 

Now we need to also relay the bundle parameters as well as we want to send something over to the CookieViewModel.

Solution:
The solution is simple let's just make a simple Host Activity which hosts the fragment and relays whatever we add as parameters or presentation attributes. This way we have consistency with iOS and navigation would be seamlessly. If the user does specify a host activity we just dont create the Host Activity internally.
_navigationService.Navigate<CookieViewModel>()

Let me know what you guys think. Maybe I missed something in MvvmCross and some of my comments are invalid, please let me know.

@Cheesebaron Cheesebaron added t/feature Feature request type p/android Android platform labels Dec 29, 2017
@martijn00 martijn00 added this to the 6.0.0 milestone Mar 27, 2018
@martijn00
Copy link
Contributor

I think this is fixed in 6.0. We've done a lot of fixes for the presenters and one of them is to use the current Activity if no host is specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/android Android platform t/feature Feature request type
Development

No branches or pull requests

3 participants