-
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.
Merge pull request #881 from unoplatform/dev/nr/templateext
feat: Adding reactive flag
- Loading branch information
Showing
15 changed files
with
159 additions
and
69 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
69 changes: 69 additions & 0 deletions
69
....Extensions.Templates/content/unoapp-extensions/MyExtensionsApp/Presentation/MainModel.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,69 @@ | ||
//+: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; | ||
|
||
#if (reactive) | ||
public partial class MainModel | ||
{ | ||
public string? Title { get; } | ||
|
||
public IState<string> Name { get; } | ||
|
||
public MainModel( | ||
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<SecondModel>(this, data: new Entity(name!)); | ||
} | ||
|
||
private INavigator _navigator; | ||
} | ||
#else | ||
public partial class MainModel:ObservableObject | ||
{ | ||
public string? Title { get; } | ||
|
||
[ObservableProperty] | ||
private string? name; | ||
|
||
public ICommand GoToSecond { get; } | ||
|
||
public MainModel( | ||
INavigator navigator, | ||
IOptions<AppConfig> appInfo) | ||
{ | ||
|
||
_navigator = navigator; | ||
Title = $"Main - {appInfo?.Value?.Title}"; | ||
|
||
GoToSecond = new AsyncRelayCommand(GoToSecondView); | ||
} | ||
|
||
public async Task GoToSecondView() | ||
{ | ||
await _navigator.NavigateViewModelAsync<SecondModel>(this, data: new Entity(Name!)); | ||
} | ||
|
||
private INavigator _navigator; | ||
} | ||
#endif | ||
|
||
//-:cnd:noEmit | ||
|
24 changes: 0 additions & 24 deletions
24
...ensions.Templates/content/unoapp-extensions/MyExtensionsApp/Presentation/MainViewModel.cs
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...xtensions.Templates/content/unoapp-extensions/MyExtensionsApp/Presentation/SecondModel.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,7 @@ | ||
//-:cnd:noEmit | ||
|
||
namespace MyExtensionsApp.Presentation; | ||
|
||
public partial record SecondModel (Entity Entity) | ||
{ | ||
} |
11 changes: 0 additions & 11 deletions
11
...sions.Templates/content/unoapp-extensions/MyExtensionsApp/Presentation/SecondViewModel.cs
This file was deleted.
Oops, something went wrong.
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