Skip to content

Commit ab1ddbb

Browse files
committed
Change ProgressBar Value to Nullable.
1 parent 8f7e661 commit ab1ddbb

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,7 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
201201
/// <summary>
202202
/// Progress bar display. Providing an int value between 0-100 will trigger the progress bar to be displayed on the result
203203
/// </summary>
204-
public int ProgressBarValue { get; set; }
205-
206-
/// <summary>
207-
/// Progress bar visibility Check
208-
/// </summary>
209-
public bool IsProgressBarVisible { get; set; } = false;
204+
public int? ProgressBar { get; set; }
210205

211206
/// <summary>
212207
/// Optionally set the color of the progress bar

Flow.Launcher/ResultListBox.xaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
mc:Ignorable="d">
2929
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
3030

31-
<ListBox.Resources>
32-
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
33-
</ListBox.Resources>
34-
3531
<ListBox.ItemTemplate>
3632
<DataTemplate>
3733
<Button HorizontalAlignment="Stretch">
@@ -118,9 +114,18 @@
118114
<ProgressBar
119115
x:Name="progressbarResult"
120116
Foreground="{Binding Result.ProgressBarColor}"
121-
Style="{DynamicResource ProgressBarResult}"
122-
Value="{Binding Result.ProgressBarValue}"
123-
Visibility="{Binding Result.IsProgressBarVisible, Converter={StaticResource BooleanToVisibilityConverter}}"/>
117+
Value="{Binding ResultProgress, Mode=OneWay}">
118+
<ProgressBar.Style>
119+
<Style TargetType="ProgressBar" BasedOn="{StaticResource ProgressBarResult}">
120+
<Setter Property="Visibility" Value="Visible"/>
121+
<Style.Triggers>
122+
<DataTrigger Binding="{Binding Result.ProgressBar}" Value="{x:Null}">
123+
<Setter Property="Visibility" Value="Collapsed"/>
124+
</DataTrigger>
125+
</Style.Triggers>
126+
</Style>
127+
</ProgressBar.Style>
128+
</ProgressBar>
124129
<TextBlock
125130
x:Name="Title"
126131
VerticalAlignment="Center"

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ private async ValueTask LoadImageAsync()
162162
}
163163

164164
public Result Result { get; }
165+
public int ResultProgress
166+
{
167+
get
168+
{
169+
if (Result.ProgressBar == null)
170+
return 0;
171+
172+
return Result.ProgressBar.Value;
173+
}
174+
}
165175

166176
public string QuerySuggestionText { get; set; }
167177

Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ internal static Result CreateDriveSpaceDisplayResult(string path, bool windowsIn
100100
AutoCompleteText = GetPathWithActionKeyword(path, ResultType.Folder),
101101
IcoPath = path,
102102
Score = 500,
103-
ProgressBarValue = progressValue,
104-
IsProgressBarVisible = true,
103+
ProgressBar = progressValue,
105104
ProgressBarColor = progressBarColor,
106105
Action = c =>
107106
{

0 commit comments

Comments
 (0)