Files
Wino-Mail/Wino.Mail.ViewModels/WelcomePageViewModel.cs
T

70 lines
2.2 KiB
C#
Raw Normal View History

2026-03-05 10:12:03 +01:00
using System;
using System.Collections.Generic;
2024-04-18 01:44:37 +02:00
using CommunityToolkit.Mvvm.ComponentModel;
2026-03-05 10:12:03 +01:00
using CommunityToolkit.Mvvm.Input;
2024-04-18 01:44:37 +02:00
using Wino.Core.Domain;
using Wino.Core.Domain.Interfaces;
2026-03-05 10:12:03 +01:00
using Wino.Core.Domain.Enums;
2024-04-18 01:44:37 +02:00
using Wino.Core.Domain.Models.Navigation;
2026-03-05 10:12:03 +01:00
using Wino.Core.Domain.Models.Updates;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
namespace Wino.Mail.ViewModels;
public partial class WelcomePageViewModel : MailBaseViewModel
2024-04-18 01:44:37 +02:00
{
2026-03-05 10:12:03 +01:00
private readonly IUpdateManager _updateManager;
private readonly INativeAppService _nativeAppService;
private readonly INavigationService _navigationService;
2025-02-16 11:54:23 +01:00
[ObservableProperty]
2026-03-05 10:12:03 +01:00
public partial string VersionDisplay { get; set; } = string.Empty;
2025-02-16 11:54:23 +01:00
2026-03-05 10:12:03 +01:00
[ObservableProperty]
public partial List<UpdateNoteSection> UpdateSections { get; set; } = [];
[ObservableProperty]
public partial List<UpdateNoteSection> FeatureSections { get; set; } = [];
public string GitHubUrl => "https://github.com/bkaankose/Wino-Mail/";
public string PaypalUrl => "https://paypal.me/bkaankose?country.x=PL&locale.x=en_US";
public WelcomePageViewModel(IUpdateManager updateManager,
INativeAppService nativeAppService,
INavigationService navigationService)
2024-04-18 01:44:37 +02:00
{
2026-03-05 10:12:03 +01:00
_updateManager = updateManager;
_nativeAppService = nativeAppService;
_navigationService = navigationService;
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
{
base.OnNavigatedTo(mode, parameters);
2024-04-18 01:44:37 +02:00
2026-03-05 10:12:03 +01:00
VersionDisplay = $"{Translator.SettingsAboutVersion}{_nativeAppService.GetFullAppVersion()}";
try
{
var updateNotes = await _updateManager.GetLatestUpdateNotesAsync();
UpdateSections = updateNotes.Sections;
}
catch (Exception)
{
UpdateSections = [];
}
2025-02-16 11:54:23 +01:00
try
2024-04-18 01:44:37 +02:00
{
2026-03-05 10:12:03 +01:00
FeatureSections = await _updateManager.GetFeaturesAsync();
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
catch (Exception)
2024-04-18 01:44:37 +02:00
{
2026-03-05 10:12:03 +01:00
FeatureSections = [];
2024-04-18 01:44:37 +02:00
}
}
2026-03-05 10:12:03 +01:00
[RelayCommand]
private void NavigateManageAccounts()
=> _navigationService.Navigate(WinoPage.ManageAccountsPage, null, NavigationReferenceFrame.ShellFrame, NavigationTransitionType.DrillIn);
2024-04-18 01:44:37 +02:00
}