Skip to content

Commit 372dc1e

Browse files
committed
Layout type
1 parent 986518a commit 372dc1e

File tree

5 files changed

+70
-58
lines changed

5 files changed

+70
-58
lines changed

src/Files.App/Services/Settings/LayoutSettingsService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ public bool SyncFolderPreferencesAcrossDirectories
1919
set => Set(value);
2020
}
2121

22+
public FolderLayoutModes DefaultLayoutMode
23+
{
24+
get => (FolderLayoutModes)Get((long)FolderLayoutModes.Adaptive);
25+
set => Set((long)value);
26+
}
27+
2228

2329
public SortOption DefaultSortOption
2430
{
@@ -62,13 +68,6 @@ public bool DefaultSortFilesFirst
6268
set => Set(value);
6369
}
6470

65-
66-
public FolderLayoutModes DefaultLayoutMode
67-
{
68-
get => (FolderLayoutModes)Get((long)FolderLayoutModes.Adaptive);
69-
set => Set((long)value);
70-
}
71-
7271
public double GitStatusColumnWidth
7372
{
7473
get => Get(80d);
@@ -335,6 +334,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
335334
{
336335
case nameof(SyncFolderPreferencesAcrossDirectories):
337336
case nameof(DefaultLayoutMode):
337+
338338
case nameof(GitStatusColumnWidth):
339339
case nameof(GitLastCommitDateColumnWidth):
340340
case nameof(GitLastCommitMessageColumnWidth):

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,13 +1842,13 @@
18421842
<data name="CompatibilityDoNotAdjustDPI" xml:space="preserve">
18431843
<value>Do not adjust DPI</value>
18441844
</data>
1845-
<data name="CompatibilityDoNotOverrideDPI" xml:space="preserve">
1845+
<data name="CompatibilityDoNotOverrideDPI" xml:space="preserve">
18461846
<value>Do not override DPI</value>
18471847
</data>
1848-
<data name="CompatibilityMode" xml:space="preserve">
1848+
<data name="CompatibilityMode" xml:space="preserve">
18491849
<value>Compatibility mode</value>
18501850
</data>
1851-
<data name="CompatibilityNoReducedColor" xml:space="preserve">
1851+
<data name="CompatibilityNoReducedColor" xml:space="preserve">
18521852
<value>No reduced color</value>
18531853
</data>
18541854
<data name="ThirdPartyLicenses" xml:space="preserve">
@@ -3713,4 +3713,7 @@
37133713
<value>Extra large</value>
37143714
<comment>Used to describe layout sizes</comment>
37153715
</data>
3716-
</root>
3716+
<data name="LayoutType" xml:space="preserve">
3717+
<value>Layout type</value>
3718+
</data>
3719+
</root>

src/Files.App/ViewModels/Settings/LayoutViewModel.cs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class LayoutViewModel : ObservableObject
1414
public LayoutViewModel()
1515
{
1616
SelectedDefaultLayoutModeIndex = (int)DefaultLayoutMode;
17+
1718
SelectedDefaultSortingIndex = UserSettingsService.LayoutSettingsService.DefaultSortOption == SortOption.FileTag ? FileTagSortingIndex : (int)UserSettingsService.LayoutSettingsService.DefaultSortOption;
1819
SelectedDefaultGroupingIndex = UserSettingsService.LayoutSettingsService.DefaultGroupOption == GroupOption.FileTag ? FileTagGroupingIndex : (int)UserSettingsService.LayoutSettingsService.DefaultGroupOption;
1920
SelectedDefaultGroupByDateUnitIndex = (int)UserSettingsService.LayoutSettingsService.DefaultGroupByDateUnit;
@@ -37,6 +38,36 @@ public bool SyncFolderPreferencesAcrossDirectories
3738
}
3839
}
3940

41+
public FolderLayoutModes DefaultLayoutMode
42+
{
43+
get => UserSettingsService.LayoutSettingsService.DefaultLayoutMode;
44+
set
45+
{
46+
if (value != UserSettingsService.LayoutSettingsService.DefaultLayoutMode)
47+
{
48+
UserSettingsService.LayoutSettingsService.DefaultLayoutMode = value;
49+
50+
OnPropertyChanged();
51+
}
52+
}
53+
}
54+
55+
private int selectedDefaultLayoutModeIndex;
56+
public int SelectedDefaultLayoutModeIndex
57+
{
58+
get => selectedDefaultLayoutModeIndex;
59+
set
60+
{
61+
if (SetProperty(ref selectedDefaultLayoutModeIndex, value))
62+
{
63+
OnPropertyChanged(nameof(SelectedDefaultLayoutModeIndex));
64+
DefaultLayoutMode = (FolderLayoutModes)value;
65+
}
66+
}
67+
}
68+
69+
70+
4071
public bool SortInDescendingOrder
4172
{
4273
get => UserSettingsService.LayoutSettingsService.DefaultDirectorySortDirection == SortDirection.Descending;
@@ -146,19 +177,7 @@ public int SelectedDefaultGroupingIndex
146177
}
147178
}
148179
}
149-
private int selectedDefaultLayoutModeIndex;
150-
public int SelectedDefaultLayoutModeIndex
151-
{
152-
get => selectedDefaultLayoutModeIndex;
153-
set
154-
{
155-
if (SetProperty(ref selectedDefaultLayoutModeIndex, value))
156-
{
157-
OnPropertyChanged(nameof(SelectedDefaultLayoutModeIndex));
158-
DefaultLayoutMode = (FolderLayoutModes)value;
159-
}
160-
}
161-
}
180+
162181
public bool ShowFileTagColumn
163182
{
164183
get => UserSettingsService.LayoutSettingsService.ShowFileTagColumn;
@@ -229,21 +248,6 @@ public bool ShowDateColumn
229248
}
230249
}
231250

