Added language & time page
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
MessageListPage,
|
MessageListPage,
|
||||||
MailListPage,
|
MailListPage,
|
||||||
ReadingPanePage,
|
ReadingPanePage,
|
||||||
SettingOptionsPage
|
LanguageTimePage,
|
||||||
|
SettingOptionsPage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
49
Wino.Mail.ViewModels/LanguageTimePageViewModel.cs
Normal file
49
Wino.Mail.ViewModels/LanguageTimePageViewModel.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using Wino.Core.Domain.Interfaces;
|
||||||
|
using Wino.Core.Domain.Models.Navigation;
|
||||||
|
using Wino.Core.Domain.Models.Translations;
|
||||||
|
|
||||||
|
namespace Wino.Mail.ViewModels
|
||||||
|
{
|
||||||
|
public partial class LanguageTimePageViewModel(IDialogService dialogService,
|
||||||
|
IPreferencesService preferencesService,
|
||||||
|
ITranslationService translationService) : BaseViewModel(dialogService)
|
||||||
|
{
|
||||||
|
public IPreferencesService PreferencesService { get; } = preferencesService;
|
||||||
|
private readonly ITranslationService _translationService = translationService;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private List<AppLanguageModel> _availableLanguages;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private AppLanguageModel _selectedLanguage;
|
||||||
|
|
||||||
|
private bool isInitialized = false;
|
||||||
|
|
||||||
|
public override void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||||
|
{
|
||||||
|
base.OnNavigatedTo(mode, parameters);
|
||||||
|
|
||||||
|
AvailableLanguages = _translationService.GetAvailableLanguages();
|
||||||
|
|
||||||
|
SelectedLanguage = AvailableLanguages.FirstOrDefault(a => a.Language == PreferencesService.CurrentLanguage);
|
||||||
|
|
||||||
|
isInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPropertyChanged(e);
|
||||||
|
|
||||||
|
if (!isInitialized) return;
|
||||||
|
|
||||||
|
if (e.PropertyName == nameof(SelectedLanguage))
|
||||||
|
{
|
||||||
|
await _translationService.InitializeLanguageAsync(SelectedLanguage.Language);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +1,15 @@
|
|||||||
using System.Collections.Generic;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Wino.Core.Domain.Enums;
|
using Wino.Core.Domain.Enums;
|
||||||
using Wino.Core.Domain.Interfaces;
|
using Wino.Core.Domain.Interfaces;
|
||||||
using Wino.Core.Domain.Models.Navigation;
|
using Wino.Core.Domain.Models.Navigation;
|
||||||
using Wino.Core.Domain.Models.Translations;
|
|
||||||
using Wino.Core.Messages.Navigation;
|
using Wino.Core.Messages.Navigation;
|
||||||
|
|
||||||
namespace Wino.Mail.ViewModels
|
namespace Wino.Mail.ViewModels
|
||||||
{
|
{
|
||||||
public partial class SettingOptionsPageViewModel : BaseViewModel
|
public partial class SettingOptionsPageViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
private readonly ITranslationService _translationService;
|
public SettingOptionsPageViewModel(IDialogService dialogService) : base(dialogService) { }
|
||||||
private readonly IPreferencesService _preferencesService;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private List<AppLanguageModel> _availableLanguages;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private AppLanguageModel _selectedLanguage;
|
|
||||||
|
|
||||||
private bool isInitialized = false;
|
|
||||||
|
|
||||||
public SettingOptionsPageViewModel(IDialogService dialogService,
|
|
||||||
ITranslationService translationService,
|
|
||||||
IPreferencesService preferencesService) : base(dialogService)
|
|
||||||
{
|
|
||||||
_translationService = translationService;
|
|
||||||
_preferencesService = preferencesService;
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void GoAccountSettings() => Messenger.Send<NavigateSettingsRequested>();
|
private void GoAccountSettings() => Messenger.Send<NavigateSettingsRequested>();
|
||||||
@@ -39,24 +17,6 @@ namespace Wino.Mail.ViewModels
|
|||||||
public override void OnNavigatedTo(NavigationMode mode, object parameters)
|
public override void OnNavigatedTo(NavigationMode mode, object parameters)
|
||||||
{
|
{
|
||||||
base.OnNavigatedTo(mode, parameters);
|
base.OnNavigatedTo(mode, parameters);
|
||||||
|
|
||||||
AvailableLanguages = _translationService.GetAvailableLanguages();
|
|
||||||
|
|
||||||
SelectedLanguage = AvailableLanguages.FirstOrDefault(a => a.Language == _preferencesService.CurrentLanguage);
|
|
||||||
|
|
||||||
isInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async void OnPropertyChanged(PropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnPropertyChanged(e);
|
|
||||||
|
|
||||||
if (!isInitialized) return;
|
|
||||||
|
|
||||||
if (e.PropertyName == nameof(SelectedLanguage))
|
|
||||||
{
|
|
||||||
await _translationService.InitializeLanguageAsync(SelectedLanguage.Language);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -77,6 +37,8 @@ namespace Wino.Mail.ViewModels
|
|||||||
pageType = WinoPage.MessageListPage;
|
pageType = WinoPage.MessageListPage;
|
||||||
else if (stringParameter == "Reading Pane")
|
else if (stringParameter == "Reading Pane")
|
||||||
pageType = WinoPage.ReadingPanePage;
|
pageType = WinoPage.ReadingPanePage;
|
||||||
|
else if (stringParameter == "Language And Time")
|
||||||
|
pageType = WinoPage.LanguageTimePage;
|
||||||
|
|
||||||
Messenger.Send(new BreadcrumbNavigationRequested(pageTitle, pageType));
|
Messenger.Send(new BreadcrumbNavigationRequested(pageTitle, pageType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ namespace Wino
|
|||||||
services.AddTransient(typeof(MessageListPageViewModel));
|
services.AddTransient(typeof(MessageListPageViewModel));
|
||||||
services.AddTransient(typeof(ReadingPanePageViewModel));
|
services.AddTransient(typeof(ReadingPanePageViewModel));
|
||||||
services.AddTransient(typeof(MergedAccountDetailsPageViewModel));
|
services.AddTransient(typeof(MergedAccountDetailsPageViewModel));
|
||||||
|
services.AddTransient(typeof(LanguageTimePageViewModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ namespace Wino.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCreationDateString(DateTime date)
|
public static string GetCreationDateString(DateTime date, bool prefer24HourTime)
|
||||||
{
|
{
|
||||||
var localTime = date.ToLocalTime();
|
var localTime = date.ToLocalTime();
|
||||||
return $"{localTime.ToLongDateString()} {localTime.ToLongTimeString()}";
|
return $"{localTime.ToLongDateString()} {(prefer24HourTime ? localTime.ToString("HH:mm:ss") : localTime.ToLongTimeString())}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetMailGroupDateString(object groupObject)
|
public static string GetMailGroupDateString(object groupObject)
|
||||||
|
|||||||
6
Wino.Mail/Views/Abstract/LanguageTimePageAbstract.cs
Normal file
6
Wino.Mail/Views/Abstract/LanguageTimePageAbstract.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
using Wino.Mail.ViewModels;
|
||||||
|
|
||||||
|
namespace Wino.Views.Abstract
|
||||||
|
{
|
||||||
|
public abstract class LanguageTimePageAbstract : BasePage<LanguageTimePageViewModel> { }
|
||||||
|
}
|
||||||
@@ -196,7 +196,7 @@
|
|||||||
<Run Text="<" /><Run Text="{x:Bind ViewModel.FromAddress, Mode=OneWay}" /><Run Text=">" />
|
<Run Text="<" /><Run Text="{x:Bind ViewModel.FromAddress, Mode=OneWay}" /><Run Text=">" />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</HyperlinkButton>
|
</HyperlinkButton>
|
||||||
<TextBlock FontSize="12" Text="{x:Bind helpers:XamlHelpers.GetCreationDateString(ViewModel.CreationDate), Mode=OneWay}" />
|
<TextBlock FontSize="12" Text="{x:Bind helpers:XamlHelpers.GetCreationDateString(ViewModel.CreationDate, ViewModel.PreferencesService.Prefer24HourTimeFormat), Mode=OneWay}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
38
Wino.Mail/Views/Settings/LanguageTimePage.xaml
Normal file
38
Wino.Mail/Views/Settings/LanguageTimePage.xaml
Normal file
File diff suppressed because one or more lines are too long
19
Wino.Mail/Views/Settings/LanguageTimePage.xaml.cs
Normal file
19
Wino.Mail/Views/Settings/LanguageTimePage.xaml.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Wino.Views.Abstract;
|
||||||
|
|
||||||
|
namespace Wino.Views.Settings
|
||||||
|
{
|
||||||
|
public sealed partial class LanguageTimePage : LanguageTimePageAbstract
|
||||||
|
{
|
||||||
|
public LanguageTimePage()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnLanguageChanged()
|
||||||
|
{
|
||||||
|
base.OnLanguageChanged();
|
||||||
|
|
||||||
|
Bindings.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -8,12 +8,5 @@ namespace Wino.Views.Settings
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnLanguageChanged()
|
|
||||||
{
|
|
||||||
base.OnLanguageChanged();
|
|
||||||
|
|
||||||
Bindings.Update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,22 +46,15 @@ namespace Wino.Views
|
|||||||
settingsHeader.Title = Translator.MenuSettings;
|
settingsHeader.Title = Translator.MenuSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Type GetNavigationPageType(WinoPage page)
|
private Type GetNavigationPageType(WinoPage page) => page switch
|
||||||
{
|
{
|
||||||
switch (page)
|
WinoPage.AboutPage => typeof(AboutPage),
|
||||||
{
|
WinoPage.PersonalizationPage => typeof(PersonalizationPage),
|
||||||
case WinoPage.AboutPage:
|
WinoPage.MessageListPage => typeof(MessageListPage),
|
||||||
return typeof(AboutPage);
|
WinoPage.ReadingPanePage => typeof(ReadingPanePage),
|
||||||
case WinoPage.PersonalizationPage:
|
WinoPage.LanguageTimePage => typeof(LanguageTimePage),
|
||||||
return typeof(PersonalizationPage);
|
_ => null,
|
||||||
case WinoPage.MessageListPage:
|
};
|
||||||
return typeof(MessageListPage);
|
|
||||||
case WinoPage.ReadingPanePage:
|
|
||||||
return typeof(ReadingPanePage);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
void IRecipient<BreadcrumbNavigationRequested>.Receive(BreadcrumbNavigationRequested message)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -356,6 +356,7 @@
|
|||||||
<Compile Include="Views\Abstract\AppShellAbstract.cs" />
|
<Compile Include="Views\Abstract\AppShellAbstract.cs" />
|
||||||
<Compile Include="Views\Abstract\ComposePageAbstract.cs" />
|
<Compile Include="Views\Abstract\ComposePageAbstract.cs" />
|
||||||
<Compile Include="Views\Abstract\IdlePageAbstract.cs" />
|
<Compile Include="Views\Abstract\IdlePageAbstract.cs" />
|
||||||
|
<Compile Include="Views\Abstract\LanguageTimePageAbstract.cs" />
|
||||||
<Compile Include="Views\Abstract\MailListPageAbstract.cs" />
|
<Compile Include="Views\Abstract\MailListPageAbstract.cs" />
|
||||||
<Compile Include="Views\Abstract\MailRenderingPageAbstract.cs" />
|
<Compile Include="Views\Abstract\MailRenderingPageAbstract.cs" />
|
||||||
<Compile Include="Views\Abstract\MergedAccountDetailsPageAbstract.cs" />
|
<Compile Include="Views\Abstract\MergedAccountDetailsPageAbstract.cs" />
|
||||||
@@ -413,6 +414,9 @@
|
|||||||
<Compile Include="Views\Settings\AboutPage.xaml.cs">
|
<Compile Include="Views\Settings\AboutPage.xaml.cs">
|
||||||
<DependentUpon>AboutPage.xaml</DependentUpon>
|
<DependentUpon>AboutPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\Settings\LanguageTimePage.xaml.cs">
|
||||||
|
<DependentUpon>LanguageTimePage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\Settings\MessageListPage.xaml.cs">
|
<Compile Include="Views\Settings\MessageListPage.xaml.cs">
|
||||||
<DependentUpon>MessageListPage.xaml</DependentUpon>
|
<DependentUpon>MessageListPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -626,6 +630,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Settings\LanguageTimePage.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Settings\MessageListPage.xaml">
|
<Page Include="Views\Settings\MessageListPage.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
Reference in New Issue
Block a user