* create "About" page in settings * add content to About page * Get latest version from GitHub * Add NotificationService to servies * Enable actions on notifications * Get latest version asynchroniously * Handle when latest version is not found and clean code * Remove old UpdateService * Remove old NotificationService * Add icon for about tab * Update About page styling * Make About menu item a footer menu item * Update About page layout Based on suggestions by @felixse * Instatiate temporary navigation item only once This seems to solve display issues when opening the "About" page multiple times where the main navigation list is being rerendered for no apparent reason. * Revert unintended changes * Added shortcut to about page in hamburger menu * Move About page properties to the AboutPageViewModel * Make "loading..." and "Not found" italic to indicate non-default behaviour * move update check back to systemtray * Made IUpdateService async
79 lines
2.7 KiB
C#
79 lines
2.7 KiB
C#
using FluentTerminal.App.Services;
|
|
using FluentTerminal.App.ViewModels.Infrastructure;
|
|
using GalaSoft.MvvmLight;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FluentTerminal.App.ViewModels.Settings
|
|
{
|
|
public class AboutPageViewModel : ViewModelBase
|
|
{
|
|
private const string BaseUrl = "https://github.com/felixse/FluentTerminal/releases/tag/";
|
|
private readonly ISettingsService _settingsService;
|
|
private readonly IUpdateService _updateService;
|
|
private string _latestVersion;
|
|
private readonly IApplicationView _applicationView;
|
|
|
|
public AboutPageViewModel(ISettingsService settingsService, IUpdateService updateService, IApplicationView applicationView)
|
|
{
|
|
_settingsService = settingsService;
|
|
_updateService = updateService;
|
|
_applicationView = applicationView;
|
|
|
|
CheckForUpdatesCommand = new AsyncCommand(() => CheckForUpdate(true));
|
|
}
|
|
|
|
public IAsyncCommand CheckForUpdatesCommand { get; }
|
|
|
|
public string CurrentVersion
|
|
{
|
|
get
|
|
{
|
|
var version = _updateService.GetCurrentVersion();
|
|
return ConvertVersionToString(version);
|
|
}
|
|
}
|
|
|
|
public string CurrentVersionReleaseNotesURL => BaseUrl + CurrentVersion;
|
|
|
|
public string LatestVersion
|
|
{
|
|
get => _latestVersion;
|
|
set
|
|
{
|
|
if (Set(ref _latestVersion, value))
|
|
{
|
|
RaisePropertyChanged(nameof(LatestVersionFound));
|
|
RaisePropertyChanged(nameof(LatestVersionLoading));
|
|
RaisePropertyChanged(nameof(LatestVersionNotFound));
|
|
RaisePropertyChanged(nameof(LatestVersionReleaseNotesURL));
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool LatestVersionFound => !LatestVersionNotFound && !LatestVersionLoading;
|
|
|
|
public bool LatestVersionLoading => LatestVersion == null;
|
|
|
|
public bool LatestVersionNotFound => LatestVersion == "0.0.0.0";
|
|
|
|
public string LatestVersionReleaseNotesURL => BaseUrl + LatestVersion;
|
|
|
|
public Task OnNavigatedTo()
|
|
{
|
|
return CheckForUpdate(false);
|
|
}
|
|
|
|
public async Task CheckForUpdate(bool notifyNoUpdate)
|
|
{
|
|
var version = ConvertVersionToString(await _updateService.GetLatestVersionAsync());
|
|
await _applicationView.RunOnDispatcherThread(() => LatestVersion = version);
|
|
await _updateService.CheckForUpdate(notifyNoUpdate);
|
|
}
|
|
|
|
private string ConvertVersionToString(Version version)
|
|
{
|
|
return string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
|
|
}
|
|
}
|
|
} |