generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
3 changed files
with
70 additions
and
39 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/app/ApplicationTemplate.Presentation/ViewModels/Posts/PostItemViewModel.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,52 @@ | ||
using ApplicationTemplate.Business; | ||
using Chinook.DynamicMvvm; | ||
using Chinook.StackNavigation; | ||
|
||
namespace ApplicationTemplate.Presentation; | ||
|
||
/// <summary> | ||
/// Post item view model. | ||
/// </summary> | ||
/// <remarks> | ||
/// This was created as a workaround for an Uno issue. | ||
/// See https://github.com/unoplatform/uno/issues/13996 for more details. | ||
/// </remarks> | ||
public sealed class PostItemViewModel : ViewModel | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PostItemViewModel"/> class. | ||
/// </summary> | ||
/// <param name="parent">The parent view model.</param> | ||
/// <param name="post">The post.</param> | ||
public PostItemViewModel(IViewModel parent, Post post) | ||
{ | ||
Parent = parent; | ||
Post = post; | ||
} | ||
|
||
/// <summary> | ||
/// The parent view model. | ||
/// </summary> | ||
public IViewModel Parent { get; } | ||
|
||
/// <summary> | ||
/// The post. | ||
/// </summary> | ||
public Post Post { get; } | ||
|
||
/// <summary> | ||
/// Deletes the post. | ||
/// </summary> | ||
public IDynamicCommand DeletePost => this.GetCommandFromTask<PostItemViewModel>(async (ct, item) => | ||
{ | ||
await this.GetService<IPostService>().Delete(ct, item.Post.Id); | ||
}); | ||
|
||
/// <summary> | ||
/// Navigates to the edit post page. | ||
/// </summary> | ||
public IDynamicCommand EditPost => this.GetCommandFromTask<PostItemViewModel>(async (ct, item) => | ||
{ | ||
await this.GetService<IStackNavigator>().Navigate(ct, () => new EditPostPageViewModel(item.Post)); | ||
}); | ||
} |
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