Skip to content

Commit

Permalink
Feat(22): Allow customization of application theme (#83)
Browse files Browse the repository at this point in the history
* Allow customization of application theme

* Use color pickers

* Missing slider thumb and comboboxitem color

* Clean up styles file

* Code formatting

* Add translations
  • Loading branch information
dan0v authored Jul 21, 2024
1 parent 4247f53 commit da68a72
Show file tree
Hide file tree
Showing 41 changed files with 1,207 additions and 428 deletions.
2 changes: 2 additions & 0 deletions AmplitudeSoundboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.11" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.11" />
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.0.11"/>
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.11"/>
<PackageReference Include="ManagedBass" Version="3.1.1" />
<PackageReference Include="ManagedBass.Flac" Version="3.1.1" />
<PackageReference Include="ManagedBass.Mix" Version="3.1.1" />
Expand Down
5 changes: 3 additions & 2 deletions App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
<Application.Styles>
<FluentTheme>
<FluentTheme.Palettes>
<ColorPaletteResources x:Key="Light" Accent="#ff9821af" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" AltMediumLow="#e4e7e9" BaseHigh="Black" BaseLow="#fff0813a" BaseMedium="#ffad4617" BaseMediumHigh="#ff811e00" BaseMediumLow="#ff97320c" ChromeAltLow="#ff811e00" ChromeBlackHigh="Black" ChromeBlackLow="#fff0813a" ChromeBlackMedium="#ff811e00" ChromeBlackMediumLow="#ffad4617" ChromeDisabledHigh="#fff0813a" ChromeDisabledLow="#ffad4617" ChromeGray="#ff97320c" ChromeHigh="#fff0813a" ChromeLow="#ffffceac" ChromeMedium="#fffcbf95" ChromeMediumLow="#ffffceac" ChromeWhite="White" ListLow="#fffcbf95" ListMedium="#fff0813a" RegionColor="#ffbfbfc1" />
<ColorPaletteResources x:Key="Dark" Accent="#ff9821af" AltHigh="Black" AltLow="Black" AltMedium="Black" AltMediumHigh="Black" AltMediumLow="#1f2329" BaseHigh="White" BaseLow="#fff0813a" BaseMedium="#fffcbf95" BaseMediumHigh="#ffffceac" BaseMediumLow="#fff6a068" ChromeAltLow="#ffffceac" ChromeBlackHigh="Black" ChromeBlackLow="#ffffceac" ChromeBlackMedium="Black" ChromeBlackMediumLow="Black" ChromeDisabledHigh="#fff0813a" ChromeDisabledLow="#fffcbf95" ChromeGray="#fff9af7e" ChromeHigh="#fff9af7e" ChromeLow="#ff97320c" ChromeMedium="#ffad4617" ChromeMediumLow="#ffda6d2e" ChromeWhite="White" ListLow="#ffad4617" ListMedium="#fff0813a" RegionColor="#ff171a21" />
<ColorPaletteResources x:Key="Light" Accent="{Binding ThemeManager.Theme.AccentColor}" AltHigh="White" AltLow="White" AltMedium="White" AltMediumHigh="White" BaseHigh="Black" ChromeBlackHigh="Black" ChromeBlackLow="#fff0813a" ChromeBlackMediumLow="#ffad4617" ChromeWhite="White"/>
<ColorPaletteResources x:Key="Dark" Accent="{Binding ThemeManager.Theme.AccentColor}" AltHigh="Black" AltLow="Black" AltMedium="Black" AltMediumHigh="Black" BaseHigh="White" ChromeBlackHigh="Black" ChromeBlackLow="#ffffceac" ChromeBlackMediumLow="Black" ChromeWhite="White"/>
</FluentTheme.Palettes>
</FluentTheme>
<StyleInclude Source="avares://Avalonia.Controls.ColorPicker/Themes/Fluent/Fluent.xaml" />
</Application.Styles>
</Application>
5 changes: 2 additions & 3 deletions App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License
*/

using Amplitude.Helpers;
using Amplitude.Models;
using Amplitude.ViewModels;
using Amplitude.Views;
using Avalonia;
Expand Down Expand Up @@ -57,7 +56,7 @@ public static string APP_STORAGE
public static SoundClipManager SoundClipManager => SoundClipManager.Instance;
public static OutputProfileManager OutputProfileManager => OutputProfileManager.Instance;
public static HotkeysManager HotkeysManager => HotkeysManager.Instance;
public static ThemeHandler ThemeHandler => ThemeHandler.Instance;
public static ThemeManager ThemeManager => ThemeManager.Instance;
public static WindowManager WindowManager => WindowManager.Instance;
public static ConfigManager ConfigManager => ConfigManager.Instance;
public static ISoundEngine SoundEngine => MSoundEngine.Instance;
Expand Down Expand Up @@ -112,7 +111,7 @@ public override void OnFrameworkInitializationCompleted()
var p = OutputProfileManager;
var s = SoundClipManager;
var h = HotkeysManager;
var t = ThemeHandler;
var t = ThemeManager;
var w = WindowManager;
w.ReadWindowSizesAndPositions();
w.SetMainWindow((MainWindow)desktop.MainWindow);
Expand Down
Binary file added Assets/img/Dark/Reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/img/Light/Reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions Models/ConfigManager.cs → Helpers/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Helpers;
using Amplitude.Localization;
using Amplitude.Models;
using Amplitude.ViewModels;
using AmplitudeSoundboard;
using System;
Expand All @@ -29,7 +29,7 @@ You should have received a copy of the GNU General Public License
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;

namespace Amplitude.Models
namespace Amplitude.Helpers
{
[JsonSerializable(typeof(Config))]
public partial class ConfigManagerContext : JsonSerializerContext { }
Expand Down Expand Up @@ -98,10 +98,6 @@ public void SaveAndOverwriteConfig(Config config)
{
Localizer.Instance.ChangeLanguage(config.Language);
}
if (_config.ThemeId != config.ThemeId)
{
App.ThemeHandler.SelectTheme(config.ThemeId);
}

var json = App.JsonIoManager.ConvertObjectsToJSON(config);
App.JsonIoManager.SaveJSONToFile(CONFIG_FILE_LOCATION, json);
Expand Down
10 changes: 10 additions & 0 deletions Helpers/FeatureManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ private static OSPlatform GetPlatform()
{ OSPlatform.OSX, true },
{ OSPlatform.Linux, false },
}
},
{
Feature.BACKGROUND_OPACTIY,
new()
{
{ OSPlatform.Windows, true },
{ OSPlatform.OSX, true },
{ OSPlatform.Linux, false },
}
}
};

public enum Feature
{
HOTKEYS,
CUSTOM_TITLEBAR,
BACKGROUND_OPACTIY
}
}
}
2 changes: 1 addition & 1 deletion Helpers/JsonIoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Models;
using AmplitudeSoundboard;
using System;
using System.IO;
Expand All @@ -42,6 +41,7 @@ public class JsonIoManager
SoundClipManagerContext.Default,
OutputProfileManagerContext.Default,
ConfigManagerContext.Default,
ThemeManagerContext.Default,
WindowManagerContext.Default
)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Helpers;
using Amplitude.Models;
using AmplitudeSoundboard;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -28,7 +28,7 @@ You should have received a copy of the GNU General Public License
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;

namespace Amplitude.Models
namespace Amplitude.Helpers
{
[JsonSerializable(typeof(Dictionary<string, OutputProfile>))]
public partial class OutputProfileManagerContext : JsonSerializerContext { }
Expand Down
3 changes: 2 additions & 1 deletion Models/SoundClipManager.cs → Helpers/SoundClipManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
along with AmplitudeSoundboard. If not, see <https://www.gnu.org/licenses/>.
*/

using Amplitude.Models;
using AmplitudeSoundboard;
using System;
using System.Collections.Generic;
Expand All @@ -30,7 +31,7 @@ You should have received a copy of the GNU General Public License
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Amplitude.Models
namespace Amplitude.Helpers
{
[JsonSerializable(typeof(Dictionary<string, SoundClip>))]
public partial class SoundClipManagerContext : JsonSerializerContext { }
Expand Down
Loading

0 comments on commit da68a72

Please sign in to comment.