Skip to content

Commit 1f86e2f

Browse files
Use State triggers
1 parent ca63881 commit 1f86e2f

File tree

3 files changed

+12
-36
lines changed

3 files changed

+12
-36
lines changed

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4068,6 +4068,6 @@
40684068
<value>Enter a path or launch alias</value>
40694069
</data>
40704070
<data name="InvalidIDENameError" xml:space="preserve">
4071-
<value>Please, enter a name for the IDE</value>
4071+
<value>Please enter a name for the IDE</value>
40724072
</data>
40734073
</root>

src/Files.App/Views/Settings/DevToolsPage.xaml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
xmlns:uc="using:Files.App.UserControls"
1313
xmlns:vm="using:Files.App.ViewModels.Settings"
1414
xmlns:wctconverters="using:CommunityToolkit.WinUI.Converters"
15-
SizeChanged="Page_SizeChanged"
1615
mc:Ignorable="d">
1716

1817
<Page.Resources>
@@ -96,9 +95,8 @@
9695

9796
<TextBox
9897
x:Name="IDENameTextBox"
99-
Grid.ColumnSpan="2"
100-
Width="300"
101-
HorizontalAlignment="Left"
98+
Grid.ColumnSpan="3"
99+
HorizontalAlignment="Stretch"
102100
VerticalAlignment="Center"
103101
PlaceholderText="{helpers:ResourceString Name=Name}"
104102
Text="{x:Bind ViewModel.IDEName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -142,12 +140,12 @@
142140
Grid.Row="1"
143141
Grid.ColumnSpan="3"
144142
Margin="0,8,0,0"
145-
Orientation="Horizontal"
146-
Spacing="8"
143+
Orientation="Vertical"
144+
Spacing="12"
147145
Visibility="{x:Bind ViewModel.IsEditingIDEConfig, Converter={StaticResource BoolVisibilityConverter}, Mode=OneWay}">
148146
<TextBox
149147
x:Name="IDEPathTextBox"
150-
Width="300"
148+
HorizontalAlignment="Stretch"
151149
VerticalAlignment="Center"
152150
PlaceholderText="{helpers:ResourceString Name=IDEPathPlaceholder}"
153151
Text="{x:Bind ViewModel.IDEPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
@@ -248,10 +246,12 @@
248246
<VisualStateManager.VisualStateGroups>
249247
<VisualStateGroup>
250248
<VisualState x:Name="DefaultState">
249+
<VisualState.StateTriggers>
250+
<AdaptiveTrigger MinWindowWidth="780" />
251+
</VisualState.StateTriggers>
251252
<VisualState.Setters>
252253
<Setter Target="IDEPathTextBox.Width" Value="300" />
253254
<Setter Target="IDEPathTextBox.HorizontalAlignment" Value="Left" />
254-
<Setter Target="IDEPathTextBox.(Grid.Column)" Value="0" />
255255
<Setter Target="IDENameTextBox.Width" Value="300" />
256256
<Setter Target="IDENameTextBox.HorizontalAlignment" Value="Left" />
257257
<Setter Target="IDENameTextBox.(Grid.ColumnSpan)" Value="2" />
@@ -260,10 +260,12 @@
260260
</VisualState.Setters>
261261
</VisualState>
262262
<VisualState x:Name="CompactState">
263+
<VisualState.StateTriggers>
264+
<AdaptiveTrigger MinWindowWidth="0" />
265+
</VisualState.StateTriggers>
263266
<VisualState.Setters>
264267
<Setter Target="IDEPathTextBox.Width" Value="Auto" />
265268
<Setter Target="IDEPathTextBox.HorizontalAlignment" Value="Stretch" />
266-
<Setter Target="IDEPathTextBox.(Grid.Column)" Value="3" />
267269
<Setter Target="IDENameTextBox.Width" Value="Auto" />
268270
<Setter Target="IDENameTextBox.HorizontalAlignment" Value="Stretch" />
269271
<Setter Target="IDENameTextBox.(Grid.ColumnSpan)" Value="3" />
Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4-
using Files.App.ViewModels.Settings;
5-
using Microsoft.UI.Xaml;
64
using Microsoft.UI.Xaml.Controls;
75

86
namespace Files.App.Views.Settings
@@ -12,30 +10,6 @@ public sealed partial class DevToolsPage : Page
1210
public DevToolsPage()
1311
{
1412
InitializeComponent();
15-
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
16-
}
17-
18-
private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e)
19-
{
20-
if (e.PropertyName is nameof(DevToolsViewModel.IsEditingIDEConfig))
21-
SetVisualState(ActualWidth);
22-
}
23-
24-
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
25-
{
26-
if (e.NewSize.Width == e.PreviousSize.Width)
27-
return;
28-
29-
SetVisualState(e.NewSize.Width);
30-
}
31-
32-
private void SetVisualState(double width)
33-
{
34-
var defaultPathWidth = 300;
35-
var pickIDEWidth = PickIDEExe.ActualWidth == 0 ? 64 : PickIDEExe.ActualWidth;
36-
var minWidth = defaultPathWidth + pickIDEWidth;
37-
var state = minWidth > width / 1.6 ? "CompactState" : "DefaultState";
38-
VisualStateManager.GoToState(this, state, false);
3913
}
4014
}
4115
}

0 commit comments

Comments
 (0)