-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
382774c
commit 1055403
Showing
6 changed files
with
301 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<Page | ||
x:Class="Emerald.Views.Settings.AppearancePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Emerald.Views.Settings" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" xmlns:Main="using:Emerald" xmlns:SS="using:Emerald.Helpers.Settings" xmlns:helpers="using:Emerald.Helpers" | ||
DataContext="{x:Bind SS:SettingsSystem.Settings}" xmlns:cn="using:CommunityToolkit.WinUI.Controls" xmlns:uc="using:Emerald.UserControls" xmlns:windowsui="using:Windows.UI"> | ||
<Grid | ||
Margin="16"> | ||
<StackPanel | ||
Spacing="4"> | ||
<cn:SettingsCard | ||
Header="{helpers:Localize Name=ColorMode}" | ||
Description="{helpers:Localize Name=ColorModeDescription}" | ||
HeaderIcon="{helpers:FontIcon Glyph=}"> | ||
<ComboBox | ||
SelectedIndex="{Binding App.Appearance.Theme, Mode=TwoWay}"> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=SystemDefault}" /> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=Light}" /> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=Dark}" /> | ||
</ComboBox> | ||
</cn:SettingsCard> | ||
<cn:SettingsCard | ||
Header="{helpers:Localize Name=MicaType}" | ||
Description="{helpers:Localize Name=MicaTypeDescription}" | ||
HeaderIcon="{helpers:FontIcon Glyph=}"> | ||
<ComboBox | ||
SelectedIndex="{Binding App.Appearance.MicaType, Mode=TwoWay}"> | ||
<ComboBoxItem | ||
Content="Mica" /> | ||
<ComboBoxItem | ||
Content="Mica Alt" /> | ||
</ComboBox> | ||
</cn:SettingsCard> | ||
<cn:SettingsCard | ||
Header="{helpers:Localize Name=NavIconStyle}" | ||
Description="{helpers:Localize Name=NavIconStyleDescription}" | ||
HeaderIcon="{helpers:FontIcon Glyph=}"> | ||
<ComboBox | ||
SelectedIndex="{Binding App.Appearance.NavIconType, Mode=TwoWay}"> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=Default}" /> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=Colorful}" /> | ||
</ComboBox> | ||
</cn:SettingsCard> | ||
<cn:SettingsExpander | ||
IsExpanded="True" | ||
Header="{helpers:Localize Name=WindowTintColor}" | ||
Description="{helpers:Localize Name=WindowTintColorDescription}" | ||
HeaderIcon="{helpers:FontIcon Glyph=}"> | ||
<cn:SettingsExpander.Content> | ||
<ComboBox | ||
SelectedIndex="{Binding App.Appearance.MicaTintColor, Mode=TwoWay}"> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=NoColor}" /> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=AccentColor}" /> | ||
<ComboBoxItem | ||
Content="{helpers:Localize Name=CustomColor}" /> | ||
</ComboBox> | ||
</cn:SettingsExpander.Content> | ||
<cn:SettingsExpander.ItemsHeader> | ||
<Grid | ||
Padding="12" | ||
Background="{StaticResource ExpanderHeaderBackground}"> | ||
<GridView | ||
DataContext="{x:Bind}" | ||
x:Name="GVColorList" | ||
ItemsSource="{x:Bind TintColorsList}" | ||
SelectionChanged="GVColorList_SelectionChanged" | ||
SelectionMode="Single"> | ||
<GridView.ItemContainerStyle> | ||
<Style | ||
TargetType="GridViewItem"> | ||
<Setter | ||
Property="Margin" | ||
Value="2" /> | ||
</Style> | ||
</GridView.ItemContainerStyle> | ||
<GridView.ItemsPanel> | ||
<ItemsPanelTemplate> | ||
<ItemsWrapGrid | ||
MaximumRowsOrColumns="12" | ||
Orientation="Horizontal" /> | ||
</ItemsPanelTemplate> | ||
</GridView.ItemsPanel> | ||
<GridView.ItemTemplate> | ||
<DataTemplate | ||
x:DataType="windowsui:Color"> | ||
<Border | ||
Width="48" | ||
Height="48" | ||
CornerRadius="6"> | ||
<Border.Background> | ||
<SolidColorBrush | ||
Color="{x:Bind}" /> | ||
</Border.Background> | ||
</Border> | ||
</DataTemplate> | ||
</GridView.ItemTemplate> | ||
</GridView> | ||
</Grid> | ||
</cn:SettingsExpander.ItemsHeader> | ||
<cn:SettingsExpander.Items> | ||
<cn:SettingsCard | ||
Header="{helpers:Localize Name=CustomColors}"> | ||
<Button | ||
Click="CustomTintColor_Click" | ||
Content="{helpers:Localize Name=Add}" /> | ||
</cn:SettingsCard> | ||
</cn:SettingsExpander.Items> | ||
</cn:SettingsExpander> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
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,147 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Emerald.Helpers; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI; | ||
using SS = Emerald.Helpers.Settings.SettingsSystem; | ||
|
||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 | ||
|
||
namespace Emerald.Views.Settings; | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class AppearancePage : Page | ||
{ | ||
|
||
public ObservableCollection<Color> TintColorsList { get; } = new() | ||
{ | ||
Color.FromArgb(255, 255, 185, 0), | ||
Color.FromArgb(255, 255, 140, 0), | ||
Color.FromArgb(255, 247, 99, 12), | ||
Color.FromArgb(255, 202, 80, 16), | ||
Color.FromArgb(255, 218, 59, 1), | ||
Color.FromArgb(255, 239, 105, 80), | ||
Color.FromArgb(255, 209, 52, 56), | ||
Color.FromArgb(255, 255, 67, 67), | ||
Color.FromArgb(255, 231, 72, 86), | ||
Color.FromArgb(255, 232, 17, 35), | ||
Color.FromArgb(255, 234, 0, 94), | ||
Color.FromArgb(255, 195, 0, 82), | ||
Color.FromArgb(255, 227, 0, 140), | ||
Color.FromArgb(255, 191, 0, 119), | ||
Color.FromArgb(255, 194, 57, 179), | ||
Color.FromArgb(255, 154, 0, 137), | ||
Color.FromArgb(255, 0, 120, 212), | ||
Color.FromArgb(255, 0, 99, 177), | ||
Color.FromArgb(255, 142, 140, 216), | ||
Color.FromArgb(255, 107, 105, 214), | ||
Color.FromArgb(255, 135, 100, 184), | ||
Color.FromArgb(255, 116, 77, 169), | ||
Color.FromArgb(255, 177, 70, 194), | ||
Color.FromArgb(255, 136, 23, 152), | ||
Color.FromArgb(255, 0, 153, 188), | ||
Color.FromArgb(255, 45, 125, 154), | ||
Color.FromArgb(255, 0, 183, 195), | ||
Color.FromArgb(255, 3, 131, 135), | ||
Color.FromArgb(255, 0, 178, 148), | ||
Color.FromArgb(255, 1, 133, 116), | ||
Color.FromArgb(255, 0, 204, 106), | ||
Color.FromArgb(255, 16, 137, 62), | ||
Color.FromArgb(255, 122, 117, 116), | ||
Color.FromArgb(255, 93, 90, 88), | ||
Color.FromArgb(255, 104, 118, 138), | ||
Color.FromArgb(255, 81, 92, 107), | ||
Color.FromArgb(255, 86, 124, 115), | ||
Color.FromArgb(255, 72, 104, 96), | ||
Color.FromArgb(255, 73, 130, 5), | ||
Color.FromArgb(255, 16, 124, 16), | ||
Color.FromArgb(255, 118, 118, 118), | ||
Color.FromArgb(255, 76, 74, 72), | ||
Color.FromArgb(255, 105, 121, 126), | ||
Color.FromArgb(255, 74, 84, 89), | ||
Color.FromArgb(255, 100, 124, 100), | ||
Color.FromArgb(255, 82, 94, 84), | ||
Color.FromArgb(255, 132, 117, 69), | ||
Color.FromArgb(255, 126, 115, 95) | ||
}; | ||
|
||
public AppearancePage() | ||
{ | ||
InitializeComponent(); | ||
|
||
if (SS.Settings.App.Appearance.MicaTintColor == (int)Helpers.Settings.Enums.MicaTintColor.CustomColor) | ||
{ | ||
if (SS.Settings.App.Appearance.CustomMicaTintColor != null) | ||
{ | ||
var c = SS.Settings.App.Appearance.CustomMicaTintColor; | ||
var cl = Color.FromArgb((byte)c.Value.A, (byte)c.Value.R, (byte)c.Value.G, (byte)c.Value.B); | ||
|
||
if (TintColorsList.Contains(cl)) | ||
GVColorList.SelectedIndex = TintColorsList.IndexOf(cl); | ||
else | ||
{ | ||
TintColorsList.Add(cl); | ||
GVColorList.SelectedIndex = TintColorsList.Count - 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void GVColorList_SelectionChanged(object sender, SelectionChangedEventArgs e) | ||
{ | ||
var c = TintColorsList[GVColorList.SelectedIndex]; | ||
|
||
SS.Settings.App.Appearance.MicaTintColor = (int)Helpers.Settings.Enums.MicaTintColor.CustomColor; | ||
SS.Settings.App.Appearance.CustomMicaTintColor = (c.A, c.R, c.G, c.B); | ||
} | ||
|
||
private void CustomTintColor_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) | ||
{ | ||
var c = SS.Settings.App.Appearance.CustomMicaTintColor; | ||
var cp = new ColorPicker() | ||
{ | ||
ColorSpectrumShape = ColorSpectrumShape.Box, | ||
IsMoreButtonVisible = false, | ||
IsColorSliderVisible = true, | ||
IsColorChannelTextInputVisible = true, | ||
IsHexInputVisible = true, | ||
IsAlphaEnabled = true, | ||
IsAlphaSliderVisible = true, | ||
IsAlphaTextInputVisible = false, | ||
Color = Color.FromArgb((byte)(c?.A ?? 0), (byte)(c?.R ?? 0), (byte)(c?.G ?? 0), (byte)(c?.B ?? 0)) | ||
}; | ||
|
||
var d = cp.ToContentDialog("CreateAColor".Localize(), "Cancel".Localize(), ContentDialogButton.Primary); | ||
|
||
d.PrimaryButtonText = "OK".Localize(); | ||
|
||
d.PrimaryButtonClick += (_, _) => | ||
{ | ||
var cl = cp.Color; | ||
if (TintColorsList.Contains(cl)) | ||
{ | ||
GVColorList.SelectedIndex = TintColorsList.IndexOf(cl); | ||
} | ||
else | ||
{ | ||
TintColorsList.Add(cl); | ||
GVColorList.SelectedIndex = TintColorsList.Count - 1; | ||
} | ||
}; | ||
|
||
_ = d.ShowAsync(); | ||
} | ||
} |
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