Skip to content

Commit 44ea8cb

Browse files
committed
ux: re-design custom action control editor
Signed-off-by: leo <[email protected]>
1 parent 4f266a2 commit 44ea8cb

File tree

4 files changed

+56
-43
lines changed

4 files changed

+56
-43
lines changed

src/ViewModels/ConfigureCustomActionControls.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ public ConfigureCustomActionControls(AvaloniaList<Models.CustomActionControl> co
2323

2424
public void Add()
2525
{
26-
var added = new Models.CustomActionControl() { Type = Models.CustomActionControlType.TextBox };
26+
var added = new Models.CustomActionControl()
27+
{
28+
Label = "Unnamed",
29+
Type = Models.CustomActionControlType.TextBox
30+
};
31+
2732
Controls.Add(added);
2833
Edit = added;
2934
}

src/Views/ConfigureCustomActionControls.axaml

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
<TextBlock Margin="0,12,0,0" Text="{DynamicResource Text.ConfigureCustomActionControls.Type}"/>
130130
<ComboBox Margin="0,4,0,0" Height="28" HorizontalAlignment="Stretch" SelectedIndex="{Binding Type, Mode=TwoWay}">
131131
<ComboBoxItem Content="TextBox"/>
132-
<ComboBoxItem Content="Path Selector"/>
132+
<ComboBoxItem Content="PathSelector"/>
133133
<ComboBoxItem Content="CheckBox"/>
134134
<ComboBoxItem Content="ComboBox"/>
135135
</ComboBox>
@@ -146,67 +146,69 @@
146146
Text="{DynamicResource Text.ConfigureCustomActionControls.Description.Tip}"
147147
Foreground="{DynamicResource Brush.FG2}"/>
148148

149-
<!-- Default value/Options -->
149+
<!-- BoolValue is needed by CheckBox/PathSelector -->
150150
<TextBlock Margin="0,12,0,0"
151151
Text="{DynamicResource Text.ConfigureCustomActionControls.DefaultValue}"
152-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:CustomActionControlType.ComboBox}}"/>
152+
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"/>
153+
<TextBlock Margin="0,12,0,0"
154+
Text="{DynamicResource Text.ConfigureCustomActionControls.IsFolder}"
155+
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.PathSelector}}"/>
156+
<CheckBox Height="28"
157+
Margin="0,4,0,0"
158+
IsChecked="{Binding BoolValue, Mode=TwoWay}">
159+
<CheckBox.IsVisible>
160+
<MultiBinding Converter="{x:Static BoolConverters.Or}">
161+
<Binding Path="Type" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:CustomActionControlType.CheckBox}}"/>
162+
<Binding Path="Type" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:CustomActionControlType.PathSelector}}"/>
163+
</MultiBinding>
164+
</CheckBox.IsVisible>
165+
</CheckBox>
166+
167+
<!-- StringValue -->
168+
<TextBlock Margin="0,12,0,0"
169+
Text="{DynamicResource Text.ConfigureCustomActionControls.CheckedValue}"
170+
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"/>
153171
<TextBlock Margin="0,12,0,0"
154172
Text="{DynamicResource Text.ConfigureCustomActionControls.Options}"
155173
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.ComboBox}}"/>
156-
<TextBox Margin="0,4,0,0"
157-
CornerRadius="3"
158-
Height="28"
159-
Text="{Binding StringValue, Mode=TwoWay}"
160-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"/>
161-
<TextBlock Margin="0,2,0,0"
162-
Classes="small"
163-
TextWrapping="Wrap"
164-
Text="{DynamicResource Text.Configure.CustomAction.Arguments.Tip}"
165-
Foreground="{DynamicResource Brush.FG2}"
166-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}">
174+
<TextBlock Margin="0,12,0,0"
175+
Text="{DynamicResource Text.ConfigureCustomActionControls.DefaultValue}">
167176
<TextBlock.IsVisible>
168177
<MultiBinding Converter="{x:Static BoolConverters.Or}">
169178
<Binding Path="Type" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:CustomActionControlType.TextBox}"/>
170179
<Binding Path="Type" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:CustomActionControlType.PathSelector}"/>
171180
</MultiBinding>
172181
</TextBlock.IsVisible>
173182
</TextBlock>
183+
<TextBox Margin="0,4,0,0"
184+
CornerRadius="3"
185+
Height="28"
186+
Text="{Binding StringValue, Mode=TwoWay}"/>
187+
<TextBlock Margin="0,2,0,0"
188+
Classes="small"
189+
TextWrapping="Wrap"
190+
Text="{DynamicResource Text.ConfigureCustomActionControls.CheckedValue.Tip}"
191+
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"
192+
Foreground="{DynamicResource Brush.FG2}"/>
174193
<TextBlock Margin="0,2,0,0"
175194
Classes="small"
176195
TextWrapping="Wrap"
177196
Text="{DynamicResource Text.ConfigureCustomActionControls.Options.Tip}"
178197
Foreground="{DynamicResource Brush.FG2}"
179198
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.ComboBox}}">
180199
</TextBlock>
181-
<CheckBox Height="28"
182-
Margin="0,4,0,0"
183-
IsChecked="{Binding BoolValue, Mode=TwoWay}"
184-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"/>
185-
186-
<!-- PathSelector needs a bool to determine whether we want a folder or a file -->
187-
<TextBlock Margin="0,12,0,0"
188-
Text="{DynamicResource Text.ConfigureCustomActionControls.IsFolder}"
189-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.PathSelector}}"/>
190-
<CheckBox Height="28"
191-
Margin="0,4,0,0"
192-
IsChecked="{Binding BoolValue, Mode=TwoWay}"
193-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.PathSelector}}"/>
194-
195-
<!-- CheckBox needs a checked value for commandline -->
196-
<TextBlock Margin="0,12,0,0"
197-
Text="{DynamicResource Text.ConfigureCustomActionControls.CheckedValue}"
198-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"/>
199-
<TextBox Margin="0,4,0,0"
200-
CornerRadius="3"
201-
Height="28"
202-
Text="{Binding StringValue, Mode=TwoWay}"
203-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"/>
204200
<TextBlock Margin="0,2,0,0"
205201
Classes="small"
206202
TextWrapping="Wrap"
207-
Text="{DynamicResource Text.ConfigureCustomActionControls.CheckedValue.Tip}"
208-
IsVisible="{Binding Type, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:CustomActionControlType.CheckBox}}"
209-
Foreground="{DynamicResource Brush.FG2}"/>
203+
Text="{DynamicResource Text.Configure.CustomAction.Arguments.Tip}"
204+
Foreground="{DynamicResource Brush.FG2}">
205+
<TextBlock.IsVisible>
206+
<MultiBinding Converter="{x:Static BoolConverters.Or}">
207+
<Binding Path="Type" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:CustomActionControlType.TextBox}"/>
208+
<Binding Path="Type" Converter="{x:Static ObjectConverters.Equal}" ConverterParameter="{x:Static m:CustomActionControlType.PathSelector}"/>
209+
</MultiBinding>
210+
</TextBlock.IsVisible>
211+
</TextBlock>
210212
</StackPanel>
211213
</DataTemplate>
212214
</ContentControl.DataTemplates>

src/Views/Preferences.axaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,10 @@
664664
<Button Margin="0,4,0,0" Classes="flat" Height="28" Click="EditCustomActionControls">
665665
<StackPanel Orientation="Horizontal">
666666
<Path Width="14" Height="14" Data="{StaticResource Icons.Edit}" Fill="{DynamicResource Brush.FG1}"/>
667-
<TextBlock Margin="4,0,0,0" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Edit}"/>
667+
<TextBlock Margin="4,0" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Edit}"/>
668+
<Border Height="16" Background="{DynamicResource Brush.Badge}" CornerRadius="8" VerticalAlignment="Center">
669+
<TextBlock Classes="primary" Text="{Binding Controls.Count}" Margin="8,0" FontSize="10" Foreground="{DynamicResource Brush.BadgeFG}"/>
670+
</Border>
668671
</StackPanel>
669672
</Button>
670673
<TextBlock Margin="0,2,0,0" TextWrapping="Wrap" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Tip}" Foreground="{DynamicResource Brush.FG2}"/>

src/Views/RepositoryConfigure.axaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@
492492
<Button Margin="0,4,0,0" Classes="flat" Height="28" Click="EditCustomActionControls">
493493
<StackPanel Orientation="Horizontal">
494494
<Path Width="14" Height="14" Data="{StaticResource Icons.Edit}" Fill="{DynamicResource Brush.FG1}"/>
495-
<TextBlock Margin="4,0,0,0" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Edit}"/>
495+
<TextBlock Margin="4,0" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Edit}"/>
496+
<Border Height="16" Background="{DynamicResource Brush.Badge}" CornerRadius="8" VerticalAlignment="Center">
497+
<TextBlock Classes="primary" Text="{Binding Controls.Count}" Margin="8,0" FontSize="10" Foreground="{DynamicResource Brush.BadgeFG}"/>
498+
</Border>
496499
</StackPanel>
497500
</Button>
498501
<TextBlock Margin="0,2,0,0" TextWrapping="Wrap" Text="{DynamicResource Text.Configure.CustomAction.InputControls.Tip}" Foreground="{DynamicResource Brush.FG2}"/>

0 commit comments

Comments
 (0)