Skip to content

Commit 226eadd

Browse files
committed
Slider
1 parent 27676d4 commit 226eadd

36 files changed

+564
-692
lines changed

src/Files.App/Actions/Display/LayoutAction.cs

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,58 +57,22 @@ public override HotKey HotKey
5757
=> new(Keys.Number3, KeyModifiers.CtrlShift);
5858
}
5959

60-
internal class LayoutGridSmallAction : ToggleLayoutAction
60+
internal class LayoutGridAction : ToggleLayoutAction
6161
{
6262
protected override LayoutTypes LayoutType
63-
=> LayoutTypes.GridSmall;
63+
=> LayoutTypes.Grid;
6464

6565
public override string Label
66-
=> "SmallIcons".GetLocalizedResource();
66+
=> "Grid".GetLocalizedResource();
6767

6868
public override string Description
69-
=> "LayoutGridSmallDescription".GetLocalizedResource();
70-
71-
public override RichGlyph Glyph
72-
=> new(opacityStyle: "ColorIconGridSmallLayout");
73-
74-
public override HotKey HotKey
75-
=> new(Keys.Number4, KeyModifiers.CtrlShift);
76-
}
77-
78-
internal class LayoutGridMediumAction : ToggleLayoutAction
79-
{
80-
protected override LayoutTypes LayoutType
81-
=> LayoutTypes.GridMedium;
82-
83-
public override string Label
84-
=> "MediumIcons".GetLocalizedResource();
85-
86-
public override string Description
87-
=> "LayoutGridMediumDescription".GetLocalizedResource();
88-
89-
public override RichGlyph Glyph
90-
=> new(opacityStyle: "ColorIconGridMediumLayout");
91-
92-
public override HotKey HotKey
93-
=> new(Keys.Number5, KeyModifiers.CtrlShift);
94-
}
95-
96-
internal class LayoutGridLargeAction : ToggleLayoutAction
97-
{
98-
protected override LayoutTypes LayoutType
99-
=> LayoutTypes.GridLarge;
100-
101-
public override string Label
102-
=> "LargeIcons".GetLocalizedResource();
103-
104-
public override string Description
105-
=> "LayoutGridLargeDescription".GetLocalizedResource();
69+
=> "LayoutGridescription".GetLocalizedResource();
10670

10771
public override RichGlyph Glyph
10872
=> new(opacityStyle: "ColorIconGridLargeLayout");
10973

11074
public override HotKey HotKey
111-
=> new(Keys.Number6, KeyModifiers.CtrlShift);
75+
=> new(Keys.Number4, KeyModifiers.CtrlShift);
11276
}
11377

11478
internal class LayoutColumnsAction : ToggleLayoutAction
@@ -126,7 +90,7 @@ public override RichGlyph Glyph
12690
=> new(opacityStyle: "ColorIconColumnsLayout");
12791

12892
public override HotKey HotKey
129-
=> new(Keys.Number7, KeyModifiers.CtrlShift);
93+
=> new(Keys.Number5, KeyModifiers.CtrlShift);
13094
}
13195

13296
internal class LayoutAdaptiveAction : ToggleLayoutAction
@@ -206,6 +170,7 @@ protected virtual void OnContextChanged(string propertyName)
206170

207171
internal class LayoutDecreaseSizeAction : IAction
208172
{
173+
private static readonly IUserSettingsService UserSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
209174
private readonly IDisplayPageContext context;
210175

211176
public string Label
@@ -227,14 +192,35 @@ public LayoutDecreaseSizeAction()
227192

228193
public Task ExecuteAsync()
229194
{
230-
context.DecreaseLayoutSize();
195+
switch (context.LayoutType)
196+
{
197+
case LayoutTypes.Details:
198+
if (UserSettingsService.LayoutSettingsService.ItemSizeDetailsView > Constants.IconHeights.DetailsView.Minimum)
199+
UserSettingsService.LayoutSettingsService.ItemSizeDetailsView -= Constants.IconHeights.DetailsView.Increment;
200+
break;
201+
case LayoutTypes.List:
202+
if (UserSettingsService.LayoutSettingsService.ItemSizeListView > Constants.IconHeights.ListView.Minimum)
203+
UserSettingsService.LayoutSettingsService.ItemSizeListView -= Constants.IconHeights.ListView.Increment;
204+
break;
205+
case LayoutTypes.Tiles:
206+
break;
207+
case LayoutTypes.Grid:
208+
if (UserSettingsService.LayoutSettingsService.ItemSizeGridView > Constants.IconHeights.GridView.Minimum)
209+
UserSettingsService.LayoutSettingsService.ItemSizeGridView -= Constants.IconHeights.GridView.Increment;
210+
break;
211+
case LayoutTypes.Columns:
212+
if (UserSettingsService.LayoutSettingsService.ItemSizeColumnsView > Constants.IconHeights.ColumnsView.Minimum)
213+
UserSettingsService.LayoutSettingsService.ItemSizeColumnsView -= Constants.IconHeights.ColumnsView.Increment;
214+
break;
215+
}
231216

232217
return Task.CompletedTask;
233218
}
234219
}
235220

