Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality: Added empty view models of Widgets #14922

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Files.App/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@
global using global::Files.App.Services;
global using global::Files.App.UserControls;
global using global::Files.App.UserControls.TabBar;
global using global::Files.App.UserControls.ViewModels.Widgets;
global using global::Files.App.UserControls.Widgets;
global using global::Files.App.ViewModels;
global using global::Files.App.ViewModels.UserControls;
global using global::Files.App.ViewModels.UserControls.Widgets;
global using global::Files.App.Views;
global using global::Files.App.Views.Layouts;
global using global::Files.App.Views.Shells;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/UserControls/Widgets/DrivesWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
xmlns:helpers="using:Files.App.Helpers"
xmlns:local="using:Files.App.UserControls.Widgets"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
mc:Ignorable="d">

<Grid>
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Files.App.UserControls.Widgets
/// </summary>
public sealed partial class DrivesWidget : BaseWidgetViewModel, IWidgetViewModel, INotifyPropertyChanged
{
private DrivesWidgetViewModel ViewModel { get; set; }

public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>();
private DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/UserControls/Widgets/FileTagsWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
xmlns:helpers="using:Files.App.Helpers"
xmlns:local="using:Files.App.UserControls.Widgets"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
mc:Ignorable="d">

<UserControl.Resources>
Expand Down
8 changes: 2 additions & 6 deletions src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ namespace Files.App.UserControls.Widgets
/// </summary>
public sealed partial class FileTagsWidget : BaseWidgetViewModel, IWidgetViewModel
{
public FileTagsWidgetViewModel ViewModel { get; set; }

private readonly IUserSettingsService userSettingsService;
private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>();

public FileTagsWidgetViewModel ViewModel
{
get => (FileTagsWidgetViewModel)DataContext;
set => DataContext = value;
}

public IShellPage AppInstance;

public Func<string, Task>? OpenAction { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:dataitems="using:Files.App.Data.Items"
xmlns:local="using:Files.App.UserControls.Widgets"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
mc:Ignorable="d">

<Grid>
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/UserControls/Widgets/QuickAccessWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Files.App.UserControls.Widgets
/// </summary>
public sealed partial class QuickAccessWidget : BaseWidgetViewModel, IWidgetViewModel, INotifyPropertyChanged
{
private QuickAccessWidgetViewModel ViewModel { get; set; }

public IUserSettingsService userSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>();

Expand Down
1 change: 1 addition & 0 deletions src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:recent="using:Files.App.Utils.RecentItem"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
mc:Ignorable="d">

<StackPanel x:Name="RecentsListGrid" Orientation="Vertical">
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/UserControls/Widgets/RecentFilesWidget.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace Files.App.UserControls.Widgets
/// </summary>
public sealed partial class RecentFilesWidget : BaseWidgetViewModel, IWidgetViewModel, INotifyPropertyChanged
{
private RecentFilesWidgetViewModel ViewModel { get; set; }

private IHomePageContext HomePageContext { get; } = Ioc.Default.GetRequiredService<IHomePageContext>();

public delegate void RecentFilesOpenLocationInvokedEventHandler(object sender, PathNavigationEventArgs e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.ViewModels.UserControls.Widgets
{
/// <summary>
/// Represents view model of <see cref="DrivesWidget"/>.
/// </summary>
public class DrivesWidgetViewModel
{
public ObservableCollection<WidgetDriveCardItem> Items { get; } = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

using Files.Shared.Utils;

namespace Files.App.UserControls.ViewModels.Widgets
namespace Files.App.ViewModels.UserControls.Widgets
{
/// <summary>
/// Represents view model of <see cref="FileTagsWidget"/>.
/// </summary>
public sealed partial class FileTagsWidgetViewModel : ObservableObject, IAsyncInitialize
{
// Dependency injections
Expand All @@ -17,14 +20,13 @@ public sealed partial class FileTagsWidgetViewModel : ObservableObject, IAsyncIn

// Properties

public ObservableCollection<WidgetFileTagsContainerItem> Containers { get; }
public ObservableCollection<WidgetFileTagsContainerItem> Containers { get; } = [];

// Constructor

public FileTagsWidgetViewModel(Func<string, Task> openAction)
{
_openAction = openAction;
Containers = new();
}

// Methods
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.ViewModels.UserControls.Widgets
{
/// <summary>
/// Represents view model of <see cref="QuickAccessWidget"/>.
/// </summary>
public class QuickAccessWidgetViewModel
{
public ObservableCollection<WidgetFolderCardItem> Items { get; } = [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.ViewModels.UserControls.Widgets
{
/// <summary>
/// Represents view model of <see cref="RecentFilesWidget"/>.
/// </summary>
public class RecentFilesWidgetViewModel
{
public ObservableCollection<RecentItem> Items { get; } = [];
}
}
Loading