瀏覽代碼

[Avalonia] Update toggling visibility of UI

Ruben 1 年之前
父節點
當前提交
b4e42807e7

+ 12 - 5
src/PicView.Avalonia/UI/HideInterfaceLogic.cs

@@ -1,5 +1,4 @@
 using Avalonia.Controls;
-using Avalonia.Threading;
 using PicView.Avalonia.Animations;
 using PicView.Avalonia.ViewModels;
 using PicView.Core.Calculations;
@@ -22,6 +21,7 @@ public static class HideInterfaceLogic
             SettingsHelper.Settings.UIProperties.ShowInterface = false;
             vm.IsTopToolbarShown = false;
             vm.IsBottomToolbarShown = false;
+            vm.IsBottomGalleryShown = SettingsHelper.Settings.Gallery.ShowBottomGalleryInHiddenUI;
         }
         else
         {
@@ -38,7 +38,7 @@ public static class HideInterfaceLogic
         
         WindowHelper.SetSize(vm);
         await FunctionsHelper.CloseMenus();
-        await SettingsHelper.SaveSettingsAsync().ConfigureAwait(false);
+        await SettingsHelper.SaveSettingsAsync();
     }
     
     /// <summary>
@@ -51,14 +51,17 @@ public static class HideInterfaceLogic
         {
             vm.IsBottomToolbarShown = false;
             SettingsHelper.Settings.UIProperties.ShowBottomNavBar = false;
+            vm.IsBottomToolbarShownSetting = false;
         }
         else
         {
             vm.IsBottomToolbarShown = true;
             SettingsHelper.Settings.UIProperties.ShowBottomNavBar = true;
+            vm.IsBottomToolbarShownSetting = true;
+            vm.BottombarHeight = SizeDefaults.BottombarHeight;
         }
         WindowHelper.SetSize(vm);
-        await SettingsHelper.SaveSettingsAsync().ConfigureAwait(false);
+        await SettingsHelper.SaveSettingsAsync();
     }
     
     #endregion
@@ -82,8 +85,12 @@ public static class HideInterfaceLogic
                 polyButton.Opacity = 0;
                 return;
             }
-            parent.Opacity = 1;
-            polyButton.Opacity = 1;
+
+            if (polyButton.IsPointerOver)
+            {
+                parent.Opacity = 1;
+                polyButton.Opacity = 1;
+            }
         };
         parent.PointerEntered += async delegate
         {

+ 6 - 6
src/PicView.Avalonia/ViewModels/MainViewModel.cs

@@ -79,7 +79,7 @@ public class MainViewModel : ViewModelBase
         set => this.RaiseAndSetIfChanged(ref _galleryMargin, value);
     }
     
-    private bool _isBottomGalleryShown = SettingsHelper.Settings.Gallery.IsBottomGalleryShown;
+    private bool _isBottomGalleryShown = SettingsHelper.Settings.UIProperties.ShowInterface && SettingsHelper.Settings.Gallery.IsBottomGalleryShown;
 
     public bool IsBottomGalleryShown
     {
@@ -87,7 +87,7 @@ public class MainViewModel : ViewModelBase
         set => this.RaiseAndSetIfChanged(ref _isBottomGalleryShown, value);
     }
 
-    private bool _isBottomGalleryShownInHiddenUi;
+    private bool _isBottomGalleryShownInHiddenUi = SettingsHelper.Settings.Gallery.ShowBottomGalleryInHiddenUI;
 
     public bool IsBottomGalleryShownInHiddenUI
     {
@@ -497,12 +497,12 @@ public class MainViewModel : ViewModelBase
         set => this.RaiseAndSetIfChanged(ref _isBottomToolbarShown, value);
     }
 
-    private bool _isShowingButtonsInHiddenUI = SettingsHelper.Settings.UIProperties.ShowAltInterfaceButtons;
+    private bool _isBottomToolbarShownSetting = SettingsHelper.Settings.UIProperties.ShowBottomNavBar;
 