236221
internal class LayoutIncreaseSizeAction : IAction
237222
{
223+
private static readonly IUserSettingsService UserSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
238224
private readonly IDisplayPageContext context;
239225

240226
public string Label
@@ -256,7 +242,27 @@ public LayoutIncreaseSizeAction()
256242

257243
public Task ExecuteAsync()
258244
{
259-
context.IncreaseLayoutSize();
245+
switch (context.LayoutType)
246+
{
247+
case LayoutTypes.Details:
248+
if (UserSettingsService.LayoutSettingsService.ItemSizeDetailsView < Constants.IconHeights.DetailsView.Maximum)
249+
UserSettingsService.LayoutSettingsService.ItemSizeDetailsView += Constants.IconHeights.DetailsView.Increment;
250+
break;
251+
case LayoutTypes.List:
252+
if (UserSettingsService.LayoutSettingsService.ItemSizeListView < Constants.IconHeights.ListView.Maximum)
253+
UserSettingsService.LayoutSettingsService.ItemSizeListView += Constants.IconHeights.ListView.Increment;
254+
break;
255+
case LayoutTypes.Tiles:
256+
break;
257+
case LayoutTypes.Grid:
258+
if (UserSettingsService.LayoutSettingsService.ItemSizeGridView < Constants.IconHeights.GridView.Maximum)
259+
UserSettingsService.LayoutSettingsService.ItemSizeGridView += Constants.IconHeights.GridView.Increment;
260+
break;
261+
case LayoutTypes.Columns:
262+
if (UserSettingsService.LayoutSettingsService.ItemSizeColumnsView < Constants.IconHeights.ColumnsView.Maximum)
263+
UserSettingsService.LayoutSettingsService.ItemSizeColumnsView += Constants.IconHeights.ColumnsView.Increment;
264+
break;
265+
}
260266

261267
return Task.CompletedTask;
262268
}

src/Files.App/App.xaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
<Application.Resources>
88
<ResourceDictionary>
99

10-
<!-- Default list view item height -->
11-
<x:Double x:Key="ListItemHeight">36</x:Double>
12-
13-
<!-- Default list view item margin -->
14-
<x:Double x:Key="ListItemMargin">0</x:Double>
15-
1610
<!-- Fix caption buttons background -->
1711
<SolidColorBrush x:Key="WindowCaptionBackground" Color="Transparent" />
1812
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Transparent" />

src/Files.App/Constants.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,41 @@ public static class TilesView
143143

144144
public static class ListView
145145
{
146+
public const int Increment = 4;
147+
148+
public const int Minimum = 24;
149+
150+
public const int Small = 28;
151+
146152
public const int Regular = 32;
153+
154+
public const int Maximum = 36;
147155
}
148156

149157
public static class DetailsView
150158
{
151-
public const int Regular = 32;
159+
public const int Increment = 4;
160+
161+
public const int Minimum = 28;
162+
163+
public const int Small = 32;
164+
165+
public const int Regular = 36;
166+
167+
public const int Maximum = 40;
152168
}
153169

154170
public static class ColumnsView
155171
{
156-
public const int Regular = 32;
172+
public const int Increment = 4;
173+
174+
public const int Minimum = 28;
175+
176+
public const int Small = 32;
177+
178+
public const int Regular = 36;
179+
180+
public const int Maximum = 40;
157181
}
158182
}
159183

src/Files.App/Data/Commands/CommandCodes.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ public enum CommandCodes
113113
LayoutDetails,
114114
LayoutList,
115115
LayoutTiles,
116-
LayoutGridSmall,
117-
LayoutGridMedium,
118-
LayoutGridLarge,
116+
LayoutGrid,
119117
LayoutColumns,
120118
LayoutAdaptive,
121119

