Skip to content

Commit e526fe4

Browse files
switched to combo box to allow users to choose the preferred group by date unit in the settings
1 parent 1a64471 commit e526fe4

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,8 +3010,8 @@
30103010
<data name="Year" xml:space="preserve">
30113011
<value>Year</value>
30123012
</data>
3013-
<data name="GroupByMonthInsteadOfYear" xml:space="preserve">
3014-
<value>Group by month instead of year</value>
3013+
<data name="PreferedGroupByDateUnit" xml:space="preserve">
3014+
<value>Prefered group by date unit</value>
30153015
</data>
30163016
<data name="GroupByDateCreatedDayDescription" xml:space="preserve">
30173017
<value>Group items by day of date created</value>

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public FoldersViewModel()
1616
SelectedDefaultLayoutModeIndex = (int)DefaultLayoutMode;
1717
SelectedDefaultSortingIndex = UserSettingsService.FoldersSettingsService.DefaultSortOption == SortOption.FileTag ? FileTagSortingIndex : (int)UserSettingsService.FoldersSettingsService.DefaultSortOption;
1818
SelectedDefaultGroupingIndex = UserSettingsService.FoldersSettingsService.DefaultGroupOption == GroupOption.FileTag ? FileTagGroupingIndex : (int)UserSettingsService.FoldersSettingsService.DefaultGroupOption;
19+
SelectedDefaultGroupByDateUnitIndex = (int)UserSettingsService.FoldersSettingsService.DefaultGroupByDateUnit;
1920
SelectedDefaultSortPriorityIndex = UserSettingsService.FoldersSettingsService.DefaultSortDirectoriesAlongsideFiles ? 2 : UserSettingsService.FoldersSettingsService.DefaultSortFilesFirst ? 1 : 0;
2021
SelectedDeleteConfirmationPolicyIndex = (int)DeleteConfirmationPolicy;
2122
}
@@ -276,15 +277,16 @@ public bool GroupInDescendingOrder
276277
public bool IsDefaultGrouped
277278
=> UserSettingsService.FoldersSettingsService.DefaultGroupOption != GroupOption.None;
278279

279-
public bool GroupByMonth
280+
private int defaultGroupByDateUnitIndex;
281+
public int SelectedDefaultGroupByDateUnitIndex
280282
{
281-
get => UserSettingsService.FoldersSettingsService.DefaultGroupByDateUnit == GroupByDateUnit.Month;
283+
get => defaultGroupByDateUnitIndex;
282284
set
283285
{
284-
if (value != (UserSettingsService.FoldersSettingsService.DefaultGroupByDateUnit == GroupByDateUnit.Month))
286+
if (SetProperty(ref defaultGroupByDateUnitIndex, value))
285287
{
286-
UserSettingsService.FoldersSettingsService.DefaultGroupByDateUnit = value ? GroupByDateUnit.Month : GroupByDateUnit.Year;
287-
OnPropertyChanged();
288+
OnPropertyChanged(nameof(SelectedDefaultGroupByDateUnitIndex));
289+
UserSettingsService.FoldersSettingsService.DefaultGroupByDateUnit = (GroupByDateUnit)value;
288290
}
289291
}
290292
}

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,16 @@
141141
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
142142
</local:SettingsBlockControl>
143143

144-
<!-- Group by Month -->
145-
<local:SettingsBlockControl Title="{helpers:ResourceString Name=GroupByMonthInsteadOfYear}" HorizontalAlignment="Stretch">
146-
<ToggleSwitch
147-
AutomationProperties.Name="{helpers:ResourceString Name=GroupByMonthInsteadOfYear}"
144+
<!-- Prefered Group by date unit -->
145+
<local:SettingsBlockControl Title="{helpers:ResourceString Name=PreferedGroupByDateUnit}" HorizontalAlignment="Stretch">
146+
<ComboBox
147+
AutomationProperties.Name="{helpers:ResourceString Name=PreferedGroupByDateUnit}"
148148
IsEnabled="{x:Bind ViewModel.IsGroupByDate, Mode=OneWay}"
149-
IsOn="{x:Bind ViewModel.GroupByMonth, Mode=TwoWay}"
150-
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
149+
SelectedIndex="{x:Bind ViewModel.SelectedDefaultGroupByDateUnitIndex, Mode=TwoWay}">
150+
<ComboBoxItem Content="{helpers:ResourceString Name=Year}" />
151+
<ComboBoxItem Content="{helpers:ResourceString Name=Month}" />
152+
<ComboBoxItem Content="{helpers:ResourceString Name=Day}" />
153+
</ComboBox>
151154
</local:SettingsBlockControl>
152155

153156
<!-- Sort Priority -->

0 commit comments

Comments
 (0)