Settings home refactoring.
This commit is contained in:
@@ -12,22 +12,8 @@ public partial class MessageListPageViewModel : MailBaseViewModel
|
||||
{
|
||||
public IPreferencesService PreferencesService { get; }
|
||||
private readonly IThumbnailService _thumbnailService;
|
||||
|
||||
private int selectedMarkAsOptionIndex;
|
||||
public int SelectedMarkAsOptionIndex
|
||||
{
|
||||
get => selectedMarkAsOptionIndex;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref selectedMarkAsOptionIndex, value))
|
||||
{
|
||||
if (value >= 0)
|
||||
{
|
||||
PreferencesService.MarkAsPreference = (MailMarkAsOption)Enum.GetValues<MailMarkAsOption>().GetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private readonly IStatePersistanceService _statePersistenceService;
|
||||
private readonly IDialogServiceBase _dialogService;
|
||||
|
||||
private readonly List<MailOperation> availableHoverActions =
|
||||
[
|
||||
@@ -38,6 +24,13 @@ public partial class MessageListPageViewModel : MailBaseViewModel
|
||||
MailOperation.MoveToJunk
|
||||
];
|
||||
|
||||
private readonly List<MailListDisplayMode> availableMailSpacingOptions =
|
||||
[
|
||||
MailListDisplayMode.Compact,
|
||||
MailListDisplayMode.Medium,
|
||||
MailListDisplayMode.Spacious
|
||||
];
|
||||
|
||||
public List<string> AvailableHoverActionsTranslations { get; set; } =
|
||||
[
|
||||
Translator.HoverActionOption_Archive,
|
||||
@@ -47,6 +40,32 @@ public partial class MessageListPageViewModel : MailBaseViewModel
|
||||
Translator.HoverActionOption_MoveJunk
|
||||
];
|
||||
|
||||
private int selectedMarkAsOptionIndex;
|
||||
public int SelectedMarkAsOptionIndex
|
||||
{
|
||||
get => selectedMarkAsOptionIndex;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref selectedMarkAsOptionIndex, value) && value >= 0)
|
||||
{
|
||||
PreferencesService.MarkAsPreference = (MailMarkAsOption)Enum.GetValues<MailMarkAsOption>().GetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int selectedMailSpacingIndex;
|
||||
public int SelectedMailSpacingIndex
|
||||
{
|
||||
get => selectedMailSpacingIndex;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref selectedMailSpacingIndex, value) && value >= 0 && value < availableMailSpacingOptions.Count)
|
||||
{
|
||||
PreferencesService.MailItemDisplayMode = availableMailSpacingOptions[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Properties
|
||||
private int leftHoverActionIndex;
|
||||
public int LeftHoverActionIndex
|
||||
@@ -88,13 +107,19 @@ public partial class MessageListPageViewModel : MailBaseViewModel
|
||||
}
|
||||
#endregion
|
||||
|
||||
public MessageListPageViewModel(IPreferencesService preferencesService, IThumbnailService thumbnailService)
|
||||
public MessageListPageViewModel(IPreferencesService preferencesService,
|
||||
IThumbnailService thumbnailService,
|
||||
IStatePersistanceService statePersistenceService,
|
||||
IDialogServiceBase dialogService)
|
||||
{
|
||||
PreferencesService = preferencesService;
|
||||
_thumbnailService = thumbnailService;
|
||||
_statePersistenceService = statePersistenceService;
|
||||
_dialogService = dialogService;
|
||||
leftHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.LeftHoverAction);
|
||||
centerHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.CenterHoverAction);
|
||||
rightHoverActionIndex = availableHoverActions.IndexOf(PreferencesService.RightHoverAction);
|
||||
selectedMailSpacingIndex = availableMailSpacingOptions.IndexOf(PreferencesService.MailItemDisplayMode);
|
||||
SelectedMarkAsOptionIndex = Array.IndexOf(Enum.GetValues<MailMarkAsOption>(), PreferencesService.MarkAsPreference);
|
||||
}
|
||||
|
||||
@@ -103,4 +128,11 @@ public partial class MessageListPageViewModel : MailBaseViewModel
|
||||
{
|
||||
await _thumbnailService.ClearCache();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ResetMailListPaneLength()
|
||||
{
|
||||
_statePersistenceService.MailListPaneLength = 420;
|
||||
_dialogService.InfoBarMessage(Translator.GeneralTitle_Info, Translator.Info_MailListSizeResetSuccessMessage, InfoBarMessageType.Success);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user