Skip to content

Commit

Permalink
Theme updates and fixes for macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Oct 30, 2024
1 parent bc409bc commit a9020e9
Show file tree
Hide file tree
Showing 16 changed files with 231 additions and 127 deletions.
70 changes: 66 additions & 4 deletions src/PicView.Avalonia.MacOS/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using PicView.Avalonia.StartUp;
using PicView.Avalonia.UI;
using PicView.Avalonia.ViewModels;
using PicView.Avalonia.Views;
using PicView.Core.Config;
using PicView.Core.FileHandling;
using PicView.Core.Localization;
Expand All @@ -24,7 +25,8 @@ public class App : Application, IPlatformSpecificService
private SettingsWindow? _settingsWindow;
private KeybindingsWindow? _keybindingsWindow;
private AboutWindow? _aboutWindow;
private ImageResizeWindow? _imageResizeWindow;
private SingleImageResizeWindow? _singleImageResizeWindow;
private BatchResizeWindow? _batchResizeWindow;
private MainViewModel? _vm;

public override void Initialize()
Expand Down Expand Up @@ -122,7 +124,7 @@ public void ShowFileProperties(string path)
}


public void ShowAboutWindow()
public void ShowAboutWindow()
{
if (Dispatcher.UIThread.CheckAccess())
{
Expand Down Expand Up @@ -279,12 +281,72 @@ public void ShowEffectsWindow()

public void ShowSingleImageResizeWindow()
{
// TODO: Implement ShowResizeWindow
if (Dispatcher.UIThread.CheckAccess())
{
Set();
}
else
{
Dispatcher.UIThread.InvokeAsync(Set);
}
return;
void Set()
{
if (Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
{
return;
}
if (_singleImageResizeWindow is null)
{
_singleImageResizeWindow = new SingleImageResizeWindow
{
DataContext = _vm,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
_singleImageResizeWindow.Show(desktop.MainWindow);
_singleImageResizeWindow.Closing += (s, e) => _singleImageResizeWindow = null;
}
else
{
_singleImageResizeWindow.Activate();
}
_= FunctionsHelper.CloseMenus();
}
}

public void ShowBatchResizeWindow()
{
// TODO: Implement ShowBatchResizeWindow
if (Dispatcher.UIThread.CheckAccess())
{
Set();
}
else
{
Dispatcher.UIThread.InvokeAsync(Set);
}
return;
void Set()
{
if (Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
{
return;
}
if (_batchResizeWindow is null)
{
_batchResizeWindow = new BatchResizeWindow
{
DataContext = _vm,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
_batchResizeWindow.Show(desktop.MainWindow);
_batchResizeWindow.Closing += (s, e) => _batchResizeWindow = null;
}
else
{
_batchResizeWindow.Activate();
}
_= FunctionsHelper.CloseMenus();
}
}

public void Print(string path)
Expand Down
4 changes: 4 additions & 0 deletions src/PicView.Avalonia.MacOS/PicView.Avalonia.MacOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<SubType>Code</SubType>
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Views\BatchResizeWindow.axaml.cs">
<DependentUpon>BatchResizeWindow.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions src/PicView.Avalonia.MacOS/Views/AboutWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@
<viewModels:MainViewModel />
</Design.DataContext>
<Border
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="1"
CornerRadius="8">
<Panel>

<DockPanel
Background="{StaticResource SecondaryBackgroundColor}"
Background="{DynamicResource SecondaryBackgroundColor}"
Height="28"
PointerPressed="MoveWindow"
VerticalAlignment="Top">

<TextBlock
Classes="txt"
Text="{CompiledBinding About}"
Text="{CompiledBinding About,
Mode=OneWay}"
TextAlignment="Center" />
</DockPanel>

<views:AboutView
Background="{StaticResource WindowBackgroundColor}"
Background="{DynamicResource WindowBackgroundColor}"
Margin="0,28,0,0"
Padding="10,5,5,10"
PointerPressed="MoveWindow"
Expand Down
2 changes: 1 addition & 1 deletion src/PicView.Avalonia.MacOS/Views/AboutWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class AboutWindow : Window
public AboutWindow()
{
InitializeComponent();
if (!SettingsHelper.Settings.Theme.Dark)
if (!SettingsHelper.Settings.Theme.Dark || SettingsHelper.Settings.Theme.GlassTheme)
{
XAboutView.Background = Brushes.Transparent;
}
Expand Down
48 changes: 48 additions & 0 deletions src/PicView.Avalonia.MacOS/Views/BatchResizeWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Window
BorderThickness="1"
ExtendClientAreaChromeHints="SystemChrome"
ExtendClientAreaTitleBarHeightHint="-1"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="PicView.Avalonia.MacOS.Views.BatchResizeWindow"
x:DataType="viewModels:MainViewModel"
xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:PicView.Avalonia.ViewModels;assembly=PicView.Avalonia"
xmlns:views="clr-namespace:PicView.Avalonia.Views;assembly=PicView.Avalonia"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.DataContext>
<viewModels:MainViewModel />
</Design.DataContext>
<Border
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="1"
CornerRadius="8">
<Panel>

<DockPanel
Background="{DynamicResource SecondaryBackgroundColor}"
Height="28"
PointerPressed="MoveWindow"
VerticalAlignment="Top">

<TextBlock
Classes="txt"
Text="{CompiledBinding ResizeImage,
Mode=OneWay}"
TextAlignment="Center" />
</DockPanel>

<views:BatchResizeView
Background="{DynamicResource WindowBackgroundColor}"
Margin="0,28,0,0"
Padding="10,5,5,10"
PointerPressed="MoveWindow"
x:Name="XAboutView" />
</Panel>
</Border>
</Window>
34 changes: 34 additions & 0 deletions src/PicView.Avalonia.MacOS/Views/BatchResizeWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Avalonia.Controls;
using Avalonia.Input;
using PicView.Core.Localization;

namespace PicView.Avalonia.MacOS.Views;

public partial class BatchResizeWindow : Window
{
public BatchResizeWindow()
{
InitializeComponent();
Loaded += (_, _) =>
{
MinWidth = MaxWidth = Width;
Height = 500;
Title = TranslationHelper.Translation.BatchResize + " - PicView";
};
KeyDown += (_, e) =>
{
if (e.Key is Key.Escape)
{
Close();
}
};
}

private void MoveWindow(object? sender, PointerPressedEventArgs e)
{
if (VisualRoot is null) { return; }

var hostWindow = (Window)VisualRoot;
hostWindow?.BeginMoveDrag(e);
}
}
20 changes: 11 additions & 9 deletions src/PicView.Avalonia.MacOS/Views/ExifWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
</Design.DataContext>
<DockPanel PointerPressed="MoveWindow">
<StackPanel
Background="{StaticResource SecondaryBackgroundColor}"
Background="{DynamicResource SecondaryBackgroundColor}"
DockPanel.Dock="Top"
Height="28"
Orientation="Horizontal"
x:Name="WindowBorder">
<Rectangle DockPanel.Dock="Left" Width="70" />

<Button
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="1,0,1,0"
Classes="noBorderHover"
Command="{CompiledBinding DuplicateFileCommand}"
Expand Down Expand Up @@ -59,7 +59,7 @@
</Button>

<Button
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="0,0,1,0"
Classes="noBorderHover"
Command="{CompiledBinding OptimizeImageCommand}"
Expand All @@ -73,11 +73,12 @@
</Button>

<Button
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="0,0,1,0"
Classes="noBorderHover"
Command="{CompiledBinding OpenWithCommand}"
CommandParameter="{CompiledBinding FileInfo.FullName}"
CommandParameter="{CompiledBinding FileInfo.FullName,
FallbackValue=''}"
Height="28"
Width="130">
<TextBlock
Expand All @@ -88,23 +89,24 @@
</Button>

<Button
BorderBrush="{StaticResource MainBorderColor}"
BorderBrush="{DynamicResource MainBorderColor}"
BorderThickness="0,0,1,0"
Classes="noBorderHover"
Command="{CompiledBinding LocateOnDiskCommand}"
CommandParameter="{CompiledBinding FileInfo.FullName}"
CommandParameter="{CompiledBinding FileInfo.FullName,
FallbackValue=''}"
Height="28"
Width="130">
<TextBlock
Classes="txt"
HorizontalAlignment="Center"
Text="{Binding ShowInFolder}"
Text="{CompiledBinding ShowInFolder}"
VerticalAlignment="Center" />
</Button>
<buttons:StarOutlineButtons Margin="10,0,0,0" />
</StackPanel>
<views:ExifView
Background="{StaticResource WindowBackgroundColor}"
Background="{DynamicResource WindowBackgroundColor}"
PointerPressed="MoveWindow"
x:Name="XExifView" />
</DockPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/PicView.Avalonia.MacOS/Views/ExifWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class ExifWindow : Window
public ExifWindow()
{
InitializeComponent();
if (!SettingsHelper.Settings.Theme.Dark)
if (!SettingsHelper.Settings.Theme.Dark || SettingsHelper.Settings.Theme.GlassTheme)
{
WindowBorder.Background = Brushes.Transparent;
XExifView.Background = Brushes.Transparent;
Expand Down
Loading

0 comments on commit a9020e9

Please sign in to comment.