Use Visibility for consistency

This commit is contained in:
Vic 2022-12-29 13:13:28 +08:00
parent e83e21dddb
commit 62821d37dd
3 changed files with 7 additions and 16 deletions

View file

@ -438,7 +438,7 @@
HorizontalAlignment="Center"
Source="{Binding PreviewImage}"
StretchDirection="DownOnly"
Visibility="{Binding ShowPreviewImage, Converter={StaticResource BoolToVisibilityConverter}}">
Visibility="{Binding ShowPreviewImage}">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="MaxWidth" Value="96" />

View file

@ -90,26 +90,18 @@ namespace Flow.Launcher.ViewModel
}
}
public bool ShowPreviewImage
public Visibility ShowPreviewImage
{
get
{
if (!string.IsNullOrEmpty(Result.Preview.PreviewImagePath) || Result.Preview.PreviewDelegate != null)
if (PreviewImageAvailable)
{
return true;
return Visibility.Visible;
}
else
{
// Fall back to Icon
if (!ImgIconAvailable && !GlyphAvailable)
return true;
// Although user can choose to use glyph icons, plugins may choose to supply only image icons.
// In this case we ignore the setting because otherwise icons will not display as intended
if (Settings.UseGlyphIcons && !GlyphAvailable && ImgIconAvailable)
return true;
return !Settings.UseGlyphIcons && ImgIconAvailable;
// Fall back to icon
return ShowIcon;
}
}
}
@ -244,7 +236,7 @@ namespace Flow.Launcher.ViewModel
{
if (ShowDefaultPreview == Visibility.Visible)
{
if (!PreviewImageLoaded && ShowPreviewImage)
if (!PreviewImageLoaded && ShowPreviewImage == Visibility.Visible)
{
PreviewImageLoaded = true;
_ = LoadPreviewImageAsync();

View file

@ -9,7 +9,6 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using JetBrains.Annotations;
namespace Flow.Launcher.ViewModel
{