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: Introduced AppThemeModeService #14068

Closed
Closed
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ private IHost ConfigureHost()
.AddSingleton<IRemovableDrivesService, RemovableDrivesService>()
.AddSingleton<INetworkDrivesService, NetworkDrivesService>()
.AddSingleton<IStartMenuService, StartMenuService>()
.AddSingleton<IAppThemeModeService, AppThemeModeService>()
.AddSingleton<MainPageViewModel>()
.AddSingleton<InfoPaneViewModel>()
.AddSingleton<SidebarViewModel>()
.AddSingleton<SettingsViewModel>()
.AddSingleton<DrivesViewModel>()
.AddSingleton<NetworkDrivesViewModel>()
.AddSingleton<StatusCenterViewModel>()
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/AddBranchDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
Title="{helpers:ResourceString Name=CreateNewBranch}"
Closing="ContentDialog_Closing"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
DefaultButton="Primary"
IsPrimaryButtonEnabled="{x:Bind ViewModel.IsBranchValid, Mode=OneWay}"
PrimaryButtonStyle="{StaticResource AccentButtonStyle}"
PrimaryButtonText="{helpers:ResourceString Name=Create}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonText="{helpers:ResourceString Name=Cancel}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Dialogs/AddBranchDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Files.App.Dialogs
{
public sealed partial class AddBranchDialog : ContentDialog, IDialog<AddBranchDialogViewModel>
{
public AddBranchDialogViewModel ViewModel
{
get => (AddBranchDialogViewModel)DataContext;
set => DataContext = value;
}
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public AddBranchDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public AddBranchDialog()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/AddItemDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
Grid.RowSpan="4"
BorderThickness="0"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
Loaded="AddItemDialog_Loaded"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonText="{helpers:ResourceString Name=Cancel}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Dialogs/AddItemDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace Files.App.Dialogs
{
public sealed partial class AddItemDialog : ContentDialog, IDialog<AddItemDialogViewModel>
{
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();
private readonly IAddItemService addItemService = Ioc.Default.GetRequiredService<IAddItemService>();

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

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public AddItemDialog()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/CreateArchiveDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
IsPrimaryButtonEnabled="{x:Bind ViewModel.IsNameValid, Mode=OneWay}"
Loaded="ContentDialog_Loaded"
PrimaryButtonText="{helpers:ResourceString Name=Create}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

Expand Down
5 changes: 5 additions & 0 deletions src/Files.App/Dialogs/CreateArchiveDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace Files.App.Dialogs
{
public sealed partial class CreateArchiveDialog : ContentDialog
{
private IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

private bool canCreate = false;
public bool CanCreate => canCreate;

Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/CreateShortcutDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{helpers:ResourceString Name=NewShortcutDialogTitle}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
DefaultButton="Primary"
IsPrimaryButtonEnabled="{x:Bind ViewModel.IsLocationValid, Mode=OneWay}"
PrimaryButtonCommand="{x:Bind ViewModel.PrimaryButtonCommand}"
PrimaryButtonText="{helpers:ResourceString Name=Create}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonText="{helpers:ResourceString Name=Cancel}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Dialogs/CreateShortcutDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@

using Files.App.ViewModels.Dialogs;
using Files.Core.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;

namespace Files.App.Dialogs
{
public sealed partial class CreateShortcutDialog : ContentDialog, IDialog<CreateShortcutDialogViewModel>
{
public CreateShortcutDialogViewModel ViewModel
{
get => (CreateShortcutDialogViewModel)DataContext;
set => DataContext = value;
}
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public CreateShortcutDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public CreateShortcutDialog()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/CredentialDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{helpers:ResourceString Name=AskCredentialDialog/Title}"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
PrimaryButtonStyle="{StaticResource AccentButtonStyle}"
PrimaryButtonText="{helpers:ResourceString Name=OK}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonText="{helpers:ResourceString Name=Cancel}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Dialogs/CredentialDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System.Text;

namespace Files.App.Dialogs
{
public sealed partial class CredentialDialog : ContentDialog, IDialog<CredentialDialogViewModel>
{
public CredentialDialogViewModel ViewModel
{
get => (CredentialDialogViewModel)DataContext;
set => DataContext = value;
}
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public CredentialDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public CredentialDialog()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/DecompressArchiveDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{helpers:ResourceString Name=ExtractArchive}"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
DefaultButton="Primary"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
PrimaryButtonText="{helpers:ResourceString Name=Extract}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonText="{helpers:ResourceString Name=Cancel}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">
Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Dialogs/DecompressArchiveDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System.Text;

namespace Files.App.Dialogs
{
public sealed partial class DecompressArchiveDialog : ContentDialog
{
public DecompressArchiveDialogViewModel ViewModel
{
get => (DecompressArchiveDialogViewModel)DataContext;
set => DataContext = value;
}
private IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public DecompressArchiveDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public DecompressArchiveDialog()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/DynamicDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
CloseButtonClick="ContentDialog_CloseButtonClick"
CloseButtonText="{x:Bind ViewModel.CloseButtonText, Mode=OneWay}"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
DefaultButton="Primary"
IsPrimaryButtonEnabled="{x:Bind ViewModel.IsPrimaryButtonEnabled, Mode=OneWay}"
IsSecondaryButtonEnabled="{x:Bind ViewModel.IsSecondaryButtonEnabled, Mode=OneWay}"
KeyDown="ContentDialog_KeyDown"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
PrimaryButtonText="{x:Bind ViewModel.PrimaryButtonText, Mode=OneWay}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick"
SecondaryButtonText="{x:Bind ViewModel.SecondaryButtonText, Mode=OneWay}"
Style="{StaticResource DefaultContentDialogStyle}"
Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Dialogs/DynamicDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Files.App.Dialogs
{
public sealed partial class DynamicDialog : ContentDialog, IDisposable
{
public DynamicDialogViewModel ViewModel
{
get => (DynamicDialogViewModel)DataContext;
private set => DataContext = value;
}
private IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public DynamicDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public DynamicDialogResult DynamicResult
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/ElevateConfirmDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
CloseButtonText="{helpers:ResourceString Name=No}"
Content="{helpers:ResourceString Name=ElevateConfirmDialog/Content}"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
DefaultButton="None"
PrimaryButtonText="{helpers:ResourceString Name=Yes}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

Expand Down
15 changes: 7 additions & 8 deletions src/Files.App/Dialogs/ElevateConfirmDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Core.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading.Tasks;

namespace Files.App.Dialogs
{
public sealed partial class ElevateConfirmDialog : ContentDialog, IDialog<ElevateConfirmDialogViewModel>
{
public ElevateConfirmDialogViewModel ViewModel
{
get => (ElevateConfirmDialogViewModel)DataContext;
set => DataContext = value;
}
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public ElevateConfirmDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public ElevateConfirmDialog()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Dialogs/FileTooLargeDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{helpers:ResourceString Name=CopyFailureFileToLarge}"
CornerRadius="{StaticResource OverlayCornerRadius}"
DataContext="{x:Bind ViewModel, Mode=OneWay}"
DefaultButton="Primary"
PrimaryButtonText="{helpers:ResourceString Name=OK}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

Expand Down
12 changes: 7 additions & 5 deletions src/Files.App/Dialogs/FileTooLargeDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace Files.App.Dialogs
{
public sealed partial class FileTooLargeDialog : ContentDialog, IDialog<FileTooLargeDialogViewModel>
{
public FileTooLargeDialogViewModel ViewModel
{
get => (FileTooLargeDialogViewModel)DataContext;
set => DataContext = value;
}
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public FileTooLargeDialogViewModel ViewModel { get; set; }

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public FileTooLargeDialog()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/FilesystemOperationDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
IsPrimaryButtonEnabled="{x:Bind ViewModel.PrimaryButtonEnabled, Mode=OneWay}"
Opened="FilesystemOperationDialog_Opened"
PrimaryButtonText="{x:Bind ViewModel.PrimaryButtonText, Mode=OneWay}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
SecondaryButtonCommand="{x:Bind ViewModel.SecondaryButtonClickCommand, Mode=OneWay}"
SecondaryButtonText="{x:Bind ViewModel.SecondaryButtonText, Mode=OneWay}"
Style="{StaticResource DefaultContentDialogStyle}"
Expand Down
8 changes: 5 additions & 3 deletions src/Files.App/Dialogs/FilesystemOperationDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@
using CommunityToolkit.WinUI.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;

namespace Files.App.Dialogs
{
public sealed partial class FilesystemOperationDialog : ContentDialog, IDialog<FileSystemDialogViewModel>
{
public IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();

public FileSystemDialogViewModel ViewModel
{
get => (FileSystemDialogViewModel)DataContext;
set
{
if (value is not null)
{
value.PrimaryButtonEnabled = true;
}

DataContext = value;
}
}

private ElementTheme ThemeMode
=> (ElementTheme)AppThemeModeService.ThemeMode;

public FilesystemOperationDialog()
{
InitializeComponent();
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/GitHubLoginDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CornerRadius="{StaticResource OverlayCornerRadius}"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
PrimaryButtonText="{helpers:ResourceString Name=OK}"
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}"
RequestedTheme="{x:Bind ThemeMode, Mode=OneWay}"
Style="{StaticResource DefaultContentDialogStyle}"
mc:Ignorable="d">

Expand Down
Loading
Loading