remove null state from action keyword Enabled status

This commit is contained in:
Jeremy 2021-09-01 21:17:20 +10:00
parent 267fb6551b
commit 91564e0933
3 changed files with 9 additions and 10 deletions

View file

@ -31,7 +31,7 @@
Margin="10" Grid.Row="0" Grid.Column="2" Content="{DynamicResource plugin_explorer_actionkeyword_enabled}"
Width="auto"
VerticalAlignment="Center" IsChecked="{Binding Enabled}"
Visibility="{Binding Visible}"/>
Visibility="{Binding EnabledVisibility}"/>
<Button Name="DownButton"
Click="OnDoneButtonClick" Grid.Row="1" Grid.Column="2"
Margin="10 0 10 0" Width="80" Height="35"

View file

@ -23,18 +23,18 @@ namespace Flow.Launcher.Plugin.Explorer.Views
set
{
// Set Enable to be true if user change ActionKeyword
if (Enabled is not null)
Enabled = true;
Enabled = true;
_actionKeyword = value;
}
}
public bool? Enabled { get; set; }
public bool Enabled { get; set; }
private string _actionKeyword;
public Visibility Visible =>
CurrentActionKeyword.Enabled is not null ? Visibility.Visible : Visibility.Collapsed;
public Visibility EnabledVisibility
=> CurrentActionKeyword.KeywordProperty == Settings.ActionKeyword.FileContentSearchActionKeyword
? Visibility.Collapsed : Visibility.Visible;
public ActionKeywordSetting(SettingsViewModel settingsViewModel,
ActionKeywordView selectedActionKeyword)

View file

@ -325,7 +325,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
public string Description { get; private init; }
public string Color => Enabled ?? true ? "Black" : "Gray";
public string Color => Enabled ? "Black" : "Gray";
internal Settings.ActionKeyword KeywordProperty { get; }
@ -335,11 +335,10 @@ namespace Flow.Launcher.Plugin.Explorer.Views
set => _settings.SetActionKeyword(KeywordProperty, value);
}
public bool? Enabled
public bool Enabled
{
get => _settings.GetActionKeywordEnabled(KeywordProperty);
set => _settings.SetActionKeywordEnabled(KeywordProperty,
value ?? throw new ArgumentException("Unexpected null value"));
set => _settings.SetActionKeywordEnabled(KeywordProperty, value);
}
}
}