-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #260 from MartinZikmund/feature/blog-viewer
- Loading branch information
Showing
17 changed files
with
167 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
using MZikmund.Services.Navigation; | ||
using MZikmund.ViewModels; | ||
|
||
namespace MZikmund.Services.Loading; | ||
|
||
public class LoadingIndicator : ILoadingIndicator | ||
{ | ||
private readonly IWindowShellProvider _windowShellProvider; | ||
private readonly WindowShellViewModel _windowShellViewModel; | ||
|
||
public LoadingIndicator(IWindowShellProvider windowShellProvider) | ||
public LoadingIndicator(WindowShellViewModel windowShellProvider) | ||
{ | ||
_windowShellProvider = windowShellProvider; | ||
_windowShellViewModel = windowShellProvider ?? throw new ArgumentNullException(nameof(windowShellProvider)); | ||
} | ||
|
||
public IDisposable BeginLoading() => _windowShellProvider.ViewModel.BeginLoading(); | ||
public IDisposable BeginLoading() => _windowShellViewModel.BeginLoading(); | ||
|
||
public bool IsLoading => _windowShellProvider.ViewModel.IsLoading; | ||
public bool IsLoading => _windowShellViewModel.IsLoading; | ||
|
||
public string StatusMessage | ||
{ | ||
get => _windowShellProvider.ViewModel.LoadingStatusMessage; | ||
set => _windowShellProvider.ViewModel.LoadingStatusMessage = value; | ||
get => _windowShellViewModel.LoadingStatusMessage; | ||
set => _windowShellViewModel.LoadingStatusMessage = value; | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
src/app/MZikmund/ViewModels/Items/PostListItemViewModel.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,19 @@ | ||
using MZikmund.DataContracts.Blog; | ||
using MZikmund.Web.Core.Services; | ||
|
||
namespace MZikmund.ViewModels.Items; | ||
|
||
public sealed class PostListItemViewModel : ObservableObject | ||
{ | ||
private readonly IMarkdownConverter _markdownConverter; | ||
|
||
public PostListItemViewModel(PostListItem item, IMarkdownConverter markdownConverter) | ||
{ | ||
Item = item; | ||
_markdownConverter = markdownConverter; | ||
} | ||
|
||
public PostListItem Item { get; } | ||
|
||
public string AbstractPlain => _markdownConverter.ToPlainText(Item.Abstract); | ||
} |
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,11 +1,29 @@ | ||
namespace MZikmund.ViewModels; | ||
using MZikmund.Api.Client; | ||
using MZikmund.DataContracts.Blog; | ||
using MZikmund.Web.Core.Services; | ||
|
||
namespace MZikmund.ViewModels; | ||
|
||
public class PostViewModel : PageViewModel | ||
{ | ||
public PostViewModel() | ||
private readonly IMZikmundApi _api; | ||
private readonly IPostContentProcessor _postContentProcessor; | ||
|
||
public PostViewModel(IMZikmundApi api, IPostContentProcessor postContentProcessor) | ||
{ | ||
_api = api; | ||
_postContentProcessor = postContentProcessor; | ||
} | ||
|
||
public override async void ViewNavigatedTo(object? parameter) | ||
{ | ||
var postId = (Guid)parameter!; | ||
var postResponse = await _api.GetPostAsync(postId); | ||
Post = postResponse.Content!; | ||
HtmlPreview = await _postContentProcessor.ProcessAsync(Post.Content); | ||
} | ||
|
||
public Post? Post { get; private set; } | ||
|
||
public string HtmlPreview { get; private set; } = ""; | ||
} |
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
Oops, something went wrong.