-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bedf9a
commit 58298c9
Showing
12 changed files
with
125 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Packages.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
....Extensions.Templates/content/unoapp-extensions/MyExtensionsApp/Business/Models/Entity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//-:cnd:noEmit | ||
|
||
namespace MyExtensionsApp.Business.Models; | ||
|
||
public record Entity(string Name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 49 additions & 4 deletions
53
...ensions.Templates/content/unoapp-extensions/MyExtensionsApp/Presentation/MainViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,69 @@ | ||
//-:cnd:noEmit | ||
//+:cnd:noEmit | ||
#if(reactive) | ||
using Uno.Extensions.Reactive; | ||
#else | ||
using System.Windows.Input; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
#endif | ||
|
||
namespace MyExtensionsApp.Presentation; | ||
|
||
public partial class MainViewModel | ||
#if(reactive) | ||
public partial class MainViewModel | ||
{ | ||
public string? Title { get; } | ||
|
||
public IState<string> Name { get; } | ||
|
||
public MainViewModel( | ||
INavigator navigator, | ||
IOptions<AppConfig> appInfo) | ||
{ | ||
|
||
_navigator = navigator; | ||
Title = $"Main - {appInfo?.Value?.Title}"; | ||
|
||
Name = State<string>.Value(this, ()=>""); | ||
} | ||
|
||
public async Task GoToSecond() | ||
{ | ||
var name = await Name; | ||
await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(name!)); | ||
} | ||
|
||
private INavigator _navigator; | ||
} | ||
#else | ||
public partial class MainViewModel:ObservableObject | ||
{ | ||
public string? Title { get; } | ||
|
||
[ObservableProperty] | ||
private string? name; | ||
|
||
public ICommand GoToSecond { get; } | ||
|
||
public MainViewModel( | ||
INavigator navigator, | ||
IOptions<AppConfig> appInfo) | ||
{ | ||
|
||
_navigator = navigator; | ||
Title = $"Main - {appInfo?.Value?.Title}"; | ||
|
||
GoToSecond = new AsyncRelayCommand(GoToSecondView); | ||
} | ||
|
||
public async Task GoToSecond(CancellationToken cancellation) | ||
public async Task GoToSecondView() | ||
{ | ||
await _navigator.NavigateViewModelAsync<SecondViewModel>(this, cancellation: cancellation); | ||
await _navigator.NavigateViewModelAsync<SecondViewModel>(this, data: new Entity(Name!)); | ||
} | ||
|
||
private INavigator _navigator; | ||
} | ||
#endif | ||
|
||
//-:cnd:noEmit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters