Skip to content

Commit

Permalink
Theme fixes (macOS)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 23, 2024
1 parent 2725631 commit fcbe068
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
18 changes: 14 additions & 4 deletions src/PicView.Avalonia.MacOS/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Styling;
using Avalonia.Threading;
using PicView.Avalonia.Interfaces;
using PicView.Avalonia.MacOS.Views;
Expand All @@ -21,6 +22,7 @@ namespace PicView.Avalonia.MacOS;

public class App : Application, IPlatformSpecificService
{
private MacMainWindow? _mainWindow;
private ExifWindow? _exifWindow;
private SettingsWindow? _settingsWindow;
private KeybindingsWindow? _keybindingsWindow;
Expand All @@ -47,17 +49,25 @@ public override async void OnFrameworkInitializationCompleted()
bool settingsExists;
try
{
settingsExists = await SettingsHelper.LoadSettingsAsync();
settingsExists = await SettingsHelper.LoadSettingsAsync().ConfigureAwait(false);
_ = Task.Run(() => TranslationHelper.LoadLanguage(SettingsHelper.Settings.UIProperties.UserLanguage));
}
catch (TaskCanceledException)
{
return;
}
var w = desktop.MainWindow = new MacMainWindow();
await Dispatcher.UIThread.InvokeAsync(() =>
{
Current.RequestedThemeVariant = SettingsHelper.Settings.Theme.Dark ? ThemeVariant.Dark : ThemeVariant.Light;
_mainWindow = new MacMainWindow();
desktop.MainWindow = _mainWindow;
});
_vm = new MainViewModel(this);
w.DataContext = _vm;
StartUpHelper.Start(_vm, settingsExists, desktop, w);
await Dispatcher.UIThread.InvokeAsync(() =>
{
_mainWindow.DataContext = _vm;
StartUpHelper.Start(_vm, settingsExists, desktop, _mainWindow);
});
}

public void SetTaskbarProgress(ulong progress, ulong maximum)
Expand Down
4 changes: 2 additions & 2 deletions src/PicView.Avalonia.MacOS/Views/MacMainWindow.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Window
BorderBrush="{StaticResource SecondaryBackgroundColor}"
BorderBrush="{DynamicResource SecondaryBackgroundColor}"
BorderThickness="1"
CanResize="{Binding CanResize}"
ExtendClientAreaChromeHints="SystemChrome"
Expand Down Expand Up @@ -156,6 +156,6 @@
<DockPanel LastChildFill="True">
<views1:MacOSTitlebar DockPanel.Dock="Top" x:Name="Titlebar" />
<views:BottomBar DockPanel.Dock="Bottom" x:Name="BottomBar" />
<views:MainView Background="{StaticResource WindowBackgroundColor}" x:Name="MainView" />
<views:MainView Background="{DynamicResource WindowBackgroundColor}" x:Name="MainView" />
</DockPanel>
</Window>
18 changes: 11 additions & 7 deletions src/PicView.Avalonia.MacOS/Views/MacOSTitlebar.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
<Design.DataContext>
<viewModels:MainViewModel />
</Design.DataContext>
<DockPanel Background="{StaticResource MainBackgroundColor}" LastChildFill="True">
<DockPanel Background="{DynamicResource MainBackgroundColor}" LastChildFill="True">
<DockPanel.Resources>
<SolidColorBrush Color="{DynamicResource MainIconColor}" x:Key="Brush0" />
<SolidColorBrush Color="{DynamicResource MainIconColor}" x:Key="Brush1" />
</DockPanel.Resources>
<Rectangle DockPanel.Dock="Left" Width="70" />

<Button
Background="Transparent"
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="0"
Classes="noBorderHover"
Command="{CompiledBinding FlipCommand}"
Expand All @@ -28,7 +32,7 @@
Width="30">
<Path
Data="M192,96v64h248c4.4,0,8,3.6,8,8v240c0,4.4-3.6,8-8,8H136c-4.4,0-8-3.6-8-8v-48c0-4.4,3.6-8,8-8h248V224H192v64L64,192 L192,96z"
Fill="{StaticResource MainIconColor}"
Fill="{StaticResource Brush1}"
Height="12"
Stretch="Fill"
Width="12" />
Expand All @@ -47,15 +51,15 @@
x:Name="RotateRightButton">
<Path
Data="M142.9 142.9c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5c0 0 0 0 0 0H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5c7.7-21.8 20.2-42.3 37.8-59.8zM16 312v7.6 .7V440c0 9.7 5.8 18.5 14.8 22.2s19.3 1.7 26.2-5.2l41.6-41.6c87.6 86.5 228.7 86.2 315.8-1c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.2 62.2-162.7 62.5-225.3 1L185 329c6.9-6.9 8.9-17.2 5.2-26.2s-12.5-14.8-22.2-14.8H48.4h-.7H40c-13.3 0-24 10.7-24 24z"
Fill="{StaticResource MainIconColor}"
Fill="{StaticResource Brush1}"
Height="13"
Stretch="Fill"
Width="13" />
</Button>

<Button
Background="Transparent"
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="0"
Classes="noBorderHover"
Command="{CompiledBinding ToggleGalleryCommand}"
Expand All @@ -65,12 +69,12 @@
<Image Width="17">
<DrawingImage>
<DrawingGroup>
<GeometryDrawing Brush="{StaticResource MainIconColor}" Geometry="F1 M22 16L22 4C22 2.9 21.1 2 20 2L8 2C6.9 2 6 2.9 6 4L6 16C6 17.1 6.9 18 8 18L20 18C21.1 18 22 17.1 22 16ZM11 12L13.03 14.71L16 11L20 16L8 16L11 12ZM2 6L2 20C2 21.1 2.9 22 4 22L18 22L18 20L4 20L4 6L2 6Z" />
<GeometryDrawing Brush="{StaticResource Brush1}" Geometry="F1 M22 16L22 4C22 2.9 21.1 2 20 2L8 2C6.9 2 6 2.9 6 4L6 16C6 17.1 6.9 18 8 18L20 18C21.1 18 22 17.1 22 16ZM11 12L13.03 14.71L16 11L20 16L8 16L11 12ZM2 6L2 20C2 21.1 2.9 22 4 22L18 22L18 20L4 20L4 6L2 6Z" />
</DrawingGroup>
</DrawingImage>
</Image>
</Button>

<uc:EditableTitlebar Background="Transparent" Foreground="{StaticResource MainTextColor}" />
<uc:EditableTitlebar Background="Transparent" Foreground="{StaticResource Brush0}" />
</DockPanel>
</UserControl>

0 comments on commit fcbe068

Please sign in to comment.