Set VirtualizingPanel.ScrollUnit and ScrollViewer.CanContentScroll for other tab.

Close Flyout when clicking install
This commit is contained in:
Hongtao Zhang 2022-11-08 11:05:58 -06:00
parent 6e76d87f66
commit ad77ecdf02
No known key found for this signature in database
GPG key ID: 75F655B91C7AC9BB
3 changed files with 58 additions and 14 deletions

View file

@ -607,7 +607,8 @@
<ScrollViewer
Margin="0,0,0,0"
Background="{DynamicResource Color01B}"
ScrollViewer.CanContentScroll="False"
CanContentScroll="True"
VirtualizingPanel.ScrollUnit="Pixel"
VirtualizingStackPanel.IsVirtualizing="True">
<StackPanel Margin="5,18,25,30" Orientation="Vertical">
<TextBlock
@ -1395,6 +1396,7 @@
FontSize="14"
KeyDown="PluginStoreFilterTxb_OnKeyDown"
LostFocus="RefreshPluginStoreEventHandler"
Text=""
TextAlignment="Left"
ToolTip="{DynamicResource searchpluginToolTip}"
@ -1436,7 +1438,7 @@
Padding="12,4,12,4"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="OnPluginStoreRefreshClick"
Command="{Binding RefreshExternalPluginsCommand}"
Content="{DynamicResource refresh}"
DockPanel.Dock="Right"
FontSize="13" />
@ -1515,7 +1517,8 @@
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
BorderThickness="0"
FocusVisualStyle="{StaticResource StoreItemFocusVisualStyleKey}">
FocusVisualStyle="{StaticResource StoreItemFocusVisualStyleKey}"
Click="StoreListItem_Click">
<ui:FlyoutService.Flyout>
<ui:Flyout x:Name="InstallFlyout" Placement="Bottom">
<Grid MinWidth="200">
@ -1675,7 +1678,8 @@
<ScrollViewer
Margin="0,0,0,0"
Padding="6,0,24,0"
ScrollViewer.CanContentScroll="False"
ScrollViewer.CanContentScroll="True"
VirtualizingStackPanel.ScrollUnit="Pixel"
VirtualizingStackPanel.IsVirtualizing="True">
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
@ -2252,7 +2256,8 @@
<ScrollViewer
Margin="0,0,0,0"
Padding="0,0,6,0"
ScrollViewer.CanContentScroll="False"
ScrollViewer.CanContentScroll="True"
VirtualizingStackPanel.ScrollUnit="Pixel"
VirtualizingStackPanel.IsVirtualizing="True">
<Border>
<Grid Margin="5,18,18,10">
@ -2547,7 +2552,8 @@
<ScrollViewer
Margin="0,0,0,0"
Padding="5,0,24,0"
ScrollViewer.CanContentScroll="False"
ScrollViewer.CanContentScroll="True"
VirtualizingStackPanel.ScrollUnit="Pixel"
VirtualizingStackPanel.IsVirtualizing="True">
<Border>
@ -2720,7 +2726,8 @@
<ScrollViewer
Margin="0,0,0,0"
Background="{DynamicResource Color01B}"
ScrollViewer.CanContentScroll="False"
ScrollViewer.CanContentScroll="True"
VirtualizingStackPanel.ScrollUnit="Pixel"
VirtualizingStackPanel.IsVirtualizing="True">
<StackPanel Margin="5,14,25,30" Orientation="Vertical">
<TextBlock

View file

@ -18,6 +18,7 @@ using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Navigation;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using Button = System.Windows.Controls.Button;
@ -300,17 +301,35 @@ namespace Flow.Launcher
}
}
private void OnPluginStoreRefreshClick(object sender, RoutedEventArgs e)
private static T FindParent<T>(DependencyObject child) where T : DependencyObject
{
_ = viewModel.RefreshExternalPluginsAsync();
}
//get parent item
DependencyObject parentObject = VisualTreeHelper.GetParent(child);
//we've reached the end of the tree
if (parentObject == null) return null;
//check if the parent matches the type we're looking for
T parent = parentObject as T;
if (parent != null)
return parent;
else
return FindParent<T>(parentObject);
}
private void OnExternalPluginInstallClick(object sender, RoutedEventArgs e)
{
if (sender is Button { DataContext: PluginStoreItemViewModel plugin })
if (sender is not Button { DataContext: PluginStoreItemViewModel plugin } button)
{
viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"));
return;
}
if (storeClickedButton != null)
{
FlyoutService.GetFlyout(storeClickedButton).Hide();
}
viewModel.DisplayPluginQuery($"install {plugin.Name}", PluginManager.GetPluginForId("9f8f9b14-2518-4907-b211-35ab6290dee7"));
}
private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e)
@ -545,5 +564,21 @@ namespace Flow.Launcher
return top;
}
private Button storeClickedButton;
private void StoreListItem_Click(object sender, RoutedEventArgs e)
{
if (sender is not Button button)
return;
storeClickedButton = button;
var flyout = FlyoutService.GetFlyout(button);
flyout.Closed += (_, _) =>
{
storeClickedButton = null;
};
}
}
}

View file

@ -20,10 +20,11 @@ using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.Input;
namespace Flow.Launcher.ViewModel
{
public class SettingWindowViewModel : BaseModel
public partial class SettingWindowViewModel : BaseModel
{
private readonly Updater _updater;
private readonly IPortable _portable;
@ -330,7 +331,8 @@ namespace Flow.Launcher.ViewModel
}
}
public async Task RefreshExternalPluginsAsync()
[RelayCommand]
private async Task RefreshExternalPluginsAsync()
{
await PluginsManifest.UpdateManifestAsync();
OnPropertyChanged(nameof(ExternalPlugins));