-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,767 additions
and
1,227 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/Files.App.Controls/ThemedIcon/Data/ThemedIconColorType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Controls | ||
{ | ||
/// <summary> | ||
/// Defines the IconColorTypes for <see cref="ThemedIcon"/> which sets the visual state | ||
/// to use the correct brush values which match system signal colours. | ||
/// </summary> | ||
public enum ThemedIconColorType | ||
{ | ||
None, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Normal. Default Value. | ||
/// </summary> | ||
Normal, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Critical. | ||
/// </summary> | ||
Critical, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Caution. | ||
/// </summary> | ||
Caution, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Success. | ||
/// </summary> | ||
Success, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Neutral. | ||
/// </summary> | ||
Neutral, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Accent. | ||
/// </summary> | ||
Accent, | ||
|
||
/// <summary> | ||
/// Icon color type of <see cref="ThemedIcon"/> is Custom. Used in combination | ||
/// with the IconColor and Foreground brushes. | ||
/// </summary> | ||
Custom | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
src/Files.App.Controls/ThemedIcon/Data/ThemedIconToggleBehaviors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Controls | ||
{ | ||
/// <summary> | ||
/// Defines IconTypes for <see cref="ThemedIcon"/>. | ||
/// </summary> | ||
public enum ToggleBehaviors | ||
{ | ||
/// <summary> | ||
/// Toggle Behavior type of <see cref="ThemedIcon"/> is Auto. | ||
/// </summary> | ||
Auto, | ||
|
||
/// <summary> | ||
/// Toggle Behavior type of <see cref="ThemedIcon"/> is On. | ||
/// </summary> | ||
On, | ||
|
||
/// <summary> | ||
/// Toggle Behavior type of <see cref="ThemedIcon"/> is Off. | ||
/// </summary> | ||
Off, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Controls | ||
{ | ||
/// <summary> | ||
/// Defines IconTypes for <see cref="ThemedIcon"/>. | ||
/// </summary> | ||
public enum ThemedIconTypes | ||
{ | ||
/// <summary> | ||
/// Icon type of <see cref="ThemedIcon"/> is Outline. | ||
/// </summary> | ||
Outline, | ||
|
||
/// <summary> | ||
/// Icon type of <see cref="ThemedIcon"/> is Layered. | ||
/// </summary> | ||
Layered, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) 2024 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using CommunityToolkit.WinUI.UI; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
|
||
namespace Files.App.Controls | ||
{ | ||
public partial class ThemedIcon | ||
{ | ||
private bool _isOwnerToggled; | ||
private bool _isOwnerEnabled; | ||
|
||
private Control? ownerControl = null; | ||
private ToggleButton? ownerToggleButton = null; | ||
|
||
private void FindOwnerControlStates() | ||
{ | ||
if (this.FindAscendant<ToggleButton>() is ToggleButton toggleButton) | ||
{ | ||
ownerToggleButton = toggleButton; | ||
|
||
// IsChecked/IsToggled change aware | ||
ownerToggleButton.Checked += OwnerControl_IsCheckedChanged; | ||
ownerToggleButton.Unchecked += OwnerControl_IsCheckedChanged; | ||
_isOwnerToggled = ownerToggleButton.IsChecked is true; | ||
} | ||
|
||
if (this.FindAscendant<Control>() is Control control) | ||
{ | ||
ownerControl = control; | ||
|
||
// IsEnabled change aware | ||
ownerControl.IsEnabledChanged += OwnerControl_IsEnabledChanged; | ||
_isOwnerEnabled = ownerControl.IsEnabled; | ||
|
||
UpdateVisualStates(); | ||
} | ||
} | ||
|
||
private void OwnerControl_IsCheckedChanged(object sender, RoutedEventArgs e) | ||
{ | ||
if (ownerToggleButton is null) | ||
return; | ||
|
||
_isOwnerToggled = ownerToggleButton.IsChecked is true; | ||
UpdateVisualStates(); | ||
|
||
} | ||
|
||
private void OwnerControl_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (ownerControl is null) | ||
return; | ||
|
||
_isOwnerEnabled = ownerControl.IsEnabled; | ||
UpdateVisualStates(); | ||
} | ||
} | ||
} |
Oops, something went wrong.