Skip to content

Commit

Permalink
feat: Changing ViewModel to Model in template
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Nov 2, 2022
1 parent 58298c9 commit 10d2a4f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ private static IHost BuildAppHost()
private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
{
views.Register(
new ViewMap(ViewModel: typeof(ShellViewModel)),
new ViewMap<MainPage, MainViewModel>(),
new DataViewMap<SecondPage, SecondViewModel, Entity>()
new ViewMap(ViewModel: typeof(ShellModel)),
new ViewMap<MainPage, MainModel>(),
new DataViewMap<SecondPage, SecondModel, Entity>()
);

routes
.Register(
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(),
new RouteMap("", View: views.FindByViewModel<ShellModel>(),
Nested: new RouteMap[]
{
new RouteMap("Main", View: views.FindByViewModel<MainViewModel>()),
new RouteMap("Second", View: views.FindByViewModel<SecondViewModel>()),
new RouteMap("Main", View: views.FindByViewModel<MainModel>()),
new RouteMap("Second", View: views.FindByViewModel<SecondModel>()),
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace MyExtensionsApp.Presentation;

#if(reactive)
public partial class MainViewModel
#if (reactive)
public partial class MainModel
{
public string? Title { get; }

public IState<string> Name { get; }

public MainViewModel(
public MainModel(
INavigator navigator,
IOptions<AppConfig> appInfo)
{
Expand All @@ -30,13 +30,13 @@ public MainViewModel(
public async Task GoToSecond()
{
var name = await Name;
await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(name!));
await _navigator.NavigateViewModelAsync<SecondModel>(this, data: new Entity(name!));
}

private INavigator _navigator;
}
#else
public partial class MainViewModel:ObservableObject
public partial class MainModel:ObservableObject
{
public string? Title { get; }

Expand All @@ -45,7 +45,7 @@ public partial class MainViewModel:ObservableObject

public ICommand GoToSecond { get; }

public MainViewModel(
public MainModel(
INavigator navigator,
IOptions<AppConfig> appInfo)
{
Expand All @@ -58,7 +58,7 @@ public MainViewModel(

public async Task GoToSecondView()
{
await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(Name!));
await _navigator.NavigateViewModelAsync<SecondModel>(this, data: new Entity(Name!));
}

private INavigator _navigator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace MyExtensionsApp.Presentation;

public partial record SecondViewModel (Entity Entity)
public partial record SecondModel (Entity Entity)
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace MyExtensionsApp.Presentation;

public class ShellViewModel
public class ShellModel
{
private INavigator Navigator { get; }


public ShellViewModel(
public ShellModel(
INavigator navigator)
{

Expand All @@ -18,6 +18,6 @@ public ShellViewModel(

public async Task Start()
{
await Navigator.NavigateViewModelAsync<MainViewModel>(this);
await Navigator.NavigateViewModelAsync<MainModel>(this);
}
}

0 comments on commit 10d2a4f

Please sign in to comment.