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

removed async/awaits from pagemodel core methods #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 additions & 25 deletions src/FreshMvvm/PageModelCoreMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,26 @@ public PageModelCoreMethods (Page currentPage, FreshBasePageModel pageModel)
_currentPageModel = pageModel;
}

public async Task DisplayAlert (string title, string message, string cancel)
public Task DisplayAlert (string title, string message, string cancel)
{
if (_currentPage != null)
await _currentPage.DisplayAlert (title, message, cancel);
return _currentPage.DisplayAlert (title, message, cancel);
}

public async Task<string> DisplayActionSheet (string title, string cancel, string destruction, params string[] buttons)
public Task<string> DisplayActionSheet (string title, string cancel, string destruction, params string[] buttons)
{
if (_currentPage != null)
return await _currentPage.DisplayActionSheet (title, cancel, destruction, buttons);
return null;
return _currentPage.DisplayActionSheet (title, cancel, destruction, buttons);
}

public async Task<bool> DisplayAlert (string title, string message, string accept, string cancel)
public Task<bool> DisplayAlert (string title, string message, string accept, string cancel)
{
if (_currentPage != null)
return await _currentPage.DisplayAlert (title, message, accept, cancel);
return false;
return _currentPage.DisplayAlert (title, message, accept, cancel);
}

public async Task PushPageModel<T> (object data, bool modal = false) where T : FreshBasePageModel
public Task PushPageModel<T> (object data, bool modal = false) where T : FreshBasePageModel
{
T pageModel = FreshIOC.Container.Resolve<T> ();

await PushPageModel(pageModel, data, modal);
return PushPageModel(pageModel, data, modal);
}

public Task PushPageModel(Type pageModelType)
Expand All @@ -55,7 +50,7 @@ public Task PushPageModel(Type pageModelType, object data, bool modal = false)
return PushPageModel(pageModel, data, modal);
}

async Task PushPageModel(FreshBasePageModel pageModel, object data, bool modal = false)
Task PushPageModel(FreshBasePageModel pageModel, object data, bool modal = false)
{
var page = FreshPageModelResolver.ResolvePageModel(data, pageModel);

Expand All @@ -67,32 +62,32 @@ async Task PushPageModel(FreshBasePageModel pageModel, object data, bool modal =

IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService> (_currentPageModel.CurrentNavigationServiceName);

await rootNavigation.PushPage (page, pageModel, modal);
return rootNavigation.PushPage (page, pageModel, modal);
}

public async Task PopPageModel (bool modal = false)
public Task PopPageModel (bool modal = false)
{
string navServiceName = _currentPageModel.CurrentNavigationServiceName;
if (_currentPageModel.IsModalFirstChild) {
navServiceName = _currentPageModel.PreviousNavigationServiceName;
}

IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService> (navServiceName);
await rootNavigation.PopPage (modal);
return rootNavigation.PopPage (modal);
}

public async Task PopToRoot(bool animate)
public Task PopToRoot(bool animate)
{
IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService> (_currentPageModel.CurrentNavigationServiceName);
await rootNavigation.PopToRoot (animate);
return rootNavigation.PopToRoot (animate);
}

public async Task PopPageModel (object data, bool modal = false)
public Task PopPageModel (object data, bool modal = false)
{
if (_currentPageModel != null && _currentPageModel.PreviousPageModel != null && data != null) {
_currentPageModel.PreviousPageModel.ReverseInit (data);
}
await PopPageModel (modal);
return PopPageModel (modal);
}

public Task PushPageModel<T> () where T : FreshBasePageModel
Expand Down Expand Up @@ -124,7 +119,7 @@ public Task PushNewNavigationServiceModal (IFreshNavigationService newNavigation
return PushNewNavigationServiceModal (newNavigationService, new FreshBasePageModel[] { basePageModels });
}

public async Task PushNewNavigationServiceModal (IFreshNavigationService newNavigationService, FreshBasePageModel[] basePageModels)
public Task PushNewNavigationServiceModal (IFreshNavigationService newNavigationService, FreshBasePageModel[] basePageModels)
{
var navPage = newNavigationService as Page;
if (navPage == null)
Expand All @@ -137,14 +132,14 @@ public async Task PushNewNavigationServiceModal (IFreshNavigationService newNavi
}

IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService> (_currentPageModel.CurrentNavigationServiceName);
await rootNavigation.PushPage (navPage, null, true);
return rootNavigation.PushPage (navPage, null, true);
}

public async Task PopModalNavigationService()
public Task PopModalNavigationService()
{
var navServiceName = _currentPageModel.PreviousNavigationServiceName;
IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService> (navServiceName);
await rootNavigation.PopPage (true);
return rootNavigation.PopPage (true);
}

public void BatchBegin()
Expand Down