From f1060bebe21576fbc43335d3754869e702cf6b5e Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Mon, 16 May 2022 08:29:41 -0400 Subject: [PATCH 01/24] Moved discord api status converters --- .../Discord/{ => APIStatus}/StatusToBrushConverter.cs | 2 +- .../Discord/{ => APIStatus}/StatusToColorConverter.cs | 2 +- src/Quarrel/Quarrel.csproj | 4 ++-- src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml | 4 ++-- src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename src/Quarrel/Converters/Discord/{ => APIStatus}/StatusToBrushConverter.cs (83%) rename src/Quarrel/Converters/Discord/{ => APIStatus}/StatusToColorConverter.cs (90%) diff --git a/src/Quarrel/Converters/Discord/StatusToBrushConverter.cs b/src/Quarrel/Converters/Discord/APIStatus/StatusToBrushConverter.cs similarity index 83% rename from src/Quarrel/Converters/Discord/StatusToBrushConverter.cs rename to src/Quarrel/Converters/Discord/APIStatus/StatusToBrushConverter.cs index 5fbefffad..001e56a82 100644 --- a/src/Quarrel/Converters/Discord/StatusToBrushConverter.cs +++ b/src/Quarrel/Converters/Discord/APIStatus/StatusToBrushConverter.cs @@ -2,7 +2,7 @@ using Windows.UI.Xaml.Media; -namespace Quarrel.Converters +namespace Quarrel.Converters.Discord.APIStatus { public static class StatusToBrushConverter { diff --git a/src/Quarrel/Converters/Discord/StatusToColorConverter.cs b/src/Quarrel/Converters/Discord/APIStatus/StatusToColorConverter.cs similarity index 90% rename from src/Quarrel/Converters/Discord/StatusToColorConverter.cs rename to src/Quarrel/Converters/Discord/APIStatus/StatusToColorConverter.cs index 82a07b1fc..279a728ee 100644 --- a/src/Quarrel/Converters/Discord/StatusToColorConverter.cs +++ b/src/Quarrel/Converters/Discord/APIStatus/StatusToColorConverter.cs @@ -2,7 +2,7 @@ using Windows.UI; -namespace Quarrel.Converters +namespace Quarrel.Converters.Discord.APIStatus { public static class StatusToColorConverter { diff --git a/src/Quarrel/Quarrel.csproj b/src/Quarrel/Quarrel.csproj index c39b43f90..861d8c222 100644 --- a/src/Quarrel/Quarrel.csproj +++ b/src/Quarrel/Quarrel.csproj @@ -158,8 +158,8 @@ - - + + diff --git a/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml b/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml index e3e1cf79a..7d12642c8 100644 --- a/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml +++ b/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml @@ -5,7 +5,7 @@ xmlns:local="using:Quarrel.SubPages.DiscordStatus" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:convert="using:Quarrel.Converters" + xmlns:sconvert="using:Quarrel.Converters.Discord.APIStatus" xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml" xmlns:models="using:Quarrel.ViewModels.SubPages.DiscordStatus.Models" mc:Ignorable="d" @@ -132,7 +132,7 @@ - + diff --git a/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml.cs b/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml.cs index f478bfe20..0af916e14 100644 --- a/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml.cs +++ b/src/Quarrel/SubPages/DiscordStatus/DiscordStatusPage.xaml.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Graphics.Canvas.Text; using Microsoft.Graphics.Canvas.UI.Xaml; -using Quarrel.Converters; +using Quarrel.Converters.Discord.APIStatus; using Quarrel.ViewModels.SubPages.DiscordStatus; using System; using System.Globalization; From 94a3404404eb7fb750da6f3d59281989733c1fb3 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Tue, 17 May 2022 00:31:54 -0400 Subject: [PATCH 02/24] Added video attachment support --- src/Quarrel/DataTemplates/MessageTemplates.xaml | 16 ++++++++++++++-- .../Messages/AttachmentTemplateSelector.cs | 13 ++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/Quarrel/DataTemplates/MessageTemplates.xaml b/src/Quarrel/DataTemplates/MessageTemplates.xaml index 7fbdcc275..1e5777b68 100644 --- a/src/Quarrel/DataTemplates/MessageTemplates.xaml +++ b/src/Quarrel/DataTemplates/MessageTemplates.xaml @@ -8,7 +8,6 @@ xmlns:tconvert="using:Quarrel.Converters.Common.Time" xmlns:mconvert="using:Quarrel.Converters.Discord.Messages" xmlns:qc="using:Quarrel.Controls" - xmlns:mcontrols="using:Quarrel.Controls.Panels.Messages" xmlns:bindablemessages="using:Quarrel.Bindables.Messages" xmlns:bindableembeds="using:Quarrel.Bindables.Messages.Embeds" xmlns:mselector="using:Quarrel.Selectors.Messages" @@ -55,9 +54,22 @@ + + + + + + + + + + + ImageAttachmentTemplate="{StaticResource ImageAttachmentTemplate}" + AudioAttachmentTemplate="{StaticResource DefaultAttachmentTemplate}" + VideoAttachmentTemplate="{StaticResource VideoAttachmentTemplate}"/> diff --git a/src/Quarrel/Selectors/Messages/AttachmentTemplateSelector.cs b/src/Quarrel/Selectors/Messages/AttachmentTemplateSelector.cs index 3a50de003..f45a61fc1 100644 --- a/src/Quarrel/Selectors/Messages/AttachmentTemplateSelector.cs +++ b/src/Quarrel/Selectors/Messages/AttachmentTemplateSelector.cs @@ -12,6 +12,10 @@ public class AttachmentTemplateSelector : DataTemplateSelector public DataTemplate? ImageAttachmentTemplate { get; set; } + public DataTemplate? AudioAttachmentTemplate { get; set; } + + public DataTemplate? VideoAttachmentTemplate { get; set; } + protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { if (item is BindableAttachment attachment) @@ -23,9 +27,12 @@ protected override DataTemplate SelectTemplateCore(object item, DependencyObject "jpeg" or "gif" => ImageAttachmentTemplate, - //"mp4" or - //"mov" or - //"wmv" => VideoAttachmentTemplate + "mp3" or + "wav" => AudioAttachmentTemplate, + + "mp4" or + "mov" or + "wmv" => VideoAttachmentTemplate, _ => DefaultAttachmentTemplate, }; From 748b4fc16183108445381375dff0cca6db9727c2 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Wed, 18 May 2022 03:52:36 -0400 Subject: [PATCH 03/24] Added empty list handle for CommaList --- src/Quarrel/Services/Localization/LocalizationService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Quarrel/Services/Localization/LocalizationService.cs b/src/Quarrel/Services/Localization/LocalizationService.cs index f108a04d4..7ff92f1fe 100644 --- a/src/Quarrel/Services/Localization/LocalizationService.cs +++ b/src/Quarrel/Services/Localization/LocalizationService.cs @@ -63,7 +63,11 @@ public string LanguageOverride public string CommaList(params string[] args) { - if (args.Length == 1) + if (args.Length == 0) + { + return string.Empty; + } + else if (args.Length == 1) { return args[0]; } From b0d670564901d997eacf0466f146089ef9404773 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Wed, 18 May 2022 04:38:07 -0400 Subject: [PATCH 04/24] Hide new window button --- src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml b/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml index acfa3025a..aa77e871c 100644 --- a/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml +++ b/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml @@ -73,6 +73,7 @@ ToolTipService.ToolTip="Open Channel in New Window" ToolTipService.Placement="Bottom" Style="{StaticResource CommandBarButton}" + Visibility="Collapsed" Click="OpenInNewWindow"> From 52c39b901299849f29eff8da86dc4e4b2956999f Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Wed, 18 May 2022 05:04:32 -0400 Subject: [PATCH 05/24] Disabled send box when draft is empty or whitespace --- src/Quarrel/Controls/Panels/Messages/MessageBox.xaml | 4 +++- .../Common/Boolean/IsNotWhiteSpaceConverter.cs | 9 +++++++++ src/Quarrel/Quarrel.csproj | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/Quarrel/Converters/Common/Boolean/IsNotWhiteSpaceConverter.cs diff --git a/src/Quarrel/Controls/Panels/Messages/MessageBox.xaml b/src/Quarrel/Controls/Panels/Messages/MessageBox.xaml index 6745c9ee6..b3fca93a6 100644 --- a/src/Quarrel/Controls/Panels/Messages/MessageBox.xaml +++ b/src/Quarrel/Controls/Panels/Messages/MessageBox.xaml @@ -5,6 +5,7 @@ xmlns:local="using:Quarrel.Controls.Shell.Panels.Messages" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:bconvert="using:Quarrel.Converters.Common.Boolean" mc:Ignorable="d" d:DesignHeight="64" d:DesignWidth="400"> @@ -245,7 +246,7 @@ diff --git a/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf b/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf index 685872396..f76fd5834 100644 --- a/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf +++ b/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf @@ -399,6 +399,18 @@ Version: {0}.{1}.{2} גרסת: {0}.{1}.{2} + + Personal Settings + Personal Settings + + + Server Settings + Server Settings + + + User Management + User Management + diff --git a/src/Quarrel/Quarrel.csproj b/src/Quarrel/Quarrel.csproj index 481bca362..922c083e2 100644 --- a/src/Quarrel/Quarrel.csproj +++ b/src/Quarrel/Quarrel.csproj @@ -184,6 +184,8 @@ + + @@ -209,6 +211,9 @@ DiscordStatusPage.xaml + + GuildSettingsPage.xaml + AboutPage.xaml @@ -590,6 +595,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs b/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs new file mode 100644 index 000000000..61a196dfd --- /dev/null +++ b/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs @@ -0,0 +1,25 @@ +// Quarrel © 2022 + +using Quarrel.ViewModels.SubPages.GuildSettings; +using Quarrel.ViewModels.SubPages.GuildSettings.Pages.Abstract; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Quarrel.Selectors.SubPages.GuildSettings +{ + public class GuildSettingsMenuItemSelector : DataTemplateSelector + { + public DataTemplate? HeaderItem { get; set; } + + public DataTemplate? MenuItem { get; set; } + + protected override DataTemplate SelectTemplateCore(object item) + { + return item switch + { + GuildSettingsHeader => HeaderItem, + GuildSettingsSubPageViewModel or _ => MenuItem, + }; + } + } +} diff --git a/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs b/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs new file mode 100644 index 000000000..9e40caf5a --- /dev/null +++ b/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs @@ -0,0 +1,18 @@ +// Quarrel © 2022 + +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Quarrel.Selectors.SubPages.UserSettings +{ + public class GuildSettingsPageSelector : DataTemplateSelector + { + protected override DataTemplate? SelectTemplateCore(object item, DependencyObject container) + { + return item switch + { + _ => null, + }; + } + } +} diff --git a/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs b/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs index 46c250904..2bf110ee4 100644 --- a/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs +++ b/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs @@ -1,6 +1,7 @@ // Quarrel © 2022 using Quarrel.ViewModels.SubPages.DiscordStatus; +using Quarrel.ViewModels.SubPages.GuildSettings; using Quarrel.ViewModels.SubPages.Meta; using Quarrel.ViewModels.SubPages.Settings; using Windows.UI.Xaml; @@ -16,8 +17,9 @@ public class SubPageTemplateSelector : DataTemplateSelector public DataTemplate? DiscordStatusTemplate { get; set; } - public DataTemplate? UserSettingsTemplate { get; set; } + public DataTemplate? GuildSettingsTemplate { get; set; } + public DataTemplate? UserSettingsTemplate { get; set; } /// protected override DataTemplate? SelectTemplateCore(object item, DependencyObject container) @@ -27,6 +29,7 @@ public class SubPageTemplateSelector : DataTemplateSelector AboutPageViewModel => AboutTemplate, CreditPageViewModel => CreditTemplate, DiscordStatusViewModel => DiscordStatusTemplate, + GuildSettingsPageViewModel => GuildSettingsTemplate, UserSettingsPageViewModel => UserSettingsTemplate, _ => null, }; diff --git a/src/Quarrel/Strings/en-US/Resources.resw b/src/Quarrel/Strings/en-US/Resources.resw index 60bd77a56..b4a81eb5f 100644 --- a/src/Quarrel/Strings/en-US/Resources.resw +++ b/src/Quarrel/Strings/en-US/Resources.resw @@ -264,6 +264,15 @@ Home + + Personal Settings + + + Server Settings + + + User Management + {author} started a call diff --git a/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml b/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml new file mode 100644 index 000000000..bbde3c233 --- /dev/null +++ b/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml.cs b/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml.cs new file mode 100644 index 000000000..ec2f11b14 --- /dev/null +++ b/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml.cs @@ -0,0 +1,17 @@ +// Quarrel © 2022 + +using Quarrel.ViewModels.SubPages.GuildSettings; +using Windows.UI.Xaml.Controls; + +namespace Quarrel.SubPages.GuildSettings +{ + public sealed partial class GuildSettingsPage : UserControl + { + public GuildSettingsPage() + { + this.InitializeComponent(); + } + + public GuildSettingsPageViewModel ViewModel => (GuildSettingsPageViewModel)DataContext; + } +} diff --git a/src/Quarrel/SubPages/Host/SubPageHost.xaml b/src/Quarrel/SubPages/Host/SubPageHost.xaml index aa3af70c3..59ddd8afb 100644 --- a/src/Quarrel/SubPages/Host/SubPageHost.xaml +++ b/src/Quarrel/SubPages/Host/SubPageHost.xaml @@ -9,6 +9,7 @@ xmlns:sselectors="using:Quarrel.Selectors.SubPages" xmlns:statuspage="using:Quarrel.SubPages.DiscordStatus" xmlns:metapages="using:Quarrel.SubPages.Meta" + xmlns:guildsettings="using:Quarrel.SubPages.GuildSettings" xmlns:usersettings="using:Quarrel.SubPages.UserSettings" mc:Ignorable="d" d:DesignHeight="300" @@ -28,6 +29,10 @@ + + + + @@ -36,6 +41,7 @@ AboutTemplate="{StaticResource AboutPageTemplate}" CreditTemplate="{StaticResource CreditPageTemplate}" DiscordStatusTemplate="{StaticResource DiscordStatusPageTemplate}" + GuildSettingsTemplate="{StaticResource GuildSettingsPageTemplate}" UserSettingsTemplate="{StaticResource UserSettingsPageTemplate}"/> From f84b9cc86f22fe070b84422d7d7936253c8f5a51 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 13:00:18 -0400 Subject: [PATCH 08/24] Abstracted User and Guild settings --- .../ViewModels/CurrentUserViewModel.cs | 2 +- .../ViewModels/Panels/GuildsViewModel.cs | 2 +- .../GuildSettings/GuildSettingsHeader.cs | 21 --------- .../GuildSettings/IGuildSettingsMenuItem.cs | 15 ------- .../Abstract/GuildSettingsSubPageViewModel.cs | 45 ------------------- .../Abstract/SettingSubPageViewModel.cs} | 8 ++-- .../GuildSettingsPageViewModel.cs | 19 ++++---- .../ISettingsMenuItem.cs} | 6 +-- .../Settings/SettingsCategoryHeader.cs | 20 +++++++++ .../Pages/BehaviorPageViewModel.cs | 6 +-- .../Pages/ConnectionsPageViewModel.cs | 6 +-- .../Pages/DisplayPageViewModel.cs | 6 +-- .../Pages/MyAccountPageViewModel.cs | 6 +-- .../Pages/NotificationsPageViewModel.cs | 6 +-- .../Pages/PrivacyPageViewModel.cs | 6 +-- .../UserSettings/Pages/VoicePageViewModel.cs | 6 +-- .../UserSettings/UserSettingsPageViewModel.cs | 19 ++++---- .../UserSettings/UserSettingsHeader.cs | 21 --------- src/Quarrel/App.Services.cs | 4 +- .../Controls/Shell/QuarrelCommandBar.xaml.cs | 2 +- src/Quarrel/Quarrel.csproj | 26 +++++------ .../GuildSettingsMenuItemSelector.cs | 25 ----------- .../GuildSettingsPageSelector.cs | 18 -------- .../SettingsMenuItemSelector.cs} | 12 ++--- .../SettingsPageSelector.cs} | 6 +-- .../SubPages/SubPageTemplateSelector.cs | 4 +- src/Quarrel/SubPages/Host/SubPageHost.xaml | 4 +- .../GuildSettings/GuildSettingsPage.xaml | 23 +++++----- .../GuildSettings/GuildSettingsPage.xaml.cs | 4 +- .../UserSettings/Pages/DisplayPage.xaml | 2 +- .../UserSettings/Pages/DisplayPage.xaml.cs | 4 +- .../UserSettings/Pages/MyAccountPage.xaml | 4 +- .../UserSettings/Pages/MyAccountPage.xaml.cs | 4 +- .../UserSettings/Pages/PrivacyPage.xaml | 4 +- .../UserSettings/Pages/PrivacyPage.xaml.cs | 4 +- .../UserSettings/UserSettingsPage.xaml | 39 ++++++++-------- .../UserSettings/UserSettingsPage.xaml.cs | 4 +- 37 files changed, 141 insertions(+), 272 deletions(-) delete mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsHeader.cs delete mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/IGuildSettingsMenuItem.cs delete mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs rename src/Quarrel.ViewModels/ViewModels/SubPages/{UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs => Settings/Abstract/SettingSubPageViewModel.cs} (75%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/GuildSettings/GuildSettingsPageViewModel.cs (63%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{UserSettings/IUserSettingsMenuItem.cs => Settings/ISettingsMenuItem.cs} (54%) create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/BehaviorPageViewModel.cs (77%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/ConnectionsPageViewModel.cs (77%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/DisplayPageViewModel.cs (86%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/MyAccountPageViewModel.cs (93%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/NotificationsPageViewModel.cs (77%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/PrivacyPageViewModel.cs (94%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/Pages/VoicePageViewModel.cs (77%) rename src/Quarrel.ViewModels/ViewModels/SubPages/{ => Settings}/UserSettings/UserSettingsPageViewModel.cs (73%) delete mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsHeader.cs delete mode 100644 src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs delete mode 100644 src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs rename src/Quarrel/Selectors/SubPages/{UserSettings/UserSettingsMenuItemSelector.cs => Settings/SettingsMenuItemSelector.cs} (50%) rename src/Quarrel/Selectors/SubPages/{UserSettings/UserSettingsPageSelector.cs => Settings/SettingsPageSelector.cs} (87%) rename src/Quarrel/SubPages/{ => Settings}/GuildSettings/GuildSettingsPage.xaml (65%) rename src/Quarrel/SubPages/{ => Settings}/GuildSettings/GuildSettingsPage.xaml.cs (75%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/Pages/DisplayPage.xaml (90%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/Pages/DisplayPage.xaml.cs (72%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/Pages/MyAccountPage.xaml (94%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/Pages/MyAccountPage.xaml.cs (72%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/Pages/PrivacyPage.xaml (96%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/Pages/PrivacyPage.xaml.cs (72%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/UserSettingsPage.xaml (56%) rename src/Quarrel/SubPages/{ => Settings}/UserSettings/UserSettingsPage.xaml.cs (75%) diff --git a/src/Quarrel.ViewModels/ViewModels/CurrentUserViewModel.cs b/src/Quarrel.ViewModels/ViewModels/CurrentUserViewModel.cs index d4ffbead7..b16abb4a6 100644 --- a/src/Quarrel.ViewModels/ViewModels/CurrentUserViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/CurrentUserViewModel.cs @@ -11,7 +11,7 @@ using Quarrel.Services.Analytics.Enums; using Quarrel.Services.Discord; using Quarrel.Services.Dispatcher; -using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.UserSettings; using System; namespace Quarrel.ViewModels diff --git a/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs b/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs index 3fe8b87dd..a5f57733c 100644 --- a/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs @@ -13,7 +13,7 @@ using Quarrel.Services.Discord; using Quarrel.Services.Dispatcher; using Quarrel.Services.Localization; -using Quarrel.ViewModels.SubPages.GuildSettings; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings; using System.Collections.Concurrent; using System.Collections.ObjectModel; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsHeader.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsHeader.cs deleted file mode 100644 index 44dbdfb96..000000000 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsHeader.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Quarrel © 2022 - -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Quarrel.Services.Localization; - -namespace Quarrel.ViewModels.SubPages.GuildSettings -{ - /// - /// A header for a category of guild settings menu items. - /// - public class GuildSettingsHeader : ObservableObject, IGuildSettingsMenuItem - { - internal GuildSettingsHeader(ILocalizationService localizationService, string resource) - { - Title = localizationService[resource]; - } - - /// - public string Title { get; } - } -} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/IGuildSettingsMenuItem.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/IGuildSettingsMenuItem.cs deleted file mode 100644 index 746c9dd22..000000000 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/IGuildSettingsMenuItem.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Quarrel © 2022 - -namespace Quarrel.ViewModels.SubPages.GuildSettings -{ - /// - /// An interface for items in the guild settings navigation menu. - /// - public interface IGuildSettingsMenuItem - { - /// - /// Gets the title of the menu item. - /// - string Title { get; } - } -} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs deleted file mode 100644 index 61edcef08..000000000 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Quarrel © 2022 - -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Quarrel.Services.Localization; -using Quarrel.Services.Storage; - -namespace Quarrel.ViewModels.SubPages.GuildSettings.Pages.Abstract -{ - /// - /// A base class for guild settings sub-page view models. - /// - public abstract class GuildSettingsSubPageViewModel : ObservableObject, IGuildSettingsMenuItem - { - /// - /// The localization service. - /// - protected readonly ILocalizationService _localizationService; - - /// - /// The storage service. - /// - protected readonly IStorageService _storageService; - - internal GuildSettingsSubPageViewModel(ILocalizationService localizationService, IStorageService storageService) - { - _localizationService = localizationService; - _storageService = storageService; - } - - /// - /// Gets the string used as a glyph for the sub page. - /// - public abstract string Glyph { get; } - - /// - /// Gets the title of the sub page. - /// - public abstract string Title { get; } - - /// - /// Gets whether or not the page is currently active. - /// - public virtual bool IsActive => false; - } -} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs similarity index 75% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs index c91a0a105..39e5d75f1 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs @@ -4,12 +4,12 @@ using Quarrel.Services.Localization; using Quarrel.Services.Storage; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract +namespace Quarrel.ViewModels.SubPages.Settings.Abstract { /// - /// A base class for user settings sub-page view models. + /// A base class for settings sub-page view models. /// - public abstract class UserSettingsSubPageViewModel : ObservableObject, IUserSettingsMenuItem + public abstract class SettingsSubPageViewModel : ObservableObject, ISettingsMenuItem { /// /// The localization service. @@ -21,7 +21,7 @@ public abstract class UserSettingsSubPageViewModel : ObservableObject, IUserSett /// protected readonly IStorageService _storageService; - internal UserSettingsSubPageViewModel(ILocalizationService localizationService, IStorageService storageService) + internal SettingsSubPageViewModel(ILocalizationService localizationService, IStorageService storageService) { _localizationService = localizationService; _storageService = storageService; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs similarity index 63% rename from src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs index e21c6df6f..41ce0d118 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs @@ -2,10 +2,11 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Quarrel.Services.Localization; -using Quarrel.ViewModels.SubPages.GuildSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.Abstract; using System.Collections.ObjectModel; -namespace Quarrel.ViewModels.SubPages.GuildSettings +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings { /// /// A view model for the guild settings page. @@ -16,29 +17,29 @@ public class GuildSettingsPageViewModel : ObservableObject private const string ServerSettingsResource = "GuildSettings/ServerSettings"; private const string UserManagementResource = "GuildSettings/UserManagement"; - private GuildSettingsSubPageViewModel? _selectedSubPage; + private SettingsSubPageViewModel? _selectedSubPage; /// /// Initializes a new instance of the . /// public GuildSettingsPageViewModel(ILocalizationService localizationService) { - Pages = new ObservableCollection(); + Pages = new ObservableCollection(); // Personal Settings - Pages.Add(new GuildSettingsHeader(localizationService, PersonalSettingsResource)); + Pages.Add(new SettingsCategoryHeader(localizationService, PersonalSettingsResource)); // Server Settings - Pages.Add(new GuildSettingsHeader(localizationService, ServerSettingsResource)); + Pages.Add(new SettingsCategoryHeader(localizationService, ServerSettingsResource)); // User management - Pages.Add(new GuildSettingsHeader(localizationService, UserManagementResource)); + Pages.Add(new SettingsCategoryHeader(localizationService, UserManagementResource)); } /// /// Gets the view model of the selected sub page. /// - public GuildSettingsSubPageViewModel? SelectedSubPage + public SettingsSubPageViewModel? SelectedSubPage { get => _selectedSubPage; set => SetProperty(ref _selectedSubPage, value); @@ -47,6 +48,6 @@ public GuildSettingsSubPageViewModel? SelectedSubPage /// /// Gets the view models of all sub page options. /// - public ObservableCollection Pages { get; } + public ObservableCollection Pages { get; } } } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/IUserSettingsMenuItem.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/ISettingsMenuItem.cs similarity index 54% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/IUserSettingsMenuItem.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/ISettingsMenuItem.cs index 4e343b4ee..153131793 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/IUserSettingsMenuItem.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/ISettingsMenuItem.cs @@ -1,11 +1,11 @@ // Quarrel © 2022 -namespace Quarrel.ViewModels.SubPages.UserSettings +namespace Quarrel.ViewModels.SubPages.Settings { /// - /// An interface for items in the user settings navigation menu. + /// An interface for items in a settings navigation menu. /// - public interface IUserSettingsMenuItem + public interface ISettingsMenuItem { /// /// Gets the title of the menu item. diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs new file mode 100644 index 000000000..b54945da1 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs @@ -0,0 +1,20 @@ +// Quarrel © 2022 + +using Quarrel.Services.Localization; + +namespace Quarrel.ViewModels.SubPages.Settings +{ + /// + /// A header for a category of settings menu items. + /// + public class SettingsCategoryHeader : ISettingsMenuItem + { + internal SettingsCategoryHeader(ILocalizationService localizationService, string resource) + { + Title = localizationService[resource]; + } + + /// + public string Title { get; } + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/BehaviorPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs similarity index 77% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/BehaviorPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs index 4d0977367..ed77c1e49 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/BehaviorPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs @@ -2,14 +2,14 @@ using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the behaviors page in settings. /// - public class BehaviorPageViewModel : UserSettingsSubPageViewModel + public class BehaviorPageViewModel : SettingsSubPageViewModel { private const string BehaviorResource = "UserSettings/Behavior"; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/ConnectionsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs similarity index 77% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/ConnectionsPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs index fabd5ed22..e8ab4e6b1 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/ConnectionsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs @@ -2,14 +2,14 @@ using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the connections page in settings. /// - public class ConnectionsPageViewModel : UserSettingsSubPageViewModel + public class ConnectionsPageViewModel : SettingsSubPageViewModel { private const string ConnectionsResource = "UserSettings/Connections"; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/DisplayPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs similarity index 86% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/DisplayPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs index 49b6f2df8..55a120769 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/DisplayPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs @@ -2,15 +2,15 @@ using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; using System.Collections.Generic; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the display page in settings. /// - public class DisplayPageViewModel : UserSettingsSubPageViewModel + public class DisplayPageViewModel : SettingsSubPageViewModel { private const string ConnectionsResource = "UserSettings/Display"; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/MyAccountPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs similarity index 93% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/MyAccountPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs index 3d2ef524c..4cd2e5736 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/MyAccountPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs @@ -4,14 +4,14 @@ using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the account page in settings. /// - public class MyAccountPageViewModel : UserSettingsSubPageViewModel + public class MyAccountPageViewModel : SettingsSubPageViewModel { private const string MyAccountResource = "UserSettings/MyAccount"; private readonly IDiscordService _discordService; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/NotificationsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs similarity index 77% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/NotificationsPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs index 0425289a7..cf01e9763 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/NotificationsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs @@ -2,14 +2,14 @@ using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the notifications page in settings. /// - public class NotificationsPageViewModel : UserSettingsSubPageViewModel + public class NotificationsPageViewModel : SettingsSubPageViewModel { private const string NotificationsResource = "UserSettings/Notifications"; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/PrivacyPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs similarity index 94% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/PrivacyPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs index 772581363..86d1187cb 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/PrivacyPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs @@ -4,14 +4,14 @@ using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the privacy page in settings. /// - public class PrivacyPageViewModel : UserSettingsSubPageViewModel + public class PrivacyPageViewModel : SettingsSubPageViewModel { private const string PrivacyResource = "UserSettings/Privacy"; private readonly IDiscordService _discordService; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/VoicePageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs similarity index 77% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/VoicePageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs index 2f0ae4abf..ea1030c1d 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/Pages/VoicePageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs @@ -2,14 +2,14 @@ using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; -namespace Quarrel.ViewModels.SubPages.UserSettings.Pages +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// /// A view model for the voice page in settings. /// - public class VoicePageViewModel : UserSettingsSubPageViewModel + public class VoicePageViewModel : SettingsSubPageViewModel { private const string VoiceResource = "UserSettings/Voice"; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs similarity index 73% rename from src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsPageViewModel.cs rename to src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs index 4e1534c35..5d284992d 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs @@ -4,12 +4,11 @@ using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.UserSettings; -using Quarrel.ViewModels.SubPages.UserSettings.Pages; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages; using System.Collections.ObjectModel; -namespace Quarrel.ViewModels.SubPages.Settings +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings { /// /// A view model for the user settings page. @@ -19,23 +18,23 @@ public class UserSettingsPageViewModel : ObservableObject private const string AccountSettingsResource = "UserSettings/AccountSettings"; private const string AppSettingsResource = "UserSettings/AppSettings"; - private UserSettingsSubPageViewModel? _selectedSubPage; + private SettingsSubPageViewModel? _selectedSubPage; /// /// Initializes a new instance of the . /// public UserSettingsPageViewModel(ILocalizationService localizationService, IStorageService storageService, IDiscordService discordService) { - Pages = new ObservableCollection(); + Pages = new ObservableCollection(); // Account settings - Pages.Add(new UserSettingsHeader(localizationService, AccountSettingsResource)); + Pages.Add(new SettingsCategoryHeader(localizationService, AccountSettingsResource)); Pages.Add(new MyAccountPageViewModel(localizationService, storageService, discordService)); Pages.Add(new PrivacyPageViewModel(localizationService, storageService, discordService)); Pages.Add(new ConnectionsPageViewModel(localizationService, storageService)); // App Settings - Pages.Add(new UserSettingsHeader(localizationService, AppSettingsResource)); + Pages.Add(new SettingsCategoryHeader(localizationService, AppSettingsResource)); Pages.Add(new DisplayPageViewModel(localizationService, storageService)); Pages.Add(new BehaviorPageViewModel(localizationService, storageService)); Pages.Add(new NotificationsPageViewModel(localizationService, storageService)); @@ -45,7 +44,7 @@ public UserSettingsPageViewModel(ILocalizationService localizationService, IStor /// /// Gets the view model of the selected sub page. /// - public UserSettingsSubPageViewModel? SelectedSubPage + public SettingsSubPageViewModel? SelectedSubPage { get => _selectedSubPage; set => SetProperty(ref _selectedSubPage, value); @@ -54,6 +53,6 @@ public UserSettingsSubPageViewModel? SelectedSubPage /// /// Gets the view models of all subpage options. /// - public ObservableCollection Pages { get; } + public ObservableCollection Pages { get; } } } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsHeader.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsHeader.cs deleted file mode 100644 index c6e9ec2f3..000000000 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/UserSettings/UserSettingsHeader.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Quarrel © 2022 - -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Quarrel.Services.Localization; - -namespace Quarrel.ViewModels.SubPages.UserSettings -{ - /// - /// A header for a category of user settings menu items. - /// - public class UserSettingsHeader : ObservableObject, IUserSettingsMenuItem - { - internal UserSettingsHeader(ILocalizationService localizationService, string resource) - { - Title = localizationService[resource]; - } - - /// - public string Title { get; } - } -} diff --git a/src/Quarrel/App.Services.cs b/src/Quarrel/App.Services.cs index 5797b6a3f..d148502f2 100644 --- a/src/Quarrel/App.Services.cs +++ b/src/Quarrel/App.Services.cs @@ -18,10 +18,10 @@ using Quarrel.ViewModels.Panels; using Quarrel.ViewModels.SubPages; using Quarrel.ViewModels.SubPages.DiscordStatus; -using Quarrel.ViewModels.SubPages.GuildSettings; using Quarrel.ViewModels.SubPages.Host; using Quarrel.ViewModels.SubPages.Meta; -using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings; +using Quarrel.ViewModels.SubPages.Settings.UserSettings; using System; using Windows.Storage; diff --git a/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml.cs b/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml.cs index 739a9a083..d3513f99e 100644 --- a/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml.cs +++ b/src/Quarrel/Controls/Shell/QuarrelCommandBar.xaml.cs @@ -9,7 +9,7 @@ using Quarrel.ViewModels.Panels; using Quarrel.ViewModels.SubPages.DiscordStatus; using Quarrel.ViewModels.SubPages.Meta; -using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.UserSettings; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/src/Quarrel/Quarrel.csproj b/src/Quarrel/Quarrel.csproj index 922c083e2..9a67f8735 100644 --- a/src/Quarrel/Quarrel.csproj +++ b/src/Quarrel/Quarrel.csproj @@ -184,11 +184,9 @@ - - - - + + @@ -211,7 +209,7 @@ DiscordStatusPage.xaml - + GuildSettingsPage.xaml @@ -227,16 +225,16 @@ CreditPage.xaml - + DisplayPage.xaml - + MyAccountPage.xaml - + PrivacyPage.xaml - + UserSettingsPage.xaml @@ -595,7 +593,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -615,19 +613,19 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs b/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs deleted file mode 100644 index 61a196dfd..000000000 --- a/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Quarrel © 2022 - -using Quarrel.ViewModels.SubPages.GuildSettings; -using Quarrel.ViewModels.SubPages.GuildSettings.Pages.Abstract; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Quarrel.Selectors.SubPages.GuildSettings -{ - public class GuildSettingsMenuItemSelector : DataTemplateSelector - { - public DataTemplate? HeaderItem { get; set; } - - public DataTemplate? MenuItem { get; set; } - - protected override DataTemplate SelectTemplateCore(object item) - { - return item switch - { - GuildSettingsHeader => HeaderItem, - GuildSettingsSubPageViewModel or _ => MenuItem, - }; - } - } -} diff --git a/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs b/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs deleted file mode 100644 index 9e40caf5a..000000000 --- a/src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Quarrel © 2022 - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace Quarrel.Selectors.SubPages.UserSettings -{ - public class GuildSettingsPageSelector : DataTemplateSelector - { - protected override DataTemplate? SelectTemplateCore(object item, DependencyObject container) - { - return item switch - { - _ => null, - }; - } - } -} diff --git a/src/Quarrel/Selectors/SubPages/UserSettings/UserSettingsMenuItemSelector.cs b/src/Quarrel/Selectors/SubPages/Settings/SettingsMenuItemSelector.cs similarity index 50% rename from src/Quarrel/Selectors/SubPages/UserSettings/UserSettingsMenuItemSelector.cs rename to src/Quarrel/Selectors/SubPages/Settings/SettingsMenuItemSelector.cs index dedabb4a7..7e356a40b 100644 --- a/src/Quarrel/Selectors/SubPages/UserSettings/UserSettingsMenuItemSelector.cs +++ b/src/Quarrel/Selectors/SubPages/Settings/SettingsMenuItemSelector.cs @@ -1,13 +1,13 @@ // Quarrel © 2022 -using Quarrel.ViewModels.SubPages.UserSettings; -using Quarrel.ViewModels.SubPages.UserSettings.Pages.Abstract; +using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.Abstract; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -namespace Quarrel.Selectors.SubPages.UserSettings +namespace Quarrel.Selectors.SubPages.Settings { - public class UserSettingsMenuItemSelector : DataTemplateSelector + public class SettingsMenuItemSelector : DataTemplateSelector { public DataTemplate? HeaderItem { get; set; } @@ -17,8 +17,8 @@ protected override DataTemplate SelectTemplateCore(object item) { return item switch { - UserSettingsHeader => HeaderItem, - UserSettingsSubPageViewModel or _ => MenuItem, + SettingsCategoryHeader => HeaderItem, + SettingsSubPageViewModel or _ => MenuItem, }; } } diff --git a/src/Quarrel/Selectors/SubPages/UserSettings/UserSettingsPageSelector.cs b/src/Quarrel/Selectors/SubPages/Settings/SettingsPageSelector.cs similarity index 87% rename from src/Quarrel/Selectors/SubPages/UserSettings/UserSettingsPageSelector.cs rename to src/Quarrel/Selectors/SubPages/Settings/SettingsPageSelector.cs index fe7e85259..070d1c086 100644 --- a/src/Quarrel/Selectors/SubPages/UserSettings/UserSettingsPageSelector.cs +++ b/src/Quarrel/Selectors/SubPages/Settings/SettingsPageSelector.cs @@ -1,12 +1,12 @@ // Quarrel © 2022 -using Quarrel.ViewModels.SubPages.UserSettings.Pages; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -namespace Quarrel.Selectors.SubPages.UserSettings +namespace Quarrel.Selectors.SubPages.Settings { - public class UserSettingsPageSelector : DataTemplateSelector + public class SettingsPageSelector : DataTemplateSelector { public DataTemplate? BehaviorsTemplate { get; set; } diff --git a/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs b/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs index 2bf110ee4..78d5ad31a 100644 --- a/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs +++ b/src/Quarrel/Selectors/SubPages/SubPageTemplateSelector.cs @@ -1,9 +1,9 @@ // Quarrel © 2022 using Quarrel.ViewModels.SubPages.DiscordStatus; -using Quarrel.ViewModels.SubPages.GuildSettings; using Quarrel.ViewModels.SubPages.Meta; -using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings; +using Quarrel.ViewModels.SubPages.Settings.UserSettings; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; diff --git a/src/Quarrel/SubPages/Host/SubPageHost.xaml b/src/Quarrel/SubPages/Host/SubPageHost.xaml index 59ddd8afb..b307b9070 100644 --- a/src/Quarrel/SubPages/Host/SubPageHost.xaml +++ b/src/Quarrel/SubPages/Host/SubPageHost.xaml @@ -9,8 +9,8 @@ xmlns:sselectors="using:Quarrel.Selectors.SubPages" xmlns:statuspage="using:Quarrel.SubPages.DiscordStatus" xmlns:metapages="using:Quarrel.SubPages.Meta" - xmlns:guildsettings="using:Quarrel.SubPages.GuildSettings" - xmlns:usersettings="using:Quarrel.SubPages.UserSettings" + xmlns:guildsettings="using:Quarrel.SubPages.Settings.GuildSettings" + xmlns:usersettings="using:Quarrel.SubPages.Settings.UserSettings" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" diff --git a/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml similarity index 65% rename from src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml rename to src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml index bbde3c233..47697de04 100644 --- a/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml +++ b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml @@ -1,21 +1,18 @@  - + @@ -23,13 +20,13 @@ - + - + diff --git a/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml.cs b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml.cs similarity index 75% rename from src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml.cs rename to src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml.cs index ec2f11b14..63f3724c6 100644 --- a/src/Quarrel/SubPages/GuildSettings/GuildSettingsPage.xaml.cs +++ b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml.cs @@ -1,9 +1,9 @@ // Quarrel © 2022 -using Quarrel.ViewModels.SubPages.GuildSettings; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings; using Windows.UI.Xaml.Controls; -namespace Quarrel.SubPages.GuildSettings +namespace Quarrel.SubPages.Settings.GuildSettings { public sealed partial class GuildSettingsPage : UserControl { diff --git a/src/Quarrel/SubPages/UserSettings/Pages/DisplayPage.xaml b/src/Quarrel/SubPages/Settings/UserSettings/Pages/DisplayPage.xaml similarity index 90% rename from src/Quarrel/SubPages/UserSettings/Pages/DisplayPage.xaml rename to src/Quarrel/SubPages/Settings/UserSettings/Pages/DisplayPage.xaml index 5cb07d36a..58ef17eb0 100644 --- a/src/Quarrel/SubPages/UserSettings/Pages/DisplayPage.xaml +++ b/src/Quarrel/SubPages/Settings/UserSettings/Pages/DisplayPage.xaml @@ -1,5 +1,5 @@  - + - + - + - + - + @@ -40,13 +39,13 @@ - + - + diff --git a/src/Quarrel/SubPages/UserSettings/UserSettingsPage.xaml.cs b/src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml.cs similarity index 75% rename from src/Quarrel/SubPages/UserSettings/UserSettingsPage.xaml.cs rename to src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml.cs index c98092dc7..98bc199fe 100644 --- a/src/Quarrel/SubPages/UserSettings/UserSettingsPage.xaml.cs +++ b/src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml.cs @@ -1,9 +1,9 @@ // Quarrel © 2022 -using Quarrel.ViewModels.SubPages.Settings; +using Quarrel.ViewModels.SubPages.Settings.UserSettings; using Windows.UI.Xaml.Controls; -namespace Quarrel.SubPages.UserSettings +namespace Quarrel.SubPages.Settings.UserSettings { public sealed partial class UserSettingsPage : UserControl { From d690d754eb92c403bac932b02e5a99c7ae93f444 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 14:30:30 -0400 Subject: [PATCH 09/24] Added guild as context to guild settings sub page --- .../SubPage/NavigateToSubPageMessage.cs | 16 ++++++++++++++-- .../ViewModels/Panels/GuildsViewModel.cs | 13 +++++++++++-- .../SubPages/Host/SubPageHostViewModel.cs | 12 ++++-------- .../GuildSettings/GuildSettingsPageViewModel.cs | 4 ++-- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/Quarrel.ViewModels/Messages/Navigation/SubPage/NavigateToSubPageMessage.cs b/src/Quarrel.ViewModels/Messages/Navigation/SubPage/NavigateToSubPageMessage.cs index 839d4ed4a..5a926feb5 100644 --- a/src/Quarrel.ViewModels/Messages/Navigation/SubPage/NavigateToSubPageMessage.cs +++ b/src/Quarrel.ViewModels/Messages/Navigation/SubPage/NavigateToSubPageMessage.cs @@ -1,5 +1,8 @@ // Quarrel © 2022 +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.DependencyInjection; using System; namespace Quarrel.Messages.Navigation.SubPages @@ -14,12 +17,21 @@ public class NavigateToSubPageMessage /// public NavigateToSubPageMessage(Type targetViewModelType) { - TargetViewModelType = targetViewModelType; + // TODO: Investigate alternative to using Ioc + ViewModel = (ObservableObject)Ioc.Default.GetRequiredService(targetViewModelType); + } + + /// + /// Initializes a new instance of the class. + /// + public NavigateToSubPageMessage(ObservableObject viewModel) + { + ViewModel = viewModel; } /// /// Gets the type of ViewModel for the target SubPage. /// - public Type TargetViewModelType { get; } + public ObservableObject ViewModel { get; } } } diff --git a/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs b/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs index a5f57733c..96a16ec0e 100644 --- a/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs @@ -36,7 +36,12 @@ public partial class GuildsViewModel : ObservableRecipient /// /// Initializes a new instance of the class. /// - public GuildsViewModel(IAnalyticsService analyticsService, IMessenger messenger, ILocalizationService localizationService, IDiscordService discordService, IDispatcherService dispatcherService) + public GuildsViewModel( + IAnalyticsService analyticsService, + IMessenger messenger, + ILocalizationService localizationService, + IDiscordService discordService, + IDispatcherService dispatcherService) { _analyticsService = analyticsService; _messenger = messenger; @@ -114,7 +119,11 @@ public void LoadGuilds() private void OpenGuildSettings() { - _messenger.Send(new NavigateToSubPageMessage(typeof(GuildSettingsPageViewModel))); + if (SelectedGuild is BindableGuild guild) + { + var viewModel = new GuildSettingsPageViewModel(_localizationService, guild); + _messenger.Send(new NavigateToSubPageMessage(viewModel)); + } } private void ForwardNavigate(ulong guildId) diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Host/SubPageHostViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Host/SubPageHostViewModel.cs index 983208281..c0a75831e 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Host/SubPageHostViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Host/SubPageHostViewModel.cs @@ -1,8 +1,6 @@ // Quarrel © 2022 -using Microsoft.Extensions.DependencyInjection; using Microsoft.Toolkit.Mvvm.ComponentModel; -using Microsoft.Toolkit.Mvvm.DependencyInjection; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Messaging; using Quarrel.Messages.Navigation.SubPages; @@ -33,7 +31,7 @@ public SubPageHostViewModel(IAnalyticsService analyticsService, IMessenger messe _messenger = messenger; _navStack = new Stack(); - _messenger.Register(this, (s, e) => NavigateToSubPage(e.TargetViewModelType)); + _messenger.Register(this, (s, e) => NavigateToSubPage(e.ViewModel)); _messenger.Register(this, (s, e) => HandleGoBackSubPage()); } @@ -43,7 +41,7 @@ public SubPageHostViewModel(IAnalyticsService analyticsService, IMessenger messe public object? ContentViewModel { get => _contentViewModel; - set + private set { if (SetProperty(ref _contentViewModel, value)) { @@ -64,17 +62,15 @@ public object? ContentViewModel public bool IsStacked => _navStack.Count > 0; [ICommand] - private void NavigateToSubPage(Type viewModelType) + private void NavigateToSubPage(object viewModel) { - // TODO: Investigate alternative to using Ioc - object viewModel = Ioc.Default.GetRequiredService(viewModelType); if (ContentViewModel is not null) { _navStack.Push(ContentViewModel); } _analyticsService.Log(LoggedEvent.SubPageOpened, - ("Type", viewModelType.Name)); + ("Type", viewModel.GetType().Name)); ContentViewModel = viewModel; } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs index 41ce0d118..997a8d943 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs @@ -1,8 +1,8 @@ // Quarrel © 2022 using Microsoft.Toolkit.Mvvm.ComponentModel; +using Quarrel.Bindables.Guilds; using Quarrel.Services.Localization; -using Quarrel.ViewModels.SubPages.Settings; using Quarrel.ViewModels.SubPages.Settings.Abstract; using System.Collections.ObjectModel; @@ -22,7 +22,7 @@ public class GuildSettingsPageViewModel : ObservableObject /// /// Initializes a new instance of the . /// - public GuildSettingsPageViewModel(ILocalizationService localizationService) + public GuildSettingsPageViewModel(ILocalizationService localizationService, BindableGuild guild) { Pages = new ObservableCollection(); From 30dd72ae0068f6816e94081449a48eeb00fab751 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 15:34:10 -0400 Subject: [PATCH 10/24] Further refactored settings view models --- .../ViewModels/Panels/GuildsViewModel.cs | 2 +- .../Abstract/SettingSubPageViewModel.cs | 9 +----- .../GuildSettingsPageViewModel.cs | 31 +++++++++++++----- .../Abstract/GuildSettingsSubPageViewModel.cs | 32 +++++++++++++++++++ .../Pages/AuditLogPageViewModel.cs | 28 ++++++++++++++++ .../GuildSettings/Pages/BansPageViewModel.cs | 28 ++++++++++++++++ .../Pages/EmojisPageViewModel.cs | 28 ++++++++++++++++ .../Pages/InvitesPageViewModel.cs | 28 ++++++++++++++++ .../Pages/MembersPageViewModel.cs | 28 ++++++++++++++++ .../Pages/ModerationPageViewModel.cs | 28 ++++++++++++++++ .../Pages/NotificationsPageViewModel.cs | 28 ++++++++++++++++ .../Pages/OverviewPageViewModel.cs | 28 ++++++++++++++++ .../Pages/PrivacyPageViewModel.cs | 28 ++++++++++++++++ .../GuildSettings/Pages/RolesPageViewModel.cs | 28 ++++++++++++++++ .../Settings/SettingsCategoryHeader.cs | 9 ++++-- .../Abstract/UserSettingsSubPageViewModel.cs | 32 +++++++++++++++++++ .../Pages/BehaviorPageViewModel.cs | 11 ++++--- .../Pages/ConnectionsPageViewModel.cs | 11 ++++--- .../Pages/DisplayPageViewModel.cs | 11 ++++--- .../Pages/MyAccountPageViewModel.cs | 12 +++---- .../Pages/NotificationsPageViewModel.cs | 11 ++++--- .../Pages/PrivacyPageViewModel.cs | 14 ++++---- .../UserSettings/Pages/VoicePageViewModel.cs | 11 ++++--- .../UserSettings/UserSettingsPageViewModel.cs | 29 +++++++++-------- 24 files changed, 432 insertions(+), 73 deletions(-) create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/AuditLogPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/EmojisPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/InvitesPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/MembersPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/NotificationsPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/RolesPageViewModel.cs create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs diff --git a/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs b/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs index 96a16ec0e..df2e21732 100644 --- a/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/Panels/GuildsViewModel.cs @@ -121,7 +121,7 @@ private void OpenGuildSettings() { if (SelectedGuild is BindableGuild guild) { - var viewModel = new GuildSettingsPageViewModel(_localizationService, guild); + var viewModel = new GuildSettingsPageViewModel(_localizationService, _discordService, guild); _messenger.Send(new NavigateToSubPageMessage(viewModel)); } } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs index 39e5d75f1..e6e38f033 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/SettingSubPageViewModel.cs @@ -2,7 +2,6 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Quarrel.Services.Localization; -using Quarrel.Services.Storage; namespace Quarrel.ViewModels.SubPages.Settings.Abstract { @@ -16,15 +15,9 @@ public abstract class SettingsSubPageViewModel : ObservableObject, ISettingsMenu /// protected readonly ILocalizationService _localizationService; - /// - /// The storage service. - /// - protected readonly IStorageService _storageService; - - internal SettingsSubPageViewModel(ILocalizationService localizationService, IStorageService storageService) + internal SettingsSubPageViewModel(ILocalizationService localizationService) { _localizationService = localizationService; - _storageService = storageService; } /// diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs index 997a8d943..65ef0ac3b 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs @@ -2,8 +2,11 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; using Quarrel.Services.Localization; +using Quarrel.Services.Storage; using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages; using System.Collections.ObjectModel; namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings @@ -22,18 +25,30 @@ public class GuildSettingsPageViewModel : ObservableObject /// /// Initializes a new instance of the . /// - public GuildSettingsPageViewModel(ILocalizationService localizationService, BindableGuild guild) + public GuildSettingsPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) { - Pages = new ObservableCollection(); + Pages = new ObservableCollection + { + new OverviewPageViewModel(localizationService, discordService, guild), - // Personal Settings - Pages.Add(new SettingsCategoryHeader(localizationService, PersonalSettingsResource)); + // Personal Settings + new SettingsCategoryHeader(localizationService[PersonalSettingsResource]), + new PrivacyPageViewModel(localizationService, discordService, guild), + new NotificationsPageViewModel(localizationService, discordService, guild), - // Server Settings - Pages.Add(new SettingsCategoryHeader(localizationService, ServerSettingsResource)); + // Server Settings + new SettingsCategoryHeader(localizationService[ServerSettingsResource]), + new RolesPageViewModel(localizationService, discordService, guild), + new EmojisPageViewModel(localizationService, discordService, guild), + new ModerationPageViewModel(localizationService, discordService, guild), + new AuditLogPageViewModel(localizationService, discordService, guild), - // User management - Pages.Add(new SettingsCategoryHeader(localizationService, UserManagementResource)); + // User management + new SettingsCategoryHeader(localizationService[UserManagementResource]), + new MembersPageViewModel(localizationService, discordService, guild), + new InvitesPageViewModel(localizationService, discordService, guild), + new BansPageViewModel(localizationService, discordService, guild) + }; } /// diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs new file mode 100644 index 000000000..58a8196de --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs @@ -0,0 +1,32 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract +{ + /// + /// A base class for guild settings sub-page view models. + /// + public abstract class GuildSettingsSubPageViewModel : SettingsSubPageViewModel + { + /// + /// The discord service. + /// + protected readonly IDiscordService _discordService; + + /// + /// The guild being modified or viewed. + /// + protected readonly BindableGuild _guild; + + internal GuildSettingsSubPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService) + { + _discordService = discordService; + _guild = guild; + } + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/AuditLogPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/AuditLogPageViewModel.cs new file mode 100644 index 000000000..3b1571080 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/AuditLogPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the audit log page in guild settings. + /// + public class AuditLogPageViewModel : GuildSettingsSubPageViewModel + { + private const string AuditLogResource = "GuildSettings/AuditLog"; + + internal AuditLogPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[AuditLogResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs new file mode 100644 index 000000000..44d8af1fe --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the bans page in guild settings. + /// + internal class BansPageViewModel : GuildSettingsSubPageViewModel + { + private const string BansResource = "GuildSettings/Bans"; + + internal BansPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[BansResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/EmojisPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/EmojisPageViewModel.cs new file mode 100644 index 000000000..caa81869d --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/EmojisPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the emojis page in guild settings. + /// + public class EmojisPageViewModel : GuildSettingsSubPageViewModel + { + private const string EmojisResource = "GuildSettings/Emojis"; + + internal EmojisPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[EmojisResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/InvitesPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/InvitesPageViewModel.cs new file mode 100644 index 000000000..cff2f6ab5 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/InvitesPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the invites page in guild settings. + /// + public class InvitesPageViewModel : GuildSettingsSubPageViewModel + { + private const string InvitesResource = "GuildSettings/Invites"; + + internal InvitesPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[InvitesResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/MembersPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/MembersPageViewModel.cs new file mode 100644 index 000000000..6e5e1a8e5 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/MembersPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the members page in guild settings. + /// + public class MembersPageViewModel : GuildSettingsSubPageViewModel + { + private const string MembersResource = "GuildSettings/Members"; + + internal MembersPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[MembersResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs new file mode 100644 index 000000000..ff9502516 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the moderation page in guild settings. + /// + public class ModerationPageViewModel : GuildSettingsSubPageViewModel + { + private const string ModerationResource = "GuildSettings/Moderation"; + + internal ModerationPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[ModerationResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/NotificationsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/NotificationsPageViewModel.cs new file mode 100644 index 000000000..aebd71392 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/NotificationsPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the notifications page in guild settings. + /// + public class NotificationsPageViewModel : GuildSettingsSubPageViewModel + { + private const string NotificationsResource = "GuildSettings/Notifications"; + + internal NotificationsPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[NotificationsResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs new file mode 100644 index 000000000..9d7ffe554 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the overview page in guild settings. + /// + public class OverviewPageViewModel : GuildSettingsSubPageViewModel + { + private const string OverviewResource = "GuildSettings/Overview"; + + internal OverviewPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[OverviewResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs new file mode 100644 index 000000000..19fd7ea56 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the privacy page in guild settings. + /// + public class PrivacyPageViewModel : GuildSettingsSubPageViewModel + { + private const string PrivacyResource = "GuildSettingsSubPageViewModel/Privacy"; + + internal PrivacyPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[PrivacyResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/RolesPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/RolesPageViewModel.cs new file mode 100644 index 000000000..9de43a9eb --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/RolesPageViewModel.cs @@ -0,0 +1,28 @@ +// Quarrel © 2022 + +using Quarrel.Bindables.Guilds; +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages +{ + /// + /// A view model for the roles page in guild settings. + /// + public class RolesPageViewModel : GuildSettingsSubPageViewModel + { + private const string RolesResource = "GuildSettings/Roles"; + + internal RolesPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : + base(localizationService, discordService, guild) + { + } + + /// + public override string Glyph => ""; + + /// + public override string Title => _localizationService[RolesResource]; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs index b54945da1..4857bb2f4 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/SettingsCategoryHeader.cs @@ -9,9 +9,14 @@ namespace Quarrel.ViewModels.SubPages.Settings /// public class SettingsCategoryHeader : ISettingsMenuItem { - internal SettingsCategoryHeader(ILocalizationService localizationService, string resource) + internal SettingsCategoryHeader(string title) + { + Title = title; + } + + internal SettingsCategoryHeader(string resource, ILocalizationService localizationService) : + this(localizationService[resource]) { - Title = localizationService[resource]; } /// diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs new file mode 100644 index 000000000..ec2a14fe4 --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/Abstract/UserSettingsSubPageViewModel.cs @@ -0,0 +1,32 @@ +// Quarrel © 2022 + +using Quarrel.Services.Discord; +using Quarrel.Services.Localization; +using Quarrel.Services.Storage; +using Quarrel.ViewModels.SubPages.Settings.Abstract; + +namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract +{ + /// + /// A base class for user settings sub-page view models. + /// + public abstract class UserSettingsSubPageViewModel : SettingsSubPageViewModel + { + /// + /// The discord service. + /// + protected readonly IDiscordService _discordService; + + /// + /// The storage service. + /// + protected readonly IStorageService _storageService; + + internal UserSettingsSubPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService) + { + _discordService = discordService; + _storageService = storageService; + } + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs index ed77c1e49..a9687dab6 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/BehaviorPageViewModel.cs @@ -1,20 +1,21 @@ // Quarrel © 2022 +using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the behaviors page in settings. + /// A view model for the behaviors page in user settings. /// - public class BehaviorPageViewModel : SettingsSubPageViewModel + public class BehaviorPageViewModel : UserSettingsSubPageViewModel { private const string BehaviorResource = "UserSettings/Behavior"; - internal BehaviorPageViewModel(ILocalizationService localizationService, IStorageService storageService) : - base(localizationService, storageService) + internal BehaviorPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs index e8ab4e6b1..3cd1b4737 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/ConnectionsPageViewModel.cs @@ -1,20 +1,21 @@ // Quarrel © 2022 +using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the connections page in settings. + /// A view model for the connections page in user settings. /// - public class ConnectionsPageViewModel : SettingsSubPageViewModel + public class ConnectionsPageViewModel : UserSettingsSubPageViewModel { private const string ConnectionsResource = "UserSettings/Connections"; - internal ConnectionsPageViewModel(ILocalizationService localizationService, IStorageService storageService) : - base(localizationService, storageService) + internal ConnectionsPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs index 55a120769..d221125b8 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/DisplayPageViewModel.cs @@ -1,21 +1,22 @@ // Quarrel © 2022 +using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; using System.Collections.Generic; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the display page in settings. + /// A view model for the display page in user settings. /// - public class DisplayPageViewModel : SettingsSubPageViewModel + public class DisplayPageViewModel : UserSettingsSubPageViewModel { private const string ConnectionsResource = "UserSettings/Display"; - internal DisplayPageViewModel(ILocalizationService localizationService, IStorageService storageService) : - base(localizationService, storageService) + internal DisplayPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs index 4cd2e5736..43ea943bc 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs @@ -4,17 +4,16 @@ using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the account page in settings. + /// A view model for the account page in user settings. /// - public class MyAccountPageViewModel : SettingsSubPageViewModel + public class MyAccountPageViewModel : UserSettingsSubPageViewModel { private const string MyAccountResource = "UserSettings/MyAccount"; - private readonly IDiscordService _discordService; private bool _isLoggedIn; private string? _email; @@ -22,11 +21,10 @@ public class MyAccountPageViewModel : SettingsSubPageViewModel private int _discriminator; private string? _aboutMe; - internal MyAccountPageViewModel(ILocalizationService localizationService, IStorageService storageService, IDiscordService discordService) : - base(localizationService, storageService) + internal MyAccountPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { _isLoggedIn = false; - _discordService = discordService; var user = _discordService.GetMe(); diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs index cf01e9763..37e4d21e1 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/NotificationsPageViewModel.cs @@ -1,20 +1,21 @@ // Quarrel © 2022 +using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the notifications page in settings. + /// A view model for the notifications page in user settings. /// - public class NotificationsPageViewModel : SettingsSubPageViewModel + public class NotificationsPageViewModel : UserSettingsSubPageViewModel { private const string NotificationsResource = "UserSettings/Notifications"; - internal NotificationsPageViewModel(ILocalizationService localizationService, IStorageService storageService) : - base(localizationService, storageService) + internal NotificationsPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs index 86d1187cb..f50da97ce 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/PrivacyPageViewModel.cs @@ -4,25 +4,23 @@ using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the privacy page in settings. + /// A view model for the privacy page in user settings. /// - public class PrivacyPageViewModel : SettingsSubPageViewModel + public class PrivacyPageViewModel : UserSettingsSubPageViewModel { private const string PrivacyResource = "UserSettings/Privacy"; - private readonly IDiscordService _discordService; private ExplicitContentFilterLevel _contentFilterLevel; - internal PrivacyPageViewModel(ILocalizationService localizationService, IStorageService storageService, IDiscordService discordService) : - base(localizationService, storageService) + internal PrivacyPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { - _discordService = discordService; } - + /// public override string Glyph => ""; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs index ea1030c1d..28db06a73 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/VoicePageViewModel.cs @@ -1,20 +1,21 @@ // Quarrel © 2022 +using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; -using Quarrel.ViewModels.SubPages.Settings.Abstract; +using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages { /// - /// A view model for the voice page in settings. + /// A view model for the voice page in user settings. /// - public class VoicePageViewModel : SettingsSubPageViewModel + public class VoicePageViewModel : UserSettingsSubPageViewModel { private const string VoiceResource = "UserSettings/Voice"; - internal VoicePageViewModel(ILocalizationService localizationService, IStorageService storageService) : - base(localizationService, storageService) + internal VoicePageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : + base(localizationService, discordService, storageService) { } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs index 5d284992d..1f30300e5 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs @@ -25,20 +25,21 @@ public class UserSettingsPageViewModel : ObservableObject /// public UserSettingsPageViewModel(ILocalizationService localizationService, IStorageService storageService, IDiscordService discordService) { - Pages = new ObservableCollection(); - - // Account settings - Pages.Add(new SettingsCategoryHeader(localizationService, AccountSettingsResource)); - Pages.Add(new MyAccountPageViewModel(localizationService, storageService, discordService)); - Pages.Add(new PrivacyPageViewModel(localizationService, storageService, discordService)); - Pages.Add(new ConnectionsPageViewModel(localizationService, storageService)); - - // App Settings - Pages.Add(new SettingsCategoryHeader(localizationService, AppSettingsResource)); - Pages.Add(new DisplayPageViewModel(localizationService, storageService)); - Pages.Add(new BehaviorPageViewModel(localizationService, storageService)); - Pages.Add(new NotificationsPageViewModel(localizationService, storageService)); - Pages.Add(new VoicePageViewModel(localizationService, storageService)); + Pages = new ObservableCollection + { + // Account settings + new SettingsCategoryHeader(localizationService[AccountSettingsResource]), + new MyAccountPageViewModel(localizationService, discordService, storageService), + new PrivacyPageViewModel(localizationService, discordService, storageService), + new ConnectionsPageViewModel(localizationService, discordService, storageService), + + // App Settings + new SettingsCategoryHeader(localizationService[AppSettingsResource]), + new DisplayPageViewModel(localizationService, discordService, storageService), + new BehaviorPageViewModel(localizationService, discordService, storageService), + new NotificationsPageViewModel(localizationService, discordService, storageService), + new VoicePageViewModel(localizationService, discordService, storageService) + }; } /// From 8cf162d2dbc1b482fa5302cb9a18ecc807ff25d3 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 15:44:37 -0400 Subject: [PATCH 11/24] Added DiscordOrange color and brush --- src/Quarrel/Resources/Brushes.xaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Quarrel/Resources/Brushes.xaml b/src/Quarrel/Resources/Brushes.xaml index 1165b1fcd..2d1743ef3 100644 --- a/src/Quarrel/Resources/Brushes.xaml +++ b/src/Quarrel/Resources/Brushes.xaml @@ -92,7 +92,6 @@ #FF000000 - #fff04747 #7289DA @@ -103,19 +102,21 @@ #FAA61A + #F57731 + #FA4747 - #ff43b581 + #43B581 - #fffaa61a + #FAA61A - #fff04747 + #FA4747 - #747f8d + #747F8D - #747f8d + #747F8D From f40825ddce2bdf9e38cd11016340dece11cdab17 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 15:44:51 -0400 Subject: [PATCH 12/24] Added resources for guild settings pages --- .../Pages/PrivacyPageViewModel.cs | 2 +- .../MultilingualResources/Quarrel.he-IL.xlf | 40 +++++++++++++++++++ src/Quarrel/Strings/en-US/Resources.resw | 30 ++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs index 19fd7ea56..627a3d7dd 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/PrivacyPageViewModel.cs @@ -12,7 +12,7 @@ namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages /// public class PrivacyPageViewModel : GuildSettingsSubPageViewModel { - private const string PrivacyResource = "GuildSettingsSubPageViewModel/Privacy"; + private const string PrivacyResource = "GuildSettings/Privacy"; internal PrivacyPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : base(localizationService, discordService, guild) diff --git a/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf b/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf index f76fd5834..edf1b6352 100644 --- a/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf +++ b/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf @@ -411,6 +411,46 @@ User Management User Management + + Audit Log + Audit Log + + + Bans + Bans + + + Emojis + Emojis + + + Invites + Invites + + + Members + Members + + + Moderation + Moderation + + + Notifications + Notifications + + + Overview + Overview + + + Privacy + Privacy + + + Roles + Roles + diff --git a/src/Quarrel/Strings/en-US/Resources.resw b/src/Quarrel/Strings/en-US/Resources.resw index b4a81eb5f..d8218a2c0 100644 --- a/src/Quarrel/Strings/en-US/Resources.resw +++ b/src/Quarrel/Strings/en-US/Resources.resw @@ -264,9 +264,39 @@ Home + + Audit Log + + + Bans + + + Emojis + + + Invites + + + Members + + + Moderation + + + Notifications + + + Overview + Personal Settings + + Privacy + + + Roles + Server Settings From 373043d455e5625daf87758ae8a9ee18f1844c80 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 15:51:59 -0400 Subject: [PATCH 13/24] Added default item selection to settings pages --- .../Settings/GuildSettings/GuildSettingsPageViewModel.cs | 3 +++ .../Settings/UserSettings/UserSettingsPageViewModel.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs index 65ef0ac3b..1774a7e47 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs @@ -8,6 +8,7 @@ using Quarrel.ViewModels.SubPages.Settings.Abstract; using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages; using System.Collections.ObjectModel; +using System.Linq; namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings { @@ -49,6 +50,8 @@ public GuildSettingsPageViewModel(ILocalizationService localizationService, IDis new InvitesPageViewModel(localizationService, discordService, guild), new BansPageViewModel(localizationService, discordService, guild) }; + + SelectedSubPage = (SettingsSubPageViewModel)Pages.FirstOrDefault(x => x is SettingsSubPageViewModel { IsActive: true }); } /// diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs index 1f30300e5..75a181ce1 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/UserSettingsPageViewModel.cs @@ -7,6 +7,7 @@ using Quarrel.ViewModels.SubPages.Settings.Abstract; using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages; using System.Collections.ObjectModel; +using System.Linq; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings { @@ -40,6 +41,8 @@ public UserSettingsPageViewModel(ILocalizationService localizationService, IStor new NotificationsPageViewModel(localizationService, discordService, storageService), new VoicePageViewModel(localizationService, discordService, storageService) }; + + SelectedSubPage = (SettingsSubPageViewModel)Pages.FirstOrDefault(x => x is SettingsSubPageViewModel { IsActive: true }); } /// From cf18b702449f3db42e462bf324a0400e4aea2d92 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 16:22:20 -0400 Subject: [PATCH 14/24] Improved hebrew localization --- .../MultilingualResources/Quarrel.he-IL.xlf | 28 ++++++------- src/Quarrel/Strings/he-IL/Resources.resw | 41 ++++++++++++++++++- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf b/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf index edf1b6352..2b90d7bff 100644 --- a/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf +++ b/src/Quarrel/MultilingualResources/Quarrel.he-IL.xlf @@ -305,7 +305,7 @@ Analyze all DMs - לנתח את כל ההודעות הישירות + נתח את כל ההודעות הישירות Protect me @@ -401,55 +401,55 @@ Personal Settings - Personal Settings + הגדרות אישיות Server Settings - Server Settings + הגדרות שרת User Management - User Management + ניהול משתמשים Audit Log - Audit Log + יומן ביקורת Bans - Bans + איסורים Emojis - Emojis + Emojis Invites - Invites + מזמין Members - Members + חברים Moderation - Moderation + מתינות Notifications - Notifications + הודעות Overview - Overview + סקירה כללית Privacy - Privacy + פרטיות Roles - Roles + תפקידים diff --git a/src/Quarrel/Strings/he-IL/Resources.resw b/src/Quarrel/Strings/he-IL/Resources.resw index 54b955b65..b6e8f79b4 100644 --- a/src/Quarrel/Strings/he-IL/Resources.resw +++ b/src/Quarrel/Strings/he-IL/Resources.resw @@ -237,7 +237,7 @@ החברים שלי נחמדים - לנתח את כל ההודעות הישירות + נתח את כל ההודעות הישירות הגן עליי @@ -284,4 +284,43 @@ גרסת: {0}.{1}.{2} + + הגדרות אישיות + + + הגדרות שרת + + + ניהול משתמשים + + + יומן ביקורת + + + איסורים + + + Emojis + + + מזמין + + + חברים + + + מתינות + + + הודעות + + + סקירה כללית + + + פרטיות + + + תפקידים + \ No newline at end of file From e1d3eb2fbc6517f9cae8d374b9fa75b0392d0b2b Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 17:08:41 -0400 Subject: [PATCH 15/24] Guild moderation page layout --- .../GuildSettingsPageViewModel.cs | 1 - .../GuildSettings/Pages/BansPageViewModel.cs | 2 +- .../Pages/ModerationPageViewModel.cs | 3 + src/Quarrel/Quarrel.csproj | 10 +- .../GuildSettingsPageSelector.cs | 49 ++++++++ .../UserSettingsPageSelector.cs} | 4 +- .../GuildSettings/GuildSettingsPage.xaml | 16 ++- .../GuildSettings/Pages/ModerationPage.xaml | 109 ++++++++++++++++++ .../Pages/ModerationPage.xaml.cs | 29 +++++ .../UserSettings/UserSettingsPage.xaml | 9 +- 10 files changed, 220 insertions(+), 12 deletions(-) create mode 100644 src/Quarrel/Selectors/SubPages/Settings/GuildSettings/GuildSettingsPageSelector.cs rename src/Quarrel/Selectors/SubPages/Settings/{SettingsPageSelector.cs => UserSettings/UserSettingsPageSelector.cs} (90%) create mode 100644 src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml create mode 100644 src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml.cs diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs index 1774a7e47..3d61bdb8f 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/GuildSettingsPageViewModel.cs @@ -4,7 +4,6 @@ using Quarrel.Bindables.Guilds; using Quarrel.Services.Discord; using Quarrel.Services.Localization; -using Quarrel.Services.Storage; using Quarrel.ViewModels.SubPages.Settings.Abstract; using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages; using System.Collections.ObjectModel; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs index 44d8af1fe..8c3a25145 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/BansPageViewModel.cs @@ -10,7 +10,7 @@ namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages /// /// A view model for the bans page in guild settings. /// - internal class BansPageViewModel : GuildSettingsSubPageViewModel + public class BansPageViewModel : GuildSettingsSubPageViewModel { private const string BansResource = "GuildSettings/Bans"; diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs index ff9502516..3e8740c61 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs @@ -24,5 +24,8 @@ internal ModerationPageViewModel(ILocalizationService localizationService, IDisc /// public override string Title => _localizationService[ModerationResource]; + + /// + public override bool IsActive => true; } } diff --git a/src/Quarrel/Quarrel.csproj b/src/Quarrel/Quarrel.csproj index 9a67f8735..e6ef2a079 100644 --- a/src/Quarrel/Quarrel.csproj +++ b/src/Quarrel/Quarrel.csproj @@ -184,9 +184,10 @@ + - + @@ -225,6 +226,9 @@ CreditPage.xaml + + ModerationPage.xaml + DisplayPage.xaml @@ -613,6 +617,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Quarrel/Selectors/SubPages/Settings/GuildSettings/GuildSettingsPageSelector.cs b/src/Quarrel/Selectors/SubPages/Settings/GuildSettings/GuildSettingsPageSelector.cs new file mode 100644 index 000000000..5d6afd189 --- /dev/null +++ b/src/Quarrel/Selectors/SubPages/Settings/GuildSettings/GuildSettingsPageSelector.cs @@ -0,0 +1,49 @@ +// Quarrel © 2022 + +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Quarrel.Selectors.SubPages.Settings.GuildSettings +{ + public class GuildSettingsPageSelector : DataTemplateSelector + { + public DataTemplate? OverviewTemplate { get; set; } + + public DataTemplate? PrivacyTemplate { get; set; } + + public DataTemplate? NotificationsTemplate { get; set; } + + public DataTemplate? RoleTemplate { get; set; } + + public DataTemplate? EmojisTemplate { get; set; } + + public DataTemplate? ModerationTemplate { get; set; } + + public DataTemplate? AuditLogTemplate { get; set; } + + public DataTemplate? MembersTemplate { get; set; } + + public DataTemplate? InvitesTemplate { get; set; } + + public DataTemplate? BansTemplate { get; set; } + + protected override DataTemplate? SelectTemplateCore(object item, DependencyObject container) + { + return item switch + { + OverviewPageViewModel => OverviewTemplate, + PrivacyPageViewModel => PrivacyTemplate, + NotificationsPageViewModel => NotificationsTemplate, + RolesPageViewModel => RoleTemplate, + EmojisPageViewModel => EmojisTemplate, + ModerationPageViewModel => ModerationTemplate, + AuditLogPageViewModel => AuditLogTemplate, + MembersPageViewModel => MembersTemplate, + InvitesPageViewModel => InvitesTemplate, + BansPageViewModel => BansTemplate, + _ => null, + }; + } + } +} diff --git a/src/Quarrel/Selectors/SubPages/Settings/SettingsPageSelector.cs b/src/Quarrel/Selectors/SubPages/Settings/UserSettings/UserSettingsPageSelector.cs similarity index 90% rename from src/Quarrel/Selectors/SubPages/Settings/SettingsPageSelector.cs rename to src/Quarrel/Selectors/SubPages/Settings/UserSettings/UserSettingsPageSelector.cs index 070d1c086..8d8ebc009 100644 --- a/src/Quarrel/Selectors/SubPages/Settings/SettingsPageSelector.cs +++ b/src/Quarrel/Selectors/SubPages/Settings/UserSettings/UserSettingsPageSelector.cs @@ -4,9 +4,9 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -namespace Quarrel.Selectors.SubPages.Settings +namespace Quarrel.Selectors.SubPages.Settings.UserSettings { - public class SettingsPageSelector : DataTemplateSelector + public class UserSettingsPageSelector : DataTemplateSelector { public DataTemplate? BehaviorsTemplate { get; set; } diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml index 47697de04..ba341bdd5 100644 --- a/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml +++ b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml @@ -4,7 +4,9 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:pages="using:Quarrel.SubPages.Settings.GuildSettings.Pages" xmlns:sselector="using:Quarrel.Selectors.SubPages.Settings" + xmlns:gsselector="using:Quarrel.Selectors.SubPages.Settings.GuildSettings" xmlns:settings="using:Quarrel.ViewModels.SubPages.Settings" xmlns:asettings="using:Quarrel.ViewModels.SubPages.Settings.Abstract" mc:Ignorable="d" @@ -12,6 +14,14 @@ d:DesignWidth="1008"> + + + + + + + @@ -39,10 +49,10 @@ MenuItemsSource="{x:Bind ViewModel.Pages, Mode=OneWay}" MenuItemTemplateSelector="{StaticResource MenuItemSelector}"> - + VerticalContentAlignment="Stretch"/> diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml new file mode 100644 index 000000000..bbb701cca --- /dev/null +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml.cs b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml.cs new file mode 100644 index 000000000..193bba770 --- /dev/null +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml.cs @@ -0,0 +1,29 @@ +// Quarrel © 2022 + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 + +namespace Quarrel.SubPages.Settings.GuildSettings.Pages +{ + public sealed partial class ModerationPage : UserControl + { + public ModerationPage() + { + this.InitializeComponent(); + } + } +} diff --git a/src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml b/src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml index 50b19c12d..e828d0618 100644 --- a/src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml +++ b/src/Quarrel/SubPages/Settings/UserSettings/UserSettingsPage.xaml @@ -5,6 +5,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sselector="using:Quarrel.Selectors.SubPages.Settings" + xmlns:usselector="using:Quarrel.Selectors.SubPages.Settings.UserSettings" xmlns:pages="using:Quarrel.SubPages.Settings.UserSettings.Pages" xmlns:settings="using:Quarrel.ViewModels.SubPages.Settings" xmlns:asettings="using:Quarrel.ViewModels.SubPages.Settings.Abstract" @@ -26,10 +27,10 @@ - + From b2554067268e9b329cb7059c810865c8722cf4c5 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 19:54:07 -0400 Subject: [PATCH 16/24] WIP Moderation page binding --- .../Models/Enums/Guilds/VerificationLevel.cs | 2 +- .../Pages/ModerationPageViewModel.cs | 50 +++++++++++++++++++ .../Pages/MyAccountPageViewModel.cs | 4 +- .../GuildSettings/Pages/ModerationPage.xaml | 43 ++++++++++------ .../Pages/ModerationPage.xaml.cs | 18 ++----- 5 files changed, 83 insertions(+), 34 deletions(-) diff --git a/src/API/Discord.API/Models/Enums/Guilds/VerificationLevel.cs b/src/API/Discord.API/Models/Enums/Guilds/VerificationLevel.cs index fa073ee9c..fec7a64b6 100644 --- a/src/API/Discord.API/Models/Enums/Guilds/VerificationLevel.cs +++ b/src/API/Discord.API/Models/Enums/Guilds/VerificationLevel.cs @@ -30,6 +30,6 @@ public enum VerificationLevel /// /// Members must have a verified phone number for their Discord account. /// - Extreme = 4 + Highest = 4 } } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs index 3e8740c61..a64d9cba8 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs @@ -1,5 +1,8 @@ // Quarrel © 2022 +using Discord.API.Models.Enums.Guilds; +using Discord.API.Models.Enums.Settings; +using Microsoft.Toolkit.Mvvm.Input; using Quarrel.Bindables.Guilds; using Quarrel.Services.Discord; using Quarrel.Services.Localization; @@ -14,9 +17,16 @@ public class ModerationPageViewModel : GuildSettingsSubPageViewModel { private const string ModerationResource = "GuildSettings/Moderation"; + private ExplicitContentFilterLevel _explicitContentFilterLevel; + private VerificationLevel _verificationLevel; + internal ModerationPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : base(localizationService, discordService, guild) { + SetVerificationLevelCommand = new RelayCommand(SetVerificationLevel); + SetExplicitContentFilterLevelCommand = new RelayCommand(SetExplicitContentFilterLevel); + + ResetValues(guild); } /// @@ -27,5 +37,45 @@ internal ModerationPageViewModel(ILocalizationService localizationService, IDisc /// public override bool IsActive => true; + + /// + /// Gets or sets the verification level. + /// + public VerificationLevel VerificationLevel + { + get => _verificationLevel; + set => SetProperty(ref _verificationLevel, value); + } + + /// + /// Gets or sets the explicit content filter level. + /// + public ExplicitContentFilterLevel ExplicitContentFilterLevel + { + get => _explicitContentFilterLevel; + set => SetProperty(ref _explicitContentFilterLevel, value); + } + + /// + /// Gets a command that sets the verification level. + /// + public RelayCommand SetVerificationLevelCommand { get; } + + /// + /// Gets a command that sets the verification level. + /// + public RelayCommand SetExplicitContentFilterLevelCommand { get; } + + private void ResetValues(BindableGuild guild) + { + VerificationLevel = guild.Guild.VerificationLevel; + ExplicitContentFilterLevel = guild.Guild.ExplicitContentFilter; + } + + private void SetVerificationLevel(VerificationLevel verificationLevel) + => VerificationLevel = verificationLevel; + + private void SetExplicitContentFilterLevel(ExplicitContentFilterLevel explicitContentFilterLevel) + => ExplicitContentFilterLevel = explicitContentFilterLevel; } } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs index 43ea943bc..ae93a8fc6 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs @@ -31,7 +31,7 @@ internal MyAccountPageViewModel(ILocalizationService localizationService, IDisco if (user is not null) { _isLoggedIn = true; - SetBaseValues(user); + ResetValues(user); } } @@ -80,7 +80,7 @@ public string? AboutMe set => SetProperty(ref _aboutMe, value); } - private void SetBaseValues(BindableSelfUser user) + private void ResetValues(BindableSelfUser user) { Email = user.SelfUser.Email; Username = user.SelfUser.Username; diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml index bbb701cca..d1fbcb02b 100644 --- a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml @@ -5,6 +5,9 @@ xmlns:local="using:Quarrel.SubPages.Settings.GuildSettings.Pages" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:bconvert="using:Quarrel.Converters.Common.Boolean" + xmlns:genum="using:Discord.API.Models.Enums.Guilds" + xmlns:senum="using:Discord.API.Models.Enums.Settings" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="400"> @@ -24,8 +27,9 @@ - @@ -33,8 +37,9 @@ Text="Unrestricted"/> - @@ -42,8 +47,9 @@ Text="Must have a verified email attached to their account."/> - @@ -51,8 +57,9 @@ Text="Must also be registered on Discord for longer than 5 minutes."/> - @@ -60,8 +67,9 @@ Text="Must also be a member of this server longer than 10 minutes."/> - @@ -74,8 +82,9 @@ - - - (ModerationPageViewModel)DataContext; } } From 6e959161e2cf8fcb5d845588d39b10c5f5840c02 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Thu, 19 May 2022 20:15:04 -0400 Subject: [PATCH 17/24] WIP Overview page --- .../Pages/OverviewPageViewModel.cs | 20 +++++++++++++++++++ src/Quarrel/Quarrel.csproj | 7 +++++++ .../GuildSettings/GuildSettingsPage.xaml | 7 ++++++- .../GuildSettings/Pages/OverviewPage.xaml | 17 ++++++++++++++++ .../GuildSettings/Pages/OverviewPage.xaml.cs | 17 ++++++++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml create mode 100644 src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml.cs diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs index 9d7ffe554..ce3132d90 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/OverviewPageViewModel.cs @@ -14,9 +14,12 @@ public class OverviewPageViewModel : GuildSettingsSubPageViewModel { private const string OverviewResource = "GuildSettings/Overview"; + private string _name; + internal OverviewPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : base(localizationService, discordService, guild) { + ResetValues(guild); } /// @@ -24,5 +27,22 @@ internal OverviewPageViewModel(ILocalizationService localizationService, IDiscor /// public override string Title => _localizationService[OverviewResource]; + + /// + public override bool IsActive => true; + + /// + /// Gets or sets the guild's name. + /// + public string Name + { + get => _name; + set => SetProperty(ref _name, value); + } + + private void ResetValues(BindableGuild guild) + { + Name = guild.Guild.Name; + } } } diff --git a/src/Quarrel/Quarrel.csproj b/src/Quarrel/Quarrel.csproj index e6ef2a079..be6124340 100644 --- a/src/Quarrel/Quarrel.csproj +++ b/src/Quarrel/Quarrel.csproj @@ -229,6 +229,9 @@ ModerationPage.xaml + + OverviewPage.xaml + DisplayPage.xaml @@ -621,6 +624,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml index ba341bdd5..5e73ab481 100644 --- a/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml +++ b/src/Quarrel/SubPages/Settings/GuildSettings/GuildSettingsPage.xaml @@ -15,12 +15,17 @@ + + + + + OverviewTemplate="{StaticResource OverviewPageTemplate}" + ModerationTemplate="{StaticResource ModerationPageTemplate}"/> diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml new file mode 100644 index 000000000..018c8163d --- /dev/null +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml.cs b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml.cs new file mode 100644 index 000000000..b08ed1c3a --- /dev/null +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/OverviewPage.xaml.cs @@ -0,0 +1,17 @@ +// Quarrel © 2022 + +using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages; +using Windows.UI.Xaml.Controls; + +namespace Quarrel.SubPages.Settings.GuildSettings.Pages +{ + public sealed partial class OverviewPage : UserControl + { + public OverviewPage() + { + this.InitializeComponent(); + } + + public OverviewPageViewModel ViewModel => (OverviewPageViewModel)DataContext; + } +} From f9b24bd44c130701cdb86b085e8b6a103effb226 Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Fri, 20 May 2022 03:57:42 -0400 Subject: [PATCH 18/24] Added draft values and implemented for Moderation page --- .../SubPages/Settings/Abstract/DraftValue.cs | 49 +++++ .../Pages/ModerationPageViewModel.cs | 18 +- .../Pages/MyAccountPageViewModel.cs | 25 +-- .../GuildSettings/Pages/ModerationPage.xaml | 186 ++++++++++-------- .../UserSettings/Pages/MyAccountPage.xaml | 8 +- 5 files changed, 175 insertions(+), 111 deletions(-) create mode 100644 src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/DraftValue.cs diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/DraftValue.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/DraftValue.cs new file mode 100644 index 000000000..752b2847c --- /dev/null +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/Abstract/DraftValue.cs @@ -0,0 +1,49 @@ +// Quarrel © 2022 + +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace Quarrel.ViewModels.SubPages.Settings.Abstract +{ + /// + /// A value that can have an updated draft. + /// + /// The type of value being drafted + public class DraftValue : ObservableObject + { + private T _value; + + /// + /// Initializes a new instance of the class. + /// + public DraftValue(T value) + { + _value = value; + CanonValue = value; + } + + /// + /// The drafted value. + /// + public T Value + { + get => _value; + set + { + if (SetProperty(ref _value, value)) + { + OnPropertyChanged(nameof(Drafted)); + } + } + } + + /// + /// The original value. + /// + public T CanonValue { get; } + + /// + /// Gets whether or not the value drafted. + /// + public bool Drafted => !CanonValue?.Equals(Value) ?? false; + } +} diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs index a64d9cba8..24fa3d17c 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/GuildSettings/Pages/ModerationPageViewModel.cs @@ -6,7 +6,9 @@ using Quarrel.Bindables.Guilds; using Quarrel.Services.Discord; using Quarrel.Services.Localization; +using Quarrel.ViewModels.SubPages.Settings.Abstract; using Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages.Abstract; +using System.Diagnostics.CodeAnalysis; namespace Quarrel.ViewModels.SubPages.Settings.GuildSettings.Pages { @@ -17,8 +19,8 @@ public class ModerationPageViewModel : GuildSettingsSubPageViewModel { private const string ModerationResource = "GuildSettings/Moderation"; - private ExplicitContentFilterLevel _explicitContentFilterLevel; - private VerificationLevel _verificationLevel; + private DraftValue _explicitContentFilterLevel; + private DraftValue _verificationLevel; internal ModerationPageViewModel(ILocalizationService localizationService, IDiscordService discordService, BindableGuild guild) : base(localizationService, discordService, guild) @@ -41,7 +43,7 @@ internal ModerationPageViewModel(ILocalizationService localizationService, IDisc /// /// Gets or sets the verification level. /// - public VerificationLevel VerificationLevel + public DraftValue VerificationLevel { get => _verificationLevel; set => SetProperty(ref _verificationLevel, value); @@ -50,7 +52,7 @@ public VerificationLevel VerificationLevel /// /// Gets or sets the explicit content filter level. /// - public ExplicitContentFilterLevel ExplicitContentFilterLevel + public DraftValue ExplicitContentFilterLevel { get => _explicitContentFilterLevel; set => SetProperty(ref _explicitContentFilterLevel, value); @@ -68,14 +70,14 @@ public ExplicitContentFilterLevel ExplicitContentFilterLevel private void ResetValues(BindableGuild guild) { - VerificationLevel = guild.Guild.VerificationLevel; - ExplicitContentFilterLevel = guild.Guild.ExplicitContentFilter; + VerificationLevel = new(guild.Guild.VerificationLevel); + ExplicitContentFilterLevel = new(guild.Guild.ExplicitContentFilter); } private void SetVerificationLevel(VerificationLevel verificationLevel) - => VerificationLevel = verificationLevel; + => VerificationLevel.Value = verificationLevel; private void SetExplicitContentFilterLevel(ExplicitContentFilterLevel explicitContentFilterLevel) - => ExplicitContentFilterLevel = explicitContentFilterLevel; + => ExplicitContentFilterLevel.Value = explicitContentFilterLevel; } } diff --git a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs index ae93a8fc6..4c41e3acb 100644 --- a/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/SubPages/Settings/UserSettings/Pages/MyAccountPageViewModel.cs @@ -4,6 +4,7 @@ using Quarrel.Services.Discord; using Quarrel.Services.Localization; using Quarrel.Services.Storage; +using Quarrel.ViewModels.SubPages.Settings.Abstract; using Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages.Abstract; namespace Quarrel.ViewModels.SubPages.Settings.UserSettings.Pages @@ -16,10 +17,10 @@ public class MyAccountPageViewModel : UserSettingsSubPageViewModel private const string MyAccountResource = "UserSettings/MyAccount"; private bool _isLoggedIn; - private string? _email; - private string? _username; - private int _discriminator; - private string? _aboutMe; + private DraftValue _email; + private DraftValue _username; + private DraftValue _discriminator; + private DraftValue _aboutMe; internal MyAccountPageViewModel(ILocalizationService localizationService, IDiscordService discordService, IStorageService storageService) : base(localizationService, discordService, storageService) @@ -47,7 +48,7 @@ internal MyAccountPageViewModel(ILocalizationService localizationService, IDisco /// /// Gets or sets the current user's email. /// - public string? Email + public DraftValue Email { get => _email; set => SetProperty(ref _email, value); @@ -56,7 +57,7 @@ public string? Email /// /// Gets or sets the current user's username. /// - public string? Username + public DraftValue Username { get => _username; set => SetProperty(ref _username, value); @@ -65,7 +66,7 @@ public string? Username /// /// Gets or sets the current user's discriminator. /// - public int Discriminator + public DraftValue Discriminator { get => _discriminator; set => SetProperty(ref _discriminator, value); @@ -74,7 +75,7 @@ public int Discriminator /// /// Gets or sets the current user's about me description. /// - public string? AboutMe + public DraftValue AboutMe { get => _aboutMe; set => SetProperty(ref _aboutMe, value); @@ -82,10 +83,10 @@ public string? AboutMe private void ResetValues(BindableSelfUser user) { - Email = user.SelfUser.Email; - Username = user.SelfUser.Username; - Discriminator = user.SelfUser.Discriminator; - AboutMe = user.SelfUser.Bio; + Email = new(user.SelfUser.Email); + Username = new(user.SelfUser.Username); + Discriminator = new(user.SelfUser.Discriminator); + AboutMe = new(user.SelfUser.Bio); } } } diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml index d1fbcb02b..bb8dd3142 100644 --- a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml @@ -20,101 +20,113 @@ - + - - - - - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + - - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + - + diff --git a/src/Quarrel/SubPages/Settings/UserSettings/Pages/MyAccountPage.xaml b/src/Quarrel/SubPages/Settings/UserSettings/Pages/MyAccountPage.xaml index 42ba68afe..599a153d7 100644 --- a/src/Quarrel/SubPages/Settings/UserSettings/Pages/MyAccountPage.xaml +++ b/src/Quarrel/SubPages/Settings/UserSettings/Pages/MyAccountPage.xaml @@ -20,7 +20,7 @@ @@ -30,13 +30,13 @@ @@ -44,7 +44,7 @@ Date: Fri, 20 May 2022 07:11:55 -0400 Subject: [PATCH 19/24] Added DraftBlock control --- src/Quarrel/Controls/DraftBlock.cs | 37 +++++++++++++++++ src/Quarrel/Quarrel.csproj | 5 +++ .../GuildSettings/Pages/ModerationPage.xaml | 17 ++++---- src/Quarrel/Themes/Generic.xaml | 41 +++++++++++++++++++ 4 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 src/Quarrel/Controls/DraftBlock.cs create mode 100644 src/Quarrel/Themes/Generic.xaml diff --git a/src/Quarrel/Controls/DraftBlock.cs b/src/Quarrel/Controls/DraftBlock.cs new file mode 100644 index 000000000..5d9ac2133 --- /dev/null +++ b/src/Quarrel/Controls/DraftBlock.cs @@ -0,0 +1,37 @@ +// Quarrel © 2022 + +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace Quarrel.Controls +{ + public sealed class DraftBlock : ContentControl + { + public static readonly DependencyProperty IsDraftedProperty = DependencyProperty.Register( + nameof(IsDrafted), typeof(bool), typeof(DraftBlock), new PropertyMetadata(false, OnIsDraftedUpdated)); + + public DraftBlock() + { + this.DefaultStyleKey = typeof(DraftBlock); + } + + public bool IsDrafted + { + get => (bool)GetValue(IsDraftedProperty); + set => SetValue(IsDraftedProperty, value); + } + + private static void OnIsDraftedUpdated(DependencyObject sender, DependencyPropertyChangedEventArgs args) + { + DraftBlock draftBlock = sender as DraftBlock; + if ((bool)args.NewValue) + { + VisualStateManager.GoToState(draftBlock, "Drafted", true); + } + else + { + VisualStateManager.GoToState(draftBlock, "Normal", true); + } + } + } +} diff --git a/src/Quarrel/Quarrel.csproj b/src/Quarrel/Quarrel.csproj index be6124340..24780396e 100644 --- a/src/Quarrel/Quarrel.csproj +++ b/src/Quarrel/Quarrel.csproj @@ -90,6 +90,7 @@ + SecondaryWindowHost.xaml @@ -644,6 +645,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + diff --git a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml index bb8dd3142..c39f805da 100644 --- a/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml +++ b/src/Quarrel/SubPages/Settings/GuildSettings/Pages/ModerationPage.xaml @@ -5,6 +5,7 @@ xmlns:local="using:Quarrel.SubPages.Settings.GuildSettings.Pages" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:qc="using:Quarrel.Controls" xmlns:bconvert="using:Quarrel.Converters.Common.Boolean" xmlns:genum="using:Discord.API.Models.Enums.Guilds" xmlns:senum="using:Discord.API.Models.Enums.Settings" @@ -24,11 +25,9 @@ - - + - - + - - + - - + diff --git a/src/Quarrel/Themes/Generic.xaml b/src/Quarrel/Themes/Generic.xaml new file mode 100644 index 000000000..56e6ecbc5 --- /dev/null +++ b/src/Quarrel/Themes/Generic.xaml @@ -0,0 +1,41 @@ + + + + From 67eab9aceadecc63825065795c1323778c00833e Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Sat, 21 May 2022 07:05:03 -0400 Subject: [PATCH 20/24] Added Mark as Read endpoint and methods --- src/API/Discord.API/Rest/IChannelService.cs | 3 +++ src/Quarrel.Client/QuarrelClient.Methods.cs | 12 ++++++++++++ .../Services/Analytics/Enums/LoggedEvent.cs | 12 ++++++++++++ .../Services/Discord/DiscordService.Methods.cs | 9 ++++++++- .../Services/Discord/IDiscordService.cs | 7 +++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/API/Discord.API/Rest/IChannelService.cs b/src/API/Discord.API/Rest/IChannelService.cs index 54193e8d2..07ca4eb51 100644 --- a/src/API/Discord.API/Rest/IChannelService.cs +++ b/src/API/Discord.API/Rest/IChannelService.cs @@ -8,6 +8,9 @@ namespace Discord.API.Rest { internal interface IChannelService { + [Get("/v9/channels/{channelId}/messages/{messageId}/ack")] + Task MarkRead([AliasAs("channelId")] ulong channelId, [AliasAs("messageId")] ulong messageId); + [Get("/v9/channels/{channelId}/messages?limit={limit}")] Task GetChannelMessages([AliasAs("channelId")] ulong channelId, [AliasAs("limit")] int limit = 50); diff --git a/src/Quarrel.Client/QuarrelClient.Methods.cs b/src/Quarrel.Client/QuarrelClient.Methods.cs index fce54b977..3c3c37500 100644 --- a/src/Quarrel.Client/QuarrelClient.Methods.cs +++ b/src/Quarrel.Client/QuarrelClient.Methods.cs @@ -173,6 +173,18 @@ public IPrivateChannel[] GetPrivateChannels() return privateChannels; } + /// + /// Marks a message as the last read message in the channel. + /// + /// The id of the channel. + /// The id of the message. + /// + public async Task MarkRead(ulong channelId, ulong messageId) + { + Guard.IsNotNull(_channelService, nameof(_channelService)); + await MakeRefitRequest(() => _channelService.MarkRead(channelId, messageId)); + } + /// /// Sends a message. /// diff --git a/src/Quarrel.ViewModels/Services/Analytics/Enums/LoggedEvent.cs b/src/Quarrel.ViewModels/Services/Analytics/Enums/LoggedEvent.cs index 4ebbc6dc9..bccf1230f 100644 --- a/src/Quarrel.ViewModels/Services/Analytics/Enums/LoggedEvent.cs +++ b/src/Quarrel.ViewModels/Services/Analytics/Enums/LoggedEvent.cs @@ -16,12 +16,24 @@ public enum LoggedEvent [StringValue("SubPage Opened")] SubPageOpened, + /// + /// A message was marked read. + /// + [StringValue("Message Marked as Read")] + MarkRead, + /// /// A message was sent. /// [StringValue("Message Sent")] MessageSent, + /// + /// A message was deleted. + /// + [StringValue("Message Deleted")] + MessageDeleted, + /// /// The user's status was set. /// diff --git a/src/Quarrel.ViewModels/Services/Discord/DiscordService.Methods.cs b/src/Quarrel.ViewModels/Services/Discord/DiscordService.Methods.cs index bbdc65d22..ff4452985 100644 --- a/src/Quarrel.ViewModels/Services/Discord/DiscordService.Methods.cs +++ b/src/Quarrel.ViewModels/Services/Discord/DiscordService.Methods.cs @@ -178,17 +178,24 @@ public async Task GetChannelMessagesAsync(IBindableMessageChannel cha return null; } + /// + public async Task MarkRead(ulong channelId, ulong messageId) + { + _analyticsService.Log(LoggedEvent.MarkRead); + await _quarrelClient.MarkRead(channelId, messageId); + } + /// public async Task SendMessage(ulong channelId, string content) { _analyticsService.Log(LoggedEvent.MessageSent); - await _quarrelClient.SendMessage(channelId, content); } /// public async Task DeleteMessage(ulong channelId, ulong messageId) { + _analyticsService.Log(LoggedEvent.MessageDeleted); await _quarrelClient.DeleteMessage(channelId, messageId); } diff --git a/src/Quarrel.ViewModels/Services/Discord/IDiscordService.cs b/src/Quarrel.ViewModels/Services/Discord/IDiscordService.cs index 1b715eb05..d728f8863 100644 --- a/src/Quarrel.ViewModels/Services/Discord/IDiscordService.cs +++ b/src/Quarrel.ViewModels/Services/Discord/IDiscordService.cs @@ -78,6 +78,13 @@ public interface IDiscordService BindableGuildMember? GetGuildMember(ulong userId, ulong guildId); + /// + /// Marks a messages as the last read message in a channel. + /// + /// The id of the channel. + /// The id of the message. + Task MarkRead(ulong channelId, ulong messageId); + /// /// Sends a message. /// From 51adea19f46f4df3a52e665a609038b079f3986f Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Sat, 21 May 2022 07:44:29 -0400 Subject: [PATCH 21/24] Added mark as read commands to BindableMessage and IBindableMessageChannels --- .../Bindables/Channels/Abstract/BindablePrivateChannel.cs | 5 +++++ .../Bindables/Channels/BindableTextChannel.cs | 5 +++++ .../Channels/Interfaces/IBindableMessageChannel.cs | 6 ++++++ .../Bindables/Messages/BindableMessage.cs | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/src/Quarrel.ViewModels/Bindables/Channels/Abstract/BindablePrivateChannel.cs b/src/Quarrel.ViewModels/Bindables/Channels/Abstract/BindablePrivateChannel.cs index 00890bf0f..878ce4b1a 100644 --- a/src/Quarrel.ViewModels/Bindables/Channels/Abstract/BindablePrivateChannel.cs +++ b/src/Quarrel.ViewModels/Bindables/Channels/Abstract/BindablePrivateChannel.cs @@ -1,5 +1,6 @@ // Quarrel © 2022 +using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Messaging; using Quarrel.Bindables.Abstract; using Quarrel.Bindables.Channels.Interfaces; @@ -26,6 +27,7 @@ internal BindablePrivateChannel( PrivateChannel privateChannel) : base(messenger, discordService, dispatcherService, privateChannel) { + MarkAsReadCommand = new RelayCommand(() => _discordService.MarkRead(Id, MessageChannel.LastMessageId ?? 0)); } /// @@ -37,6 +39,9 @@ internal BindablePrivateChannel( /// public IMessageChannel MessageChannel => (IMessageChannel)Channel; + /// + public RelayCommand MarkAsReadCommand { get; } + /// /// Creates a new instance of a based on the type. /// diff --git a/src/Quarrel.ViewModels/Bindables/Channels/BindableTextChannel.cs b/src/Quarrel.ViewModels/Bindables/Channels/BindableTextChannel.cs index c7aa0d814..1cd811dc1 100644 --- a/src/Quarrel.ViewModels/Bindables/Channels/BindableTextChannel.cs +++ b/src/Quarrel.ViewModels/Bindables/Channels/BindableTextChannel.cs @@ -1,5 +1,6 @@ // Quarrel © 2022 +using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Messaging; using Quarrel.Bindables.Channels.Abstract; using Quarrel.Bindables.Channels.Interfaces; @@ -25,6 +26,7 @@ internal BindableTextChannel( BindableCategoryChannel? parent = null) : base(messenger, discordService, dispatcherService, channel, selfMember, parent) { + MarkAsReadCommand = new RelayCommand(() => _discordService.MarkRead(MessageChannel.Id, MessageChannel.LastMessageId ?? 0)); } /// @@ -39,6 +41,9 @@ internal BindableTextChannel( /// public GuildTextChannel TextChannel => (GuildTextChannel)Channel; + /// + public RelayCommand MarkAsReadCommand { get; } + /// protected override void AckUpdate() { diff --git a/src/Quarrel.ViewModels/Bindables/Channels/Interfaces/IBindableMessageChannel.cs b/src/Quarrel.ViewModels/Bindables/Channels/Interfaces/IBindableMessageChannel.cs index c37647bbc..c03fd5941 100644 --- a/src/Quarrel.ViewModels/Bindables/Channels/Interfaces/IBindableMessageChannel.cs +++ b/src/Quarrel.ViewModels/Bindables/Channels/Interfaces/IBindableMessageChannel.cs @@ -1,5 +1,6 @@ // Quarrel © 2022 +using Microsoft.Toolkit.Mvvm.Input; using Quarrel.Client.Models.Channels.Interfaces; namespace Quarrel.Bindables.Channels.Interfaces @@ -13,5 +14,10 @@ public interface IBindableMessageChannel : IBindableSelectableChannel /// Gets the wrapped . /// IMessageChannel MessageChannel { get; } + + /// + /// Gets a command that marks the channel as read. + /// + RelayCommand MarkAsReadCommand { get; } } } diff --git a/src/Quarrel.ViewModels/Bindables/Messages/BindableMessage.cs b/src/Quarrel.ViewModels/Bindables/Messages/BindableMessage.cs index db3a46ce0..05e0cbdae 100644 --- a/src/Quarrel.ViewModels/Bindables/Messages/BindableMessage.cs +++ b/src/Quarrel.ViewModels/Bindables/Messages/BindableMessage.cs @@ -72,6 +72,7 @@ internal BindableMessage( Attachments[i] = new BindableAttachment(messenger, discordService, dispatcherService, _message.Attachments[i]); } + MarkLastReadCommand = new RelayCommand(() => _discordService.MarkRead(ChannelId, Id)); CopyIdCommand = new RelayCommand(() => _clipboardService.Copy($"{Id}")); CopyLinkCommand = new RelayCommand(() => _clipboardService.Copy($"{message.MessageUri}")); DeleteCommand = new RelayCommand(() => _discordService.DeleteMessage(ChannelId, Id)); @@ -169,6 +170,11 @@ _message.Type is MessageType.ApplicationCommand or MessageType.ContextMenuComman // TODO: Properly handle deletable condition public bool CanDelete => Message.IsOwn; + /// + /// Gets a command that marks the message as the last read message in the channel. + /// + public RelayCommand MarkLastReadCommand { get; } + /// /// Gets a command that copies the message id to the clipboard. /// From 8ff6a050e738e102e123e07fdee82e5a8a5b8ffb Mon Sep 17 00:00:00 2001 From: Adam Dernis Date: Sun, 22 May 2022 08:06:07 -0400 Subject: [PATCH 22/24] WIP Added MarkAsRead MenuFlyoutItem --- src/API/Discord.API/Rest/IChannelService.cs | 3 ++- src/Quarrel/DataTemplates/ChannelTemplates.xaml | 8 ++++++++ src/Quarrel/DataTemplates/MessageTemplates.xaml | 6 +----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/API/Discord.API/Rest/IChannelService.cs b/src/API/Discord.API/Rest/IChannelService.cs index 07ca4eb51..aeb570f48 100644 --- a/src/API/Discord.API/Rest/IChannelService.cs +++ b/src/API/Discord.API/Rest/IChannelService.cs @@ -9,7 +9,8 @@ namespace Discord.API.Rest internal interface IChannelService { [Get("/v9/channels/{channelId}/messages/{messageId}/ack")] - Task MarkRead([AliasAs("channelId")] ulong channelId, [AliasAs("messageId")] ulong messageId); + [Headers("Content-Type: application/json;")] + Task MarkRead([AliasAs("channelId")] ulong channelId, [AliasAs("messageId")] ulong messageId, [Body] string body = "{token: null}"); [Get("/v9/channels/{channelId}/messages?limit={limit}")] Task GetChannelMessages([AliasAs("channelId")] ulong channelId, [AliasAs("limit")] int limit = 50); diff --git a/src/Quarrel/DataTemplates/ChannelTemplates.xaml b/src/Quarrel/DataTemplates/ChannelTemplates.xaml index 1491c0fac..2e52c66d9 100644 --- a/src/Quarrel/DataTemplates/ChannelTemplates.xaml +++ b/src/Quarrel/DataTemplates/ChannelTemplates.xaml @@ -11,6 +11,14 @@ + + + + + + + - - - - + Icon="Link" Command="{x:Bind CopyLinkCommand}"/> From 0d754a1b34e53d7c9df059329ae8c58d4138e478 Mon Sep 17 00:00:00 2001 From: Matthew <40522069+matthew4850@users.noreply.github.com> Date: Tue, 24 May 2022 01:26:18 +0100 Subject: [PATCH 23/24] Fix token. --- src/Quarrel/SubPages/LoginPage.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Quarrel/SubPages/LoginPage.xaml b/src/Quarrel/SubPages/LoginPage.xaml index e6ab4c3ea..c7c61f0e6 100644 --- a/src/Quarrel/SubPages/LoginPage.xaml +++ b/src/Quarrel/SubPages/LoginPage.xaml @@ -111,7 +111,7 @@ public event EventHandler? ChannelUpdated; + + /// + /// Invoked when a user logs out. + /// + public event Action? LoggedOut; + + /// + /// Invoked when the gateway reconnects. + /// + public event Action? Reconnecting; + + /// + /// Invoked when the gateway resumes. + /// + public event Action? Resuming; } } diff --git a/src/Quarrel.Client/QuarrelClient.cs b/src/Quarrel.Client/QuarrelClient.cs index 3fa190d19..44588c621 100644 --- a/src/Quarrel.Client/QuarrelClient.cs +++ b/src/Quarrel.Client/QuarrelClient.cs @@ -51,7 +51,9 @@ public async Task LoginAsync(string token) { _token = token; InitializeServices(token); - await SetupGatewayAsync(token); + if(_gateway == null) + await SetupGatewayAsync(); + await _gateway!.Connect(token); } private void InitializeServices(string token) @@ -65,12 +67,12 @@ private void InitializeServices(string token) _userService = restFactory.GetUserService(); } - private async Task SetupGatewayAsync(string token) + private async Task SetupGatewayAsync() { Guard.IsNotNull(_gatewayService, nameof(_gatewayService)); var gatewayConfig = await MakeRefitRequest(() => _gatewayService.GetGatewayConfig()); Guard.IsNotNull(gatewayConfig, nameof(_gatewayService)); - _gateway = new Gateway(gatewayConfig, token, + _gateway = new Gateway(gatewayConfig, unhandledMessageEncountered: (e) => GatewayExceptionHandled?.Invoke(this, e), unknownEventEncountered: e => UnknownGatewayEventEncountered?.Invoke(this, e), unknownOperationEncountered: e => UnknownGatewayOperationEncountered?.Invoke(this, e), @@ -86,7 +88,7 @@ private async Task SetupGatewayAsync(string token) resumed: e => { }, invalidSession: e => { }, - gatewayClosed: e => { }, + gatewayStateChanged: OnGatewayStateChanged, guildCreated: e => { }, guildUpdated: e => { }, @@ -127,7 +129,24 @@ private async Task SetupGatewayAsync(string token) voiceServerUpdated: e => { }, sessionReplaced: e => { }); - await _gateway.ConnectAsync(); + } + + private void OnGatewayStateChanged(GatewayStatus newState) + { + switch (newState) + { + case GatewayStatus.Resuming: + Resuming?.Invoke(); + break; + + case GatewayStatus.Reconnecting: + Resuming?.Invoke(); + break; + + case GatewayStatus.Disconnected: + LoggedOut?.Invoke(); + break; + } } } } diff --git a/src/Quarrel.ViewModels/Messages/UserLoggedOutMessage.cs b/src/Quarrel.ViewModels/Messages/UserLoggedOutMessage.cs new file mode 100644 index 000000000..9f05c379a --- /dev/null +++ b/src/Quarrel.ViewModels/Messages/UserLoggedOutMessage.cs @@ -0,0 +1,15 @@ +// Quarrel © 2022 + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Quarrel.Messages +{ + /// + /// A message sent when a user is disconnected. + /// + public class UserLoggedOutMessage + { + } +} diff --git a/src/Quarrel.ViewModels/Services/Discord/DiscordService.cs b/src/Quarrel.ViewModels/Services/Discord/DiscordService.cs index 7d42f91cd..f3394cec9 100644 --- a/src/Quarrel.ViewModels/Services/Discord/DiscordService.cs +++ b/src/Quarrel.ViewModels/Services/Discord/DiscordService.cs @@ -43,6 +43,9 @@ public DiscordService(IAnalyticsService analyticsService, ILocalizationService l private void RegisterEvents() { _quarrelClient.LoggedIn += OnLoggedIn; + _quarrelClient.LoggedOut += OnLoggedOut; + _quarrelClient.Reconnecting += OnReconnecting; + _quarrelClient.Resuming += OnResuming; _quarrelClient.HttpExceptionHandled += OnHttpExceptionHandled; _quarrelClient.GatewayExceptionHandled += OnGatewayExceptionHandled; @@ -92,6 +95,21 @@ private void OnLoggedIn(object sender, SelfUser e) _messenger.Send(new UserLoggedInMessage(info)); } + private void OnLoggedOut() + { + _messenger.Send(new UserLoggedOutMessage()); + } + + private void OnReconnecting() + { + _messenger.Send(new ConnectingMessage()); + } + + private void OnResuming() + { + _messenger.Send(new ConnectingMessage()); + } + private void OnHttpExceptionHandled(object sender, Exception e) => LogException(LoggedEvent.HttpExceptionHandled, e); diff --git a/src/Quarrel.ViewModels/Services/Storage/Accounts/AccountInfoStorage.cs b/src/Quarrel.ViewModels/Services/Storage/Accounts/AccountInfoStorage.cs index dd27c9a52..c1c9c06d2 100644 --- a/src/Quarrel.ViewModels/Services/Storage/Accounts/AccountInfoStorage.cs +++ b/src/Quarrel.ViewModels/Services/Storage/Accounts/AccountInfoStorage.cs @@ -29,7 +29,7 @@ public AccountInfoStorage(IVaultService vaultService, IFolderData folder, IAsync public AccountInfo? ActiveAccount { get => ActiveAccountId.HasValue ? GetPopulatedAccountInfo(ActiveAccountId.Value) : null; - set => ActiveAccountId = value is not null ? value.Id : null; + set => ActiveAccountId = value?.Id; } /// diff --git a/src/Quarrel.ViewModels/ViewModels/WindowViewModel.cs b/src/Quarrel.ViewModels/ViewModels/WindowViewModel.cs index 06143e6ec..70493a473 100644 --- a/src/Quarrel.ViewModels/ViewModels/WindowViewModel.cs +++ b/src/Quarrel.ViewModels/ViewModels/WindowViewModel.cs @@ -44,8 +44,10 @@ public WindowViewModel( _storageService = storageService; _dispatcherService = dispatcherService; - _messenger.Register(this, (_, _) => WindowState = WindowHostState.Connecting); + // TODO: Should connecting and reconnecting be handled separately? + _messenger.Register(this, (_, _) => OnConnecting()); _messenger.Register(this, (_, m) => OnLoggedIn(m.AccountInfo)); + _messenger.Register(this, (_, m) => OnLoggedOut()); InitializeLogin(); } @@ -96,5 +98,21 @@ private async void OnLoggedIn(AccountInfo info) WindowState = WindowHostState.LoggedIn; }); } + + private void OnLoggedOut() + { + _dispatcherService.RunOnUIThread(() => + { + WindowState = WindowHostState.LoggedOut; + }); + } + + private void OnConnecting() + { + _dispatcherService.RunOnUIThread(() => + { + WindowState = WindowHostState.Connecting; + }); + } } }