Skip to content

Commit

Permalink
Gallery closing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Nov 1, 2024
1 parent f53250e commit a2f64f6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
55 changes: 33 additions & 22 deletions src/PicView.Avalonia/CustomControls/GalleryAnimationControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private async Task ClosedToBottomAnimation()
await vm.GalleryItemStretchTask(SettingsHelper.Settings.Gallery.BottomGalleryStretchMode);
await Dispatcher.UIThread.InvokeAsync(() =>
{
Height = 0;
IsVisible = true;
Opacity = 1;
WindowResizing.SetSize(vm);
Expand Down Expand Up @@ -203,32 +204,42 @@ await Dispatcher.UIThread.InvokeAsync(() =>

private async Task BottomToClosedAnimation()
{
if (DataContext is not MainViewModel vm || _isAnimating)
{
return;
}
await Dispatcher.UIThread.InvokeAsync(() =>
{
WindowResizing.SetSize(vm);
UIHelper.GetGalleryView.BlurMask.BlurEnabled = false;
});

vm.GalleryOrientation = Orientation.Horizontal;
vm.IsGalleryCloseIconVisible = false;
vm.GalleryMargin = new Thickness(2,0);
var from = vm.GalleryHeight;
const int to = 0;
const double speed = 0.7;
_isAnimating = true;
var heightAnimation = AnimationsHelper.HeightAnimation(from, to, speed);
await heightAnimation.RunAsync(this);
await Dispatcher.UIThread.InvokeAsync(() =>
{
Height = to;
Height = 0;
IsVisible = false;
WindowResizing.SetSize(vm);
WindowResizing.SetSize(DataContext as MainViewModel);
});
_isAnimating = false;

// TODO make fancy animation that resizes the window
// if (DataContext is not MainViewModel vm || _isAnimating)
// {
// return;
// }
//
// var from = vm.GetBottomGalleryItemHeight + SizeDefaults.ScrollbarSize;
// await Dispatcher.UIThread.InvokeAsync(() =>
// {
// Height = from;
// Opacity = 1;
// IsVisible = true;
// UIHelper.GetGalleryView.BlurMask.BlurEnabled = false;
// });
//
// const int to = 0;
// const double speed = 0.7;
// var galleryHeightAnimation = AnimationsHelper.HeightAnimation(from, to, speed);
// _isAnimating = true;
// await galleryHeightAnimation.RunAsync(this);
// await Dispatcher.UIThread.InvokeAsync(() =>
// {
// Height = to;
// IsVisible = false;
// WindowResizing.SetSize(vm);
// });
// _isAnimating = false;
// vm.GalleryOrientation = Orientation.Horizontal;
// vm.IsGalleryCloseIconVisible = false;
}

private async Task BottomToFullAnimation()
Expand Down
1 change: 0 additions & 1 deletion src/PicView.Avalonia/CustomControls/GalleryListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class GalleryListBox : ListBox

public GalleryListBox()
{
SelectionMode = SelectionMode.Single;
AddHandler(PointerPressedEvent, PreviewPointerPressedEvent, RoutingStrategies.Tunnel);
}

Expand Down
6 changes: 3 additions & 3 deletions src/PicView.Avalonia/Gallery/GalleryFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ public static async Task OpenCloseBottomGallery(MainViewModel vm)

if (SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
{
SettingsHelper.Settings.Gallery.IsBottomGalleryShown = false;
IsFullGalleryOpen = false;
IsBottomGalleryOpen = false;
vm.GalleryMode = GalleryMode.BottomToClosed;
vm.GetIsShowingBottomGalleryTranslation = TranslationHelper.Translation.ShowBottomGallery;
SettingsHelper.Settings.Gallery.IsBottomGalleryShown = false;
// IsFullGalleryOpen = false;
// IsBottomGalleryOpen = false;
await SettingsHelper.SaveSettingsAsync();
return;
}
Expand Down

0 comments on commit a2f64f6

Please sign in to comment.