232-
public FolderLayoutModes DefaultLayoutMode
233-
{
234-
get => UserSettingsService.LayoutSettingsService.DefaultLayoutMode;
235-
set
236-
{
237-
if (value != UserSettingsService.LayoutSettingsService.DefaultLayoutMode)
238-
{
239-
UserSettingsService.LayoutSettingsService.DefaultLayoutMode = value;
240-
241-
OnPropertyChanged();
242-
}
243-
}
244-
}
245-
246-
247251
public void ResetLayoutPreferences()
248252
{
249253
// Is this proper practice?

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@
5151
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
5252
</local:SettingsBlockControl>
5353

54+
<!-- Layout Type -->
55+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=LayoutType}" HorizontalAlignment="Stretch">
56+
<local:SettingsBlockControl.Icon>
57+
<FontIcon Glyph="&#xE8BA;" />
58+
</local:SettingsBlockControl.Icon>
59+
60+
<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=LayoutType}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultLayoutModeIndex, Mode=TwoWay}">
61+
<ComboBoxItem Content="{helpers:ResourceString Name=Details}" />
62+
<ComboBoxItem Content="{helpers:ResourceString Name=List}" />
63+
<ComboBoxItem Content="{helpers:ResourceString Name=Tiles}" />
64+
<ComboBoxItem Content="{helpers:ResourceString Name=Columns}" />
65+
<ComboBoxItem Content="{helpers:ResourceString Name=Grid}" />
66+
<ComboBoxItem Content="{helpers:ResourceString Name=Adaptive}" />
67+
</ComboBox>
68+
</local:SettingsBlockControl>
69+
70+
5471
<!-- Details layout columns -->
5572
<local:SettingsBlockControl Title="{helpers:ResourceString Name=DetailsLayoutColumns}" HorizontalAlignment="Stretch">
5673
<local:SettingsBlockControl.Icon>
@@ -165,21 +182,7 @@
165182
</local:SettingsBlockControl.ExpandableContent>
166183
</local:SettingsBlockControl>
167184

168-
<!-- Layout mode -->
169-
<local:SettingsBlockControl Title="{helpers:ResourceString Name=Layout}" HorizontalAlignment="Stretch">
170-
<local:SettingsBlockControl.Icon>
171-
<FontIcon Glyph="&#xE8BA;" />
172-
</local:SettingsBlockControl.Icon>
173185

174-
<ComboBox AutomationProperties.Name="{helpers:ResourceString Name=Layout}" SelectedIndex="{x:Bind ViewModel.SelectedDefaultLayoutModeIndex, Mode=TwoWay}">
175-
<ComboBoxItem Content="{helpers:ResourceString Name=Details}" />
176-
<ComboBoxItem Content="{helpers:ResourceString Name=List}" />
177-
<ComboBoxItem Content="{helpers:ResourceString Name=Tiles}" />
178-
<ComboBoxItem Content="{helpers:ResourceString Name=Columns}" />
179-
<ComboBoxItem Content="{helpers:ResourceString Name=Grid}" />
180-
<ComboBoxItem Content="{helpers:ResourceString Name=Adaptive}" />
181-
</ComboBox>
182-
</local:SettingsBlockControl>
183186

184187
</StackPanel>
185188
</Grid>

src/Files.Core/Services/Settings/ILayoutSettingsService.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyC
1212
/// </summary>
1313
bool SyncFolderPreferencesAcrossDirectories { get; set; }
1414

15+
/// <summary>
16+
/// Gets or sets a value indicating the default layout mode.
17+
/// </summary>
18+
FolderLayoutModes DefaultLayoutMode { get; set; }
19+
20+
21+
1522
/// <summary>
1623
/// Gets or sets a value indicating whether or not the date column should be visible by default.
1724
/// </summary>
@@ -82,11 +89,6 @@ public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyC
8289
/// </summary>
8390
bool ShowSyncStatusColumn { get; set; }
8491

85-
/// <summary>
86-
/// Gets or sets a value indicating the default layout mode.
87-
/// </summary>
88-
FolderLayoutModes DefaultLayoutMode { get; set; }
89-
9092
/// <summary>
9193
/// Gets or sets a value indicating the width of the git status column
9294
/// </summary>

0 commit comments

Comments
 (0)