src/Files.App/Data/Commands/Manager/CommandManager.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ public IRichCommand this[HotKey hotKey]
113113
public IRichCommand LayoutDetails => commands[CommandCodes.LayoutDetails];
114114
public IRichCommand LayoutList => commands[CommandCodes.LayoutList];
115115
public IRichCommand LayoutTiles => commands[CommandCodes.LayoutTiles];
116-
public IRichCommand LayoutGridSmall => commands[CommandCodes.LayoutGridSmall];
117-
public IRichCommand LayoutGridMedium => commands[CommandCodes.LayoutGridMedium];
118-
public IRichCommand LayoutGridLarge => commands[CommandCodes.LayoutGridLarge];
116+
public IRichCommand LayoutGrid => commands[CommandCodes.LayoutGrid];
119117
public IRichCommand LayoutColumns => commands[CommandCodes.LayoutColumns];
120118
public IRichCommand LayoutAdaptive => commands[CommandCodes.LayoutAdaptive];
121119
public IRichCommand SortByName => commands[CommandCodes.SortByName];
@@ -284,9 +282,7 @@ public CommandManager()
284282
[CommandCodes.LayoutDetails] = new LayoutDetailsAction(),
285283
[CommandCodes.LayoutList] = new LayoutListAction(),
286284
[CommandCodes.LayoutTiles] = new LayoutTilesAction(),
287-
[CommandCodes.LayoutGridSmall] = new LayoutGridSmallAction(),
288-
[CommandCodes.LayoutGridMedium] = new LayoutGridMediumAction(),
289-
[CommandCodes.LayoutGridLarge] = new LayoutGridLargeAction(),
285+
[CommandCodes.LayoutGrid] = new LayoutGridAction(),
290286
[CommandCodes.LayoutColumns] = new LayoutColumnsAction(),
291287
[CommandCodes.LayoutAdaptive] = new LayoutAdaptiveAction(),
292288
[CommandCodes.SortByName] = new SortByNameAction(),

src/Files.App/Data/Commands/Manager/ICommandManager.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
9999
IRichCommand LayoutDetails { get; }
100100
IRichCommand LayoutList { get; }
101101
IRichCommand LayoutTiles { get; }
102-
IRichCommand LayoutGridSmall { get; }
103-
IRichCommand LayoutGridMedium { get; }
104-
IRichCommand LayoutGridLarge { get; }
102+
IRichCommand LayoutGrid { get; }
105103
IRichCommand LayoutColumns { get; }
106104
IRichCommand LayoutAdaptive { get; }
107105

src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,8 @@ public LayoutTypes LayoutType
3333
case LayoutTypes.Tiles:
3434
viewModel.ToggleLayoutModeTiles(true);
3535
break;
36-
case LayoutTypes.GridSmall:
37-
viewModel.ToggleLayoutModeGridView(IconHeights.GridView.Small, true);
38-
break;
39-
case LayoutTypes.GridMedium:
40-
viewModel.ToggleLayoutModeGridView(IconHeights.GridView.Medium, true);
41-
break;
42-
case LayoutTypes.GridLarge:
43-
viewModel.ToggleLayoutModeGridView(IconHeights.GridView.Large, true);
36+
case LayoutTypes.Grid:
37+
viewModel.ToggleLayoutModeGridView(true);
4438
break;
4539
case LayoutTypes.Columns:
4640
viewModel.ToggleLayoutModeColumnView(true);
@@ -138,18 +132,6 @@ public DisplayPageContext()
138132
settings.PropertyChanged += Settings_PropertyChanged;
139133
}
140134

