So it’s official, FreshMvvm is now 1.0 and available in nuget.
Let’s take a look at some of the new features.
- Ability to use ViewModel naming instead of PageModel, thanks to this contribution by Olexandr Leuschenko
- Multiple Navigation Services
- Support for custom IOC containers
- Ability to Push a NavigationContainer
- It also handles async better thanks to Olexandr Leuschenko
Let’s take a look at some of the bigger features in the release.
Multiple Navigation Services
It’s always been possible to do any type of navigation in FreshMvvm, with custom or advanced scenarios were done by implementing a custom navigation service. Even with this ability people found it a little hard to do advanced navigation scenarios in FreshMvvm. After I reviewed all the support questions that came in for FreshMvvm I found that the basic issue people had was they wanted to be able to use our built in navigation containers multiple times, two primary examples are 1) within a master detail having a navigation stack in a master and another in the detail 2) The ability to push modally with a new navigation container. In order to support both these scenarios I concluded that the FreshMvvm required the ability to have named NavigationServices so that we could support multiple NavigationService’s.
Using multiple navigation containers
Below we’re running two navigation stacks, in a single MasterDetail.
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
varmasterDetailsMultiple=newMasterDetailPage();//generic master detail page
//we setup the first navigation container with ContactList
varcontactListPage=FreshPageModelResolver.ResolvePageModel<ContactListPageModel>();
contactListPage.Title=“Contact List”;
//we setup the first navigation container with name MasterPageArea
varmasterPageArea=newFreshNavigationContainer(contactListPage,“MasterPageArea”);
masterPageArea.Title=“Menu”;
masterDetailsMultiple.Master=masterPageArea;//set the first navigation container to the Master
//we setup the second navigation container with the QuoteList
varquoteListPage=FreshPageModelResolver.ResolvePageModel<QuoteListPageModel>();
quoteListPage.Title=“Quote List”;
//we setup the second navigation container with name DetailPageArea
vardetailPageArea=newFreshNavigationContainer(quoteListPage,“DetailPageArea”);
masterDetailsMultiple.Detail=detailPageArea;//set the second navigation container to the Detail
MainPage=masterDetailsMultiple;
|
PushModally with new navigation stack
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
//push a basic page Modally
varpage=FreshPageModelResolver.ResolvePageModel<MainMenuPageModel>();
varbasicNavContainer=newFreshNavigationContainer(page,“secondNavPage”);
awaitCoreMethods.PushNewNavigationServiceModal(basicNavContainer,newFreshBasePageModel[]{page.GetModel()});
//push a tabbed page Modally
vartabbedNavigation=newFreshTabbedNavigationContainer(“secondNavPage”);
tabbedNavigation.AddTab<ContactListPageModel>(“Contacts”,“contacts.png”,null);
tabbedNavigation.AddTab<QuoteListPageModel>(“Quotes”,“document.png”,null);
awaitCoreMethods.PushNewNavigationServiceModal(tabbedNavigation);
//push a master detail page Modally
varmasterDetailNav=newFreshMasterDetailNavigationContainer(“secondNavPage”);
masterDetailNav.Init(“Menu”,“Menu.png”);
masterDetailNav.AddPage<ContactListPageModel>(“Contacts”,null);
masterDetailNav.AddPage<QuoteListPageModel>(“Quotes”,null);
awaitCoreMethods.PushNewNavigationServiceModal(masterDetailNav);
|
Custom IOC Container
The second major request for FreshMvvm 1.0 was to allow custom IOC containers. In the case that your application already has a container that you want to leverage.
Using a custom IOC container is very simple in that you only need to implement a single interface.
C#
1
2
3
4
5
6
7
8
9
10
11
|
publicinterfaceIFreshIOC
{
objectResolve(Type resolveType);
voidRegister<RegisterType>(RegisterType instance)where RegisterType:class;
voidRegister<RegisterType>(RegisterType instance,stringname)where RegisterType:class;
ResolveType Resolve<ResolveType>()where ResolveType:class;
ResolveType Resolve<ResolveType>(stringname)where ResolveType:class;
voidRegister<RegisterType,RegisterImplementation>()
where RegisterType:class
where RegisterImplementation:class,RegisterType;
}
|
And then set the IOC container in the System.
C#
1
|
FreshIOC.OverrideContainer(myContainer);
|
This release can be found in nuget and the source code on github.
https://www.nuget.org/packages/FreshMvvm/
https://github.com/rid00z/FreshMvvm
Thanks