Settings shell.
This commit is contained in:
@@ -44,6 +44,7 @@ public partial class KeyboardShortcutViewModel : ObservableObject
|
||||
WinoApplicationMode.Mail => Translator.KeyboardShortcuts_ModeMail,
|
||||
WinoApplicationMode.Calendar => Translator.KeyboardShortcuts_ModeCalendar,
|
||||
WinoApplicationMode.Contacts => Translator.ContactsPage_Title,
|
||||
WinoApplicationMode.Settings => Translator.MenuSettings,
|
||||
_ => Mode.ToString()
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Core.Domain.Models.Settings;
|
||||
using Wino.Messaging.Client.Navigation;
|
||||
|
||||
namespace Wino.Core.ViewModels;
|
||||
@@ -63,23 +64,8 @@ public partial class SettingOptionsPageViewModel : CoreBaseViewModel
|
||||
{
|
||||
if (type is WinoPage pageType)
|
||||
{
|
||||
string pageTitle = pageType switch
|
||||
{
|
||||
WinoPage.ManageAccountsPage => Translator.SettingsManageAccountSettings_Title,
|
||||
WinoPage.PersonalizationPage => Translator.SettingsPersonalization_Title,
|
||||
WinoPage.AboutPage => Translator.SettingsAbout_Title,
|
||||
WinoPage.MessageListPage => Translator.SettingsMessageList_Title,
|
||||
WinoPage.ReadComposePanePage => Translator.SettingsReadComposePane_Title,
|
||||
WinoPage.LanguageTimePage => Translator.SettingsLanguageTime_Title,
|
||||
WinoPage.AppPreferencesPage => Translator.SettingsAppPreferences_Title,
|
||||
WinoPage.CalendarSettingsPage => Translator.SettingsCalendarSettings_Title,
|
||||
WinoPage.SignatureAndEncryptionPage => Translator.SettingsSignatureAndEncryption_Title,
|
||||
WinoPage.KeyboardShortcutsPage => Translator.Settings_KeyboardShortcuts_Title,
|
||||
WinoPage.StoragePage => Translator.SettingsStorage_Title,
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
|
||||
Messenger.Send(new BreadcrumbNavigationRequested(pageTitle, pageType));
|
||||
var pageInfo = SettingsNavigationInfoProvider.GetInfo(pageType, AccountSummaryText);
|
||||
Messenger.Send(new BreadcrumbNavigationRequested(pageInfo.Title, pageType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,54 @@
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Settings;
|
||||
|
||||
namespace Wino.Core.ViewModels;
|
||||
|
||||
public class SettingsPageViewModel : CoreBaseViewModel
|
||||
public partial class SettingsPageViewModel : CoreBaseViewModel
|
||||
{
|
||||
public SettingsPageViewModel(INavigationService navigationService, IStatePersistanceService statePersistenceService)
|
||||
private readonly IAccountService _accountService;
|
||||
|
||||
public SettingsPageViewModel(
|
||||
INavigationService navigationService,
|
||||
IStatePersistanceService statePersistenceService,
|
||||
IAccountService accountService)
|
||||
{
|
||||
NavigationService = navigationService;
|
||||
StatePersistenceService = statePersistenceService;
|
||||
_accountService = accountService;
|
||||
}
|
||||
|
||||
public INavigationService NavigationService { get; }
|
||||
public IStatePersistanceService StatePersistenceService { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string CurrentDescription { get; set; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string ManageAccountsDescription { get; set; } = string.Empty;
|
||||
|
||||
public async Task UpdateActivePageAsync(WinoPage pageType)
|
||||
{
|
||||
await EnsureAccountSummaryAsync();
|
||||
|
||||
var info = SettingsNavigationInfoProvider.GetInfo(pageType, ManageAccountsDescription);
|
||||
await ExecuteUIThread(() => CurrentDescription = info.Description);
|
||||
}
|
||||
|
||||
private async Task EnsureAccountSummaryAsync()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(ManageAccountsDescription))
|
||||
return;
|
||||
|
||||
var accounts = await _accountService.GetAccountsAsync().ConfigureAwait(false);
|
||||
var count = accounts?.Count ?? 0;
|
||||
|
||||
await ExecuteUIThread(() =>
|
||||
{
|
||||
ManageAccountsDescription = string.Format(Translator.SettingsOptions_AccountsSummary, count);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user