Skip to content

Commit

Permalink
Added markdown property
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 committed Jan 10, 2023
1 parent 2e4fa18 commit 00f4797
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private IServiceProvider ConfigureServices()
.AddSingleton<IDateTimeFormatterFactory, DateTimeFormatterFactory>()
.AddSingleton<IDateTimeFormatter, UserDateTimeFormatter>()
.AddSingleton<IVolumeInfoFactory, VolumeInfoFactory>()
.AddSingleton<IReleaseNotesService, ReleaseNotesService>()

// TODO(i): FileSystem operations:
// (IFilesystemHelpersService, IFilesystemOperationsService)
Expand Down Expand Up @@ -209,6 +210,10 @@ await Task.WhenAll(
await updateService.CheckForUpdates();
await updateService.DownloadMandatoryUpdates();

// Download release notes
var releaseNotesService = Ioc.Default.GetRequiredService<IReleaseNotesService>();
await releaseNotesService.DownloadReleaseNotes();

static async Task OptionalTask(Task task, bool condition)
{
if (condition)
Expand Down
37 changes: 37 additions & 0 deletions src/Files.App/ServicesImplementation/ReleaseNotesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.WinUI.Helpers;
using Files.App.Extensions;
using Files.Backend.Services;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Windows.Services.Store;
using WinRT.Interop;

namespace Files.App.ServicesImplementation
{
internal sealed class ReleaseNotesService : ObservableObject, IReleaseNotesService
{
private string? _releaseNotes;
public string? ReleaseNotes
{
get => _releaseNotes;
private set => SetProperty(ref _releaseNotes, value);
}

private bool isReleaseNotesAvailable;
public bool IsReleaseNotesAvailable
{
get => isReleaseNotesAvailable;
set => SetProperty(ref isReleaseNotesAvailable, value);
}

public async Task DownloadReleaseNotes()
{
///
}
}
}
13 changes: 5 additions & 8 deletions src/Files.App/UserControls/AddressToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
x:Name="ViewReleaseNotesButton"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
x:Load="{x:Bind ViewModel.IsAppUpdated, Mode=OneWay}"
x:Load="{x:Bind ViewModel.IsReleaseNotesVisible, Mode=OneWay}"
AccessKey="2"
AutomationProperties.Name="{helpers:ResourceString Name=ReleaseNotes}"
Command="{x:Bind ViewModel.ViewReleaseNotesCommand, Mode=OneWay}"
Expand Down Expand Up @@ -338,7 +338,6 @@
<!-- Release Notes Teaching Tip -->
<TeachingTip
x:Name="ReleaseNotesTeachingTip"
Title="{helpers:ResourceString Name=ReleaseNotes}"
IsLightDismissEnabled="True"
IsOpen="{x:Bind ViewModel.IsReleaseNotesOpen, Mode=TwoWay}"
Target="{x:Bind ViewReleaseNotesButton}">
Expand All @@ -361,13 +360,11 @@
<!-- Markdown Content -->
<TeachingTip.Content>
<ScrollViewer
Width="260"
Height="240"
HorizontalScrollMode="Disabled"
VerticalScrollMode="Enabled">
<controls:MarkdownTextBlock
Padding="0,12"
Background="Transparent"
Text="Coming Soon 👀" />
HorizontalScrollMode="Auto"
VerticalScrollMode="Auto">
<controls:MarkdownTextBlock Background="Transparent" Text="{x:Bind ViewModel.ReleaseNotes, Mode=OneWay}" />
</ScrollViewer>
</TeachingTip.Content>
</TeachingTip>
Expand Down
27 changes: 16 additions & 11 deletions src/Files.App/ViewModels/ToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Files.App.Filesystem;
using Files.App.Filesystem.StorageItems;
using Files.App.Helpers;
using Files.App.ServicesImplementation;
using Files.App.Shell;
using Files.App.UserControls;
using Files.App.Views;
Expand All @@ -25,6 +26,7 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.ApplicationModel.DataTransfer;
Expand All @@ -40,8 +42,8 @@ namespace Files.App.ViewModels
public class ToolbarViewModel : ObservableObject, IAddressToolbar, IDisposable
{
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

public IUpdateService UpdateService { get; } = Ioc.Default.GetService<IUpdateService>()!;
public IReleaseNotesService ReleaseNotesService { get; } = Ioc.Default.GetService<IReleaseNotesService>()!;

public delegate void ToolbarPathItemInvokedEventHandler(object sender, PathNavigationEventArgs e);

Expand Down Expand Up @@ -252,15 +254,25 @@ public bool IsLayoutAdaptive
public bool IsAdaptiveLayoutEnabled
=> UserSettingsService.FoldersSettingsService.EnableOverridingFolderPreferences;

public bool IsAppUpdated
=> UpdateService.IsAppUpdated;

public bool IsUpdateAvailable
=> UpdateService.IsUpdateAvailable;

public bool IsUpdating
=> UpdateService.IsUpdating;

public bool IsReleaseNotesVisible
=> UpdateService.IsAppUpdated && ReleaseNotesService.IsReleaseNotesAvailable;

public string? ReleaseNotes
=> ReleaseNotesService.ReleaseNotes;

private bool isReleaseNotesOpen;
public bool IsReleaseNotesOpen
{
get => isReleaseNotesOpen;
set => SetProperty(ref isReleaseNotesOpen, value);
}

private bool canCopyPathInPage;
public bool CanCopyPathInPage
{
Expand Down Expand Up @@ -321,13 +333,6 @@ public bool IsSearchBoxVisible
}
}

private bool isReleaseNotesOpen;
public bool IsReleaseNotesOpen
{
get => isReleaseNotesOpen;
set => SetProperty(ref isReleaseNotesOpen, value);
}

private string? pathText;
public string? PathText
{
Expand Down
23 changes: 23 additions & 0 deletions src/Files.Backend/Services/IReleaseNotesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.ComponentModel;
using System.Threading.Tasks;

namespace Files.Backend.Services
{
public interface IReleaseNotesService : INotifyPropertyChanged
{
/// <summary>
/// Release notes for the latest release
/// </summary>
string? ReleaseNotes { get; }

/// <summary>
/// Gets a value indicating if release notes are available
/// </summary>
bool IsReleaseNotesAvailable { get; }

/// <summary>
/// Downloads release notes for the latest release
/// </summary>
Task DownloadReleaseNotes();
}
}

0 comments on commit 00f4797

Please sign in to comment.