This repository was archived by the owner on Apr 30, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
312 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsHeader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Quarrel © 2022 | ||
|
||
using Microsoft.Toolkit.Mvvm.ComponentModel; | ||
using Quarrel.Services.Localization; | ||
|
||
namespace Quarrel.ViewModels.SubPages.GuildSettings | ||
{ | ||
/// <summary> | ||
/// A header for a category of guild settings menu items. | ||
/// </summary> | ||
public class GuildSettingsHeader : ObservableObject, IGuildSettingsMenuItem | ||
{ | ||
internal GuildSettingsHeader(ILocalizationService localizationService, string resource) | ||
{ | ||
Title = localizationService[resource]; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string Title { get; } | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/GuildSettingsPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Quarrel © 2022 | ||
|
||
using Microsoft.Toolkit.Mvvm.ComponentModel; | ||
using Quarrel.Services.Localization; | ||
using Quarrel.ViewModels.SubPages.GuildSettings.Pages.Abstract; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace Quarrel.ViewModels.SubPages.GuildSettings | ||
{ | ||
/// <summary> | ||
/// A view model for the guild settings page. | ||
/// </summary> | ||
public class GuildSettingsPageViewModel : ObservableObject | ||
{ | ||
private const string PersonalSettingsResource = "GuildSettings/PersonalSettings"; | ||
private const string ServerSettingsResource = "GuildSettings/ServerSettings"; | ||
private const string UserManagementResource = "GuildSettings/UserManagement"; | ||
|
||
private GuildSettingsSubPageViewModel? _selectedSubPage; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GuildSettingsPageViewModel"/>. | ||
/// </summary> | ||
public GuildSettingsPageViewModel(ILocalizationService localizationService) | ||
{ | ||
Pages = new ObservableCollection<IGuildSettingsMenuItem>(); | ||
|
||
// Personal Settings | ||
Pages.Add(new GuildSettingsHeader(localizationService, PersonalSettingsResource)); | ||
|
||
// Server Settings | ||
Pages.Add(new GuildSettingsHeader(localizationService, ServerSettingsResource)); | ||
|
||
// User management | ||
Pages.Add(new GuildSettingsHeader(localizationService, UserManagementResource)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the view model of the selected sub page. | ||
/// </summary> | ||
public GuildSettingsSubPageViewModel? SelectedSubPage | ||
{ | ||
get => _selectedSubPage; | ||
set => SetProperty(ref _selectedSubPage, value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the view models of all sub page options. | ||
/// </summary> | ||
public ObservableCollection<IGuildSettingsMenuItem> Pages { get; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Quarrel.ViewModels/ViewModels/SubPages/GuildSettings/IGuildSettingsMenuItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Quarrel © 2022 | ||
|
||
namespace Quarrel.ViewModels.SubPages.GuildSettings | ||
{ | ||
/// <summary> | ||
/// An interface for items in the guild settings navigation menu. | ||
/// </summary> | ||
public interface IGuildSettingsMenuItem | ||
{ | ||
/// <summary> | ||
/// Gets the title of the menu item. | ||
/// </summary> | ||
string Title { get; } | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...wModels/ViewModels/SubPages/GuildSettings/Pages/Abstract/GuildSettingsSubPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Quarrel © 2022 | ||
|
||
using Microsoft.Toolkit.Mvvm.ComponentModel; | ||
using Quarrel.Services.Localization; | ||
using Quarrel.Services.Storage; | ||
|
||
namespace Quarrel.ViewModels.SubPages.GuildSettings.Pages.Abstract | ||
{ | ||
/// <summary> | ||
/// A base class for guild settings sub-page view models. | ||
/// </summary> | ||
public abstract class GuildSettingsSubPageViewModel : ObservableObject, IGuildSettingsMenuItem | ||
{ | ||
/// <summary> | ||
/// The localization service. | ||
/// </summary> | ||
protected readonly ILocalizationService _localizationService; | ||
|
||
/// <summary> | ||
/// The storage service. | ||
/// </summary> | ||
protected readonly IStorageService _storageService; | ||
|
||
internal GuildSettingsSubPageViewModel(ILocalizationService localizationService, IStorageService storageService) | ||
{ | ||
_localizationService = localizationService; | ||
_storageService = storageService; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the string used as a glyph for the sub page. | ||
/// </summary> | ||
public abstract string Glyph { get; } | ||
|
||
/// <summary> | ||
/// Gets the title of the sub page. | ||
/// </summary> | ||
public abstract string Title { get; } | ||
|
||
/// <summary> | ||
/// Gets whether or not the page is currently active. | ||
/// </summary> | ||
public virtual bool IsActive => false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsMenuItemSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Quarrel/Selectors/SubPages/GuildSettings/GuildSettingsPageSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.