-    public bool IsShowingButtonsInHiddenUI
+    public bool IsBottomToolbarShownSetting
     {
-        get => _isShowingButtonsInHiddenUI;
-        set => this.RaiseAndSetIfChanged(ref _isShowingButtonsInHiddenUI, value);
+        get => _isBottomToolbarShownSetting;
+        set => this.RaiseAndSetIfChanged(ref _isBottomToolbarShownSetting, value);
     }
     
     private bool _isShowingTaskbarProgress = SettingsHelper.Settings.UIProperties.IsTaskbarProgressEnabled;

+ 0 - 9
src/PicView.Avalonia/ViewModels/ViewModelBase.cs

@@ -158,7 +158,6 @@ public class ViewModelBase : ReactiveObject
         ShowBottomToolbar = TranslationHelper.Translation.ShowBottomToolbar;
         ShowBottomGalleryWhenUiIsHidden = TranslationHelper.Translation.ShowBottomGalleryWhenUiIsHidden;
         ChangeKeybindingTooltip = TranslationHelper.Translation.ChangeKeybindingTooltip;
-        ShowButtonsInHiddenUI = TranslationHelper.Translation.ShowButtonsInHiddenUI;
         ToggleTaskbarProgress = TranslationHelper.Translation.ToggleTaskbarProgress;
         ChangeKeybindingText = TranslationHelper.Translation.ChangeKeybindingText;
         Navigation = TranslationHelper.Translation.Navigation;
@@ -702,14 +701,6 @@ public class ViewModelBase : ReactiveObject
         set => this.RaiseAndSetIfChanged(ref _toggleTaskbarProgress, value);
     }
 
-    private string? _showButtonsInHiddenUI;
-
-    public string? ShowButtonsInHiddenUI
-    {
-        get => _showButtonsInHiddenUI;
-        set => this.RaiseAndSetIfChanged(ref _showButtonsInHiddenUI, value);
-    }
-
     private string? _changeKeybindingTooltip;
 
     public string? ChangeKeybindingTooltip

+ 1 - 17
src/PicView.Avalonia/Views/AppearanceView.axaml

@@ -51,7 +51,7 @@
             BorderThickness="0"
             Classes="altHover"
             Command="{CompiledBinding ToggleBottomNavBarCommand}"
-            IsChecked="{CompiledBinding IsBottomToolbarShown}"
+            IsChecked="{CompiledBinding IsBottomToolbarShownSetting}"
             Margin="0,0,0,3"
             Width="270">
             <TextBlock
@@ -78,22 +78,6 @@
                 Text="{CompiledBinding ShowBottomGalleryWhenUiIsHidden}" />
         </ToggleButton>
 
-        <ToggleButton
-            Background="Transparent"
-            BorderThickness="0"
-            Classes="altHover"
-            IsChecked="{CompiledBinding IsShowingButtonsInHiddenUI}"
-            IsEnabled="False"
-            Margin="0,0,0,3"
-            Width="270">
-            <TextBlock
-                Classes="txt"
-                Margin="0"
-                MaxWidth="240"
-                Padding="0,1,5,0"
-                Text="{CompiledBinding ShowButtonsInHiddenUI}" />
-        </ToggleButton>
-
         <ToggleButton
             Background="Transparent"
             BorderThickness="0"

+ 1 - 1
src/PicView.Avalonia/Views/MainView.axaml

@@ -505,7 +505,7 @@
         <views:GalleryAnimationControlView
             GalleryMode="{CompiledBinding GalleryMode}"
             Height="NaN"
-            IsVisible="False"
+            IsVisible="{CompiledBinding IsBottomGalleryShown}"
             VerticalAlignment="{CompiledBinding GalleryVerticalAlignment}"
             Width="{CompiledBinding GalleryWidth}"
             x:Name="GalleryView" />