rid00z / freshmvvm Goto Github PK
View Code? Open in Web Editor NEWFreshMvvm is a super light Mvvm Framework designed specifically for Xamarin.Forms. It's designed to be Easy, Simple and Flexible.
License: Apache License 2.0
FreshMvvm is a super light Mvvm Framework designed specifically for Xamarin.Forms. It's designed to be Easy, Simple and Flexible.
License: Apache License 2.0
I am unable to resolve a type in my Release configuration. The Debug work is functioning, but the Release only works if I remove the controls that have custom renderers.
The specific problem that I am having is a System.IO.FileNotFound exception on the namespace. The exception is being thrown when trying to PushModelAsync
I use to register UserDialogs for Android and WindowsPhone81. Android works fine but WP doesnt. Do I have to do something extra?
FreshIOC.Container.Register<IUserDialogs>(UserDialogs.Instance);
Currently there is no way to modify the BarTextColor of the NavigationPage object inside the navigation containers. In Xamarin.Forms in order to have a light status bar for iOS, the BarTextColor must be set to White.
Is there any chance this can be added? Not sure the best way to do so or I would make a pull request. In my test I added a boolean to CreateContainerPage
protected virtual Page CreateContainerPage(Page page, bool isLight = false)
{
var nav = new NavigationPage(page);
if (isLight)
{
nav.BarTextColor = Color.White;
}
return nav;
}
Fresh IOC is not compatible with UWP apps. Please create a FreshMVVM package that does not include FreshIOC for people who what to use another IOC container.
In the newest version did this change? I had that line in previous versions without any complaints but now it won't compile.
I have switched it to FreshIOC.Container.Register(typeof(HttpClient));
but not sure that is the proper way.
I'm interested to know why TinyIOC is being included in the src but the namespace is just changed.
It would be better to just have TinyIOC as a nuget dependant. The version of TinyIOC included is outdated.
when you have FreshMasterDetailNavigationContainer as below, it will execute through each PageModel (ViewModel) init and constructor and if you have some initial data loading your view, this will be very expensive. Is there a way to prevent this? Otherwise for me Freshmvvm is no use.
thanks.
var masterDetailNav = new FreshMasterDetailNavigationContainer();
masterDetailNav.Init("Menu", "Menu.png");
masterDetailNav.AddPage<page1PageModel>("page1", null);
masterDetailNav.AddPage<page2PageModel>("page2", null);
masterDetailNav.AddPage<page3PageModel>("page3", null);
masterDetailNav.AddPage<page4PageModel>("page4", null);
masterDetailNav.AddPage<page5PageModel>("page5", null);
Missing implementation on CustomImplementedNav: public void NotifyChildrenPageWasPopped () { }
As the title says we are seeing an issue where the < Back button on iOS will sometimes change to < Previous Page Name instead of Back.
I've been trying to understand the best way to bind events like Entry.Completed
to logic in the page model, and conversely having the page model direct page control behavior like Entry.Focus()
.
It seems like a good solution for the Completed
event is to wire the event(s) directly in the page code behind file, and in those events call MessagingCenter.Send()
with a corresponding MessagingCenter.Subscribe()
in the page model.
Then doing just the opposite to trigger Entry.Focus()
in the page.
Is this pretty much best practice for things like this? Or is there a more binding-y way to do this?
Is this a bug or feature? I would like to change the navigation icon from the back button to something more suitable but can't figure out how to do so.
FreshMVVM is easy to use and supposed to speed up development time but actually more I use, I feel like it is my hump and it slows me down. everytime something is wrong on xaml or in viewmodel freshmvvm will popout this message. FreshTinyIoC.TinyIoCResolutionException: Unable to resolve type: blablaPage.xaml
I need to find the error debugging line by line if it is in xaml, i need to find out by removing things and try each label, button etc. Is there no possibility to enhance this situation with full exception information?
Hi Michael,
I love my XAML so I tried to use FreshMvvm with a TabbedPage in XAML as well.
Mostly goes fine, but it won't show the actual content of the selected page. I'm probably doing something wrong, but I can't figure out what.
This is the XAML page I have.
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Kilomeeter.Pages.MainPage" ItemsSource="{Binding Pages}">
<TabbedPage.ItemTemplate>
<DataTemplate>
<Page Title="{Binding Title}" Icon="{Binding Icon}" />
</DataTemplate>
</TabbedPage.ItemTemplate>
</TabbedPage>
And this is my PageModel:
public class MainPageModel : FreshBasePageModel
{
public ObservableCollection<object> Pages { get; set; }
public Page SelectedPage { get; set; }
public MainPageModel()
{
Pages = new ObservableCollection<object>
{
FreshPageModelResolver.ResolvePageModel<CarsOverviewPageModel>(),
FreshPageModelResolver.ResolvePageModel<MapPageModel>()
};
}
}
Nothing fancy.
I've tried setting the SelectedPage
and the CurrentPage
on the TabbedPage but nothing seems to show up. Just the tabs, which are selectable, but an empty screen.
Any thoughts?
I'm using Arc.Userdialogs together with FreshMvvm which works well with one exception: the messages(toasts) appear and reappear as if there is an additional refresh/repaint by FreshMvvm.
Did you ever use Arc.Userdialogs with FreshMvvm and are there any gotchas or whatever?
With the sample, I've tried a couple of different checkouts and the head versions of FreshMvvm and the latest nuget package, but in all cases the ListView is blank.
Is anyone else having this problem or is it just me?
When i try to Push a new Page
I'm trying to get the current page name from a separate class, but i'm not sure how to handle this. I used the NavigationStack in normal Xamarin, but it doesn't work with this.
In a ContentPage
named ThingListPage
consisting of a Xaml file and code-behind, containing a ListView
. For testing, I made an array of strings in the ContentPage
's local ResourceDictionary
and set it as the ListView
's ItemsSource
. Like this:
<ListViem ItemsSource="{Binding Source={StaticResource TestData}}">
Everything is fine. Later, I commented out the ResourceDictionary
and its contents without changing the ListView
's ItemSource
. Xamarin continued to build and deploy without errors or warnings. Incidentally, the assembly-level attribute for Xaml compilation was enabled:
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
Upon running the app, it gave a super-vague error on both iOS and Android emulators:
FreshTinyIoC.TinyIoCResolutionException: Unable to resolve type: MyApp.Pages.ThingListPage
I couldn't decipher anything from debugging in VS. It was only through trial-and-error that I found the problem came from the invalid binding statement.
Sorry for a less-than-definitive report, but I thought it better to report my notes thus far than to lose them to the great Notepad.exe in the sky.
Not sure if this is a general Xamarin Forms question/problem but: FreshMvvm when got through nuget has been build with Forms 1.4.... We are currently at Forms 1.5.1. This seemed to be no problem until we started getting errors about 'xamlctask compilation'
I resolved this by removing the FreshMvvm nuget package, build the FreshMvvm dll's using the zip from nuget and referencing the resulting Dll's in my project.
Any comments?
Hi
I tried to create a masterdetail page using freshmvvm as below. but It looks like that it only display on start up page, when I navigate to any other page that is not the list of MasterPage, it will not be visible
public App()
{
// The root page of your application
LoadMasterDetail();
}
public void LoadMasterDetail()
{
var masterDetailNav = new FreshMasterDetailNavigationContainer();
masterDetailNav.Init("Menu", "Menu.png");
masterDetailNav.AddPage<Page1PageModel>("Page1", null);
masterDetailNav.AddPage<Page2PageModel>("Page2", null);
masterDetailNav.AddPage<Page3PageModel>("Page3", null);
MainPage = masterDetailNav;
}
So according to above if I have page4Page and Page4PageModel which I am navigating through somewhere else when I am on this page, I dont see any masterdetail container. Is this supposed to be like that?
2nd thing, It executes through each and every pagemodel at the application start. This means if I have some heavy operation in any pageModel, this will reduce application start time. Is there anyway to prevent this?
thanks.
We have made no changes to our code but updating the newest (stable) Xamarin.Forms v2.1.0.6529 and FreshMVVM (1.0.3.003) we are now receiving this error:
Master and Detail must be set before adding MasterDetailPage to a container
I can confirm that Detail
is not being set as the resolver can't find the PageModels.
Hello,
I have a MenuPage (and MenuPageModel) as Master page. This menu has a list of options with some commands binded.
How can I do for do the navigation (PushAsync) from MenuPageModel? Here is my code.
var menuPage = FreshPageModelResolver.ResolvePageModel<MenuPageModel>();
this.Master = menuPage;
var homePage = FreshPageModelResolver.ResolvePageModel<HomePageModel>();
this.Detail = new FreshNavigationContainer(homePage);
Thanks.
In this method I want to call to an asynchronous method to retrieve some data from server, but I see that this method is a void.
So, what is the recommended way to use the "await" operator here? Am I using the correct method?
I been following your sample, using Xamarin Forms 2. It's not finding my LoginPageModel which is derived from FreshBasePageModel. I scrubbed through the sample app to see if I'm missing anything and I have what's needed.
Hello.
When I try to show an alert from the PageModel's Init() method (if there is any exception I want to show any UI alert), not only the navigation to the page is not done, but the navigation is "broken" for the all the application (so I can't do push to anywhere).
public override void Init(object initData)
{
base.Init(initData);
...
UserDialogs.Instance.Alert("Message", "Message content", "Close");
}
I have already tried without the UserDialogs plugin, and the error persists:
((MasterPage)Application.Current.MainPage).DisplayAlert("Message", "Message content", "Close");
Is this a bug? Any workaround?
Waiting for your replies. Thanks.
If I clone the repo and open the FreshMvvmSampleApp and update packages I cannot build the application for Droid. To test try cloning the repo to a fresh directory.
Calling await CoreMethods.PopToRoot(true/false)
does nothing in UWP Project.
For the moment any workaround would be very appreciated.
Thx for your great work!
EDIT: I'm using FreshMvvm version 2.0.1 and Xamarin.Forms 2.1.0.6529
EDIT 2: Now, Xamarin Forms to 2.2.0.31 and FreshMvvm to 2.1.0, same problem
I would like to avoid Fody, and I would like to reuse the PropertyChangedEventHandler PropertyChanged that there is in FresBasePageModel.
How can I do this?
It looks like the packages.config file is missing from the FreshMvvmSampleApp.Droid project.
According to TinyIOC documentation :
// By default we register concrete types as
// multi-instance, and interfaces as singletons
container.Register<MyConcreteType>(); // Multi-instance
container.Register<IMyInterface, MyConcreteType>(); // Singleton
This means the default implementation of registering concretes with interfaces in the IFreshIOC
container is to register singletons which might not be the intended behavior, and there's not an easy way to change this without plugging in a brand new container implementation.
The TinyIOC convention of fluent extension methods wouldn't work here without exposing the underlying TinyIOC framework, so i would propose adding some extra methods and specifying the lifetime, making the Register<T, T2> multiinstance by default.
eg.
RegisterSingleton<RegisterType, RegisterImplementation>()
Register<RegisterType, RegisterImplementation>()
Updating void Init() to async Task Init() to support both testing and best practices. Current method is used async at times and this can cause issues with void return type.
I've created a branch with changes to this method but there are open questions. The change in FreshBasePageModel makes sense but results in a breaking change for all subclasses. Nothing major though, a small change.
The issue then comes from the ResolverPageModel calls calling Init(). They need to either, 1) be changed to async as well, as I did in the branch, or 2) the call needs to be wrapped in a Task.Run().
This works and I already have the code working in the branch with updated sample code. The issue is that the ResolvePageModel call is now async which means the call to load this page can potentially get called twice by a handler if the user hits it more than once before the page resolves.
The resolver wouldn't be able to ensure the page is initialized before it's displayed. This isn't terrible as this is pretty much how we are currently using the Init() method when there is an waited async call in the async void.
Branch with changes: https://github.com/BNoohi/FreshMvvm
@rid00z on issues with void Init(): http://www.michaelridland.com/xamarin/freshmvvm-n2-ioc-constructor-injection/ (also a great tutorial video)
MSDN article on async best practices: https://msdn.microsoft.com/en-us/magazine/jj991977.aspx
Thoughts?
All the navigation controls rely on being able to read the service name from the page model. But this is not exposed to custom implementations of IFreshNavigationService. this makes it hard to create custom navigators which work with the CoreMethods pop and push methods
Hi Michael
Do you use FreshMvvm in the production? Is he ready for this?
I get an "Argument null exception" error if I use null as the icon parameter in the FreshTabbedNavigationContainers, AddTab.
If I use whitespace, UIKit.UIImage gives me another error.
The example here uses "null", http://goo.gl/AvlBbO
Maybe it's a change in Xamarin that courses this issue?
How can I call PushPageModel
or something similar outside of a page model? There are times I need to call it from a menu that has it's own View Model that does not inherit and cannot inherit from FreshBasePageModel
. I'm using http://xam-consulting.com/slideoverkit-xamarin-forms/ in case you are wondering.
I would like to be able to enable/disable one or more tabs (using tabbed navigation) based on certain conditions during run-ime. Is this possible (hiding/showing would be a good alternative).
I am need to be able to pop a page and pop to root from outside of the page models. I am using the code from a different issue that lets you push pages from outside the model, but for some reason popping and popping to root do not work. Anyone have any ideas?
My code:
var navService = FreshMvvm.FreshIOC.Container.Resolve<IFreshNavigationService> (FreshMvvm.Constants.DefaultNavigationServiceName);
await navService.PopPage();
I get the error:
'jobject' must not be IntPtr.Zero.
Parameter name: jobject
As the title says: will there be a 0.0.7 version or is there a 0.1.0/1.0 in the pipelines in several months from now? I know I can download the code as-is from github but using NuGet etc. gives me some more confidence in a version being stable etc.
Pushing a PageModel using the CoreMethods.PushPageModel<>(object, true); interface does not result in any events being raised if the Android Back button is pushed.
I noticed several new releases last month, I like that! Are there any release notes to find out what got changed/fixed/added?
Can you please do a little write up summarizing the common components \ features FreshMvvm has like navigation, property changed support, navigation, DI
I try to install FreshMvvm NuGet Package to Universal Windows project (with Xamarin.Forms 1.5.1.6466-pre2) and have the following errors:
FreshMvvm 0.0.6 is not compatible with UAP,Version=v10.0.
Some packages are not compatible with UAP,Version=v10.0.
Hi,
I think there should be a way to clean up events and the releasing of the binding context when a page is popped.
I included a destructor in FreshBasePageModel
~FreshBasePageModel()
{
var page = CurrentPage;
page.BindingContext = null;
page.Appearing -= ViewIsAppearing;
page.Disappearing -= ViewIsDisappearing;
}
But I'm not sure if this would be enough as we don'r know when it will be called.
What do you think?
I have SearchItemsPage and ItemsLookupPage. I want that both of them use the same pagemodel (ItemsPageModel).
Is this possible to "jump" the framework convention for exceptional cases?
Thanks :).
How can I navigate to a tabbed page without pushing a modal?
I am doing this:
var tabbedNavigation = new FreshTabbedNavigationContainer ("secondNavPage");
tabbedNavigation.AddTab<ContactListPageModel> ("Contacts", "contacts.png", null);
tabbedNavigation.AddTab<QuoteListPageModel> ("Quotes", "document.png", null);
await CoreMethods.PushNewNavigationServiceModal(tabbedNavigation);
But I don' want to navigate to this tabbed page in a Modal. Is this possible to do only push?
Thanks.
CoreMethods.PushPageModel<T>
does not navigate as expected in a Modal page.
Here is a video of the behavior: http://screencast.com/t/gErUL9c2h
The basic navigation wraps any new Modal in a NavigationPage, which is great. However, when trying to navigate to pages while that Modal is displayed, the pages are pushed underneath (in the other parent NavigationPage).
I have been playing with this and investigating my options. Suggestions are welcome.
Giving the following example:
namespace Foo.Bar.PageModels
{
public class MyPageViewModel
{
...
}
}
Using var name = type.AssemblyQualifiedName.Replace ("Model", string.Empty);
Will lead into the follow type: Foo.Bar.Pages.MyPageView
witch does not exist.
I was looking to derive from the FreshMasterDetailContainer to add menu item icons, but seem to be missing a few pieces. Does it have the ability to support this? Could you point me in the right direction?
My first thought was to override the AddPage() method but obviously I can't pass in any new parameters.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.