141-
public void DecreaseLayoutSize()
142-
{
143-
if (FolderSettings is LayoutPreferencesManager viewModel)
144-
viewModel.DecreaseLayoutSize();
145-
}
146-
147-
public void IncreaseLayoutSize()
148-
{
149-
if (FolderSettings is LayoutPreferencesManager viewModel)
150-
viewModel.IncreaseLayoutSize();
151-
}
152-
153135
private void Context_Changing(object? sender, EventArgs e)
154136
{
155137
var viewModel = FolderSettings;
@@ -174,7 +156,6 @@ private void FolderSettings_PropertyChanged(object? sender, PropertyChangedEvent
174156
switch (e.PropertyName)
175157
{
176158
case nameof(LayoutPreferencesManager.LayoutMode):
177-
case nameof(LayoutPreferencesManager.IconHeight):
178159
case nameof(LayoutPreferencesManager.IsAdaptiveLayoutEnabled):
179160
SetProperty(ref _LayoutType, GetLayoutType(), nameof(LayoutType));
180161
break;
@@ -251,12 +232,7 @@ private LayoutTypes GetLayoutType()
251232
FolderLayoutModes.DetailsView => LayoutTypes.Details,
252233
FolderLayoutModes.ListView => LayoutTypes.List,
253234
FolderLayoutModes.TilesView => LayoutTypes.Tiles,
254-
FolderLayoutModes.GridView => viewModel.IconHeight switch
255-
{
256-
< IconHeights.GridView.Medium => LayoutTypes.GridSmall,
257-
< IconHeights.GridView.Large => LayoutTypes.GridMedium,
258-
_ => LayoutTypes.GridLarge,
259-
},
235+
FolderLayoutModes.GridView => LayoutTypes.Grid,
260236
FolderLayoutModes.ColumnView => LayoutTypes.Columns,
261237
_ => throw new InvalidEnumArgumentException(),
262238
};

src/Files.App/Data/Contexts/DisplayPage/IDisplayPageContext.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@ public interface IDisplayPageContext : INotifyPropertyChanging, INotifyPropertyC
1717

1818
bool SortDirectoriesAlongsideFiles { get; set; }
1919
bool SortFilesFirst { get; set; }
20-
21-
void DecreaseLayoutSize();
22-
void IncreaseLayoutSize();
2320
}
2421
}

src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ public enum LayoutTypes : ushort
99
Details,
1010
List,
1111
Tiles,
12-
GridSmall,
13-
GridMedium,
14-
GridLarge,
12+
Grid,
1513
Columns,
1614
Adaptive,
1715
}

src/Files.App/Data/EventArguments/LayoutModeEventArgs.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ public class LayoutModeEventArgs
77
{
88
public readonly FolderLayoutModes LayoutMode;
99

10-
public readonly int GridViewSize;
11-
12-
internal LayoutModeEventArgs(FolderLayoutModes layoutMode, int gridViewSize)
10+
internal LayoutModeEventArgs(FolderLayoutModes layoutMode)
1311
{
1412
LayoutMode = layoutMode;
15-
GridViewSize = gridViewSize;
1613
}
1714
}
1815
}

src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
120120
{
121121
IsToggle = true
122122
}.Build(),
123-
new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutGridSmall)
124-
{
125-
IsToggle = true
126-
}.Build(),
127-
new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutGridMedium)
128-
{
129-
IsToggle = true
130-
}.Build(),
131-
new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutGridLarge)
123+
new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutGrid)
132124
{
133125
IsToggle = true
134126
}.Build(),

src/Files.App/Data/Models/ItemViewModel.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,6 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
613613
case nameof(UserSettingsService.FoldersSettingsService.SyncFolderPreferencesAcrossDirectories):
614614
case nameof(UserSettingsService.FoldersSettingsService.DefaultGroupByDateUnit):
615615
case nameof(UserSettingsService.FoldersSettingsService.DefaultLayoutMode):
616-
case nameof(UserSettingsService.LayoutSettingsService.DefaultIconHeightDetailsView):
617-
case nameof(UserSettingsService.LayoutSettingsService.DefaultIconHeightListView):
618-
case nameof(UserSettingsService.LayoutSettingsService.DefaulIconHeightTilesView):
619-
case nameof(UserSettingsService.LayoutSettingsService.DefaulIconHeightGridView):
620-
case nameof(UserSettingsService.LayoutSettingsService.DefaultIconHeightColumnsView):
621616
await dispatcherQueue.EnqueueOrInvokeAsync(() =>
622617
{
623618
folderSettings.OnDefaultPreferencesChanged(WorkingDirectory, e.SettingName);

src/Files.App/Helpers/Layout/AdaptiveLayoutHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void ApplyAdaptativeLayout(LayoutPreferencesManager folderSettings
3030
folderSettings.ToggleLayoutModeDetailsView(false);
3131
break;
3232
case Layouts.Grid:
33-
folderSettings.ToggleLayoutModeGridView(Constants.IconHeights.GridView.Medium, false);
33+
folderSettings.ToggleLayoutModeGridView(false);
3434
break;
3535
}
3636
}

0 commit comments

Comments
 (0)