Skip to content

Commit

Permalink
chore: revert "feat: Adding TextBox Icons Command and Visibility (#997)"
Browse files Browse the repository at this point in the history
This reverts commit 0b2a7a9.
  • Loading branch information
kazo0 committed Dec 1, 2023
1 parent ef221bd commit a23c7e3
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 458 deletions.
56 changes: 5 additions & 51 deletions doc/material-controls-extensions.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,19 @@
# Material Control Extensions

## Icons
## Icon

Below is a summary of the icon support for different controls:

| Control | Icon | LeadingIcon | TrailingIcon |
|-----------------|------|-------------|--------------|
| **Button** | ✔️ |||
| **Combobox** | ✔️ |||
| **PasswordBox** | ✔️ |||
| **TextBox** || ✔️ | ✔️ |


This feature allows for the addition of icons on the supported controls. Icons can be added in different positions, such as `Icon`, `LeadingIcon`, and `TrailingIcon`. You can choose from various [`IconElement`](https://docs.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.iconelement)s to represent your icons, including `<BitmapIcon />`, `<FontIcon />`, `<PathIcon />`, or `<SymbolIcon />`.

When using `LeadingIcon` and `TrailingIcon`, you have the additional flexibility of binding commands to them. By utilizing `LeadingCommand` and `TrailingCommand`, you can associate specific actions or functionality with these icons, allowing users to interact with them. This feature is particularly useful when you want to provide distinct actions associated with each icon.

Furthermore, `LeadingIcon` and `TrailingIcon` offer additional control over icon visibility. You can use the properties `IsLeadingIconVisible` and `IsTrailingIconVisible` to dynamically control the visibility of these icons based on specific conditions or user interactions.

> [!WARNING]
> `LeadingIcon` and `TrailingIcon` as well as `LeadingCommand`, `TrailingCommand`, `IsLeadingIconVisible`, `IsTrailingIconVisible` are specifically available for `TextBox` controls. Use `Icon` for other controls such as `PasswordBox`, `ComboBox`, `Button`.
This feature allows for the addition of icon on the supported controls. Those icons could be any of the [`IconElement`](https://docs.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.iconelement)s: `<BitmapIcon />`, `<FontIcon />`, `<PathIcon />` or `<SymbolIcon />`.

Here are supported control with samples:

* TextBox:

```xml
<TextBox Style="{StaticResource MaterialFilledTextBoxStyle}"
um:ControlExtensions.LeadingCommand="{Binding MyCommand}">
<um:ControlExtensions.LeadingIcon>
<SymbolIcon Symbol="SolidStar" />
</um:ControlExtensions.LeadingIcon>
</TextBox>

<TextBox Style="{StaticResource MaterialFilledTextBoxStyle}"
um:ControlExtensions.TrailingCommand="{Binding MyCommand}"
um:ControlExtensions.IsTrailingIconVisible="False">
<um:ControlExtensions.TrailingIcon>
<SymbolIcon Symbol="SolidStar" />
</um:ControlExtensions.TrailingIcon>
</TextBox>
```

* PasswordBox:

```xml
<PasswordBox Style="{StaticResource MaterialFilledPasswordBoxStyle}">
<TextBox Style="{StaticResource MaterialFilledTextBoxStyle}">
<um:ControlExtensions.Icon>
<SymbolIcon Symbol="Favorite" />
<SymbolIcon Symbol="SolidStar" />
</um:ControlExtensions.Icon>
</PasswordBox>
</ComboBox>
```

* ComboBox:
Expand All @@ -62,16 +26,6 @@ Here are supported control with samples:
</ComboBox>
```

* Button:

```xml
<Button Style="{StaticResource MaterialOutlinedButtonStyle}">
<um:ControlExtensions.Icon>
<FontIcon Glyph="&#xE946;" />
</um:ControlExtensions.Icon>
</Button>
```

## Alternate Content

This feature allows putting different content on a control when the state changes.
Expand Down
92 changes: 0 additions & 92 deletions src/library/Uno.Material/Extensions/ControlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Diagnostics.CodeAnalysis;
using Windows.UI;
using Uno.Disposables;
using System.Windows.Input;

#if WinUI
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -65,97 +64,6 @@ public static class ControlExtensions

#endregion

#region DependencyProperty: LeadingIcon

public static DependencyProperty LeadingIconProperty { [DynamicDependency(nameof(GetLeadingIcon))] get; } = DependencyProperty.RegisterAttached(
"LeadingIcon",
typeof(IconElement),
typeof(ControlExtensions),
new PropertyMetadata(default));

[DynamicDependency(nameof(SetLeadingIcon))]
public static IconElement GetLeadingIcon(Control obj) => (IconElement)obj.GetValue(LeadingIconProperty);

[DynamicDependency(nameof(GetLeadingIcon))]
public static void SetLeadingIcon(Control obj, IconElement value) => obj.SetValue(LeadingIconProperty, value);

#endregion

#region DependencyProperty: IsLeadingIconVisible

public static DependencyProperty IsLeadingIconVisibleProperty { [DynamicDependency(nameof(GetIsLeadingIconVisible))] get; } = DependencyProperty.RegisterAttached(
"IsLeadingIconVisible",
typeof(bool),
typeof(ControlExtensions),
new PropertyMetadata(true));

[DynamicDependency(nameof(SetIsLeadingIconVisible))]
public static bool GetIsLeadingIconVisible(Control obj) => (bool)obj.GetValue(IsLeadingIconVisibleProperty);

[DynamicDependency(nameof(GetIsLeadingIconVisible))]
public static void SetIsLeadingIconVisible(Control obj, bool value) => obj.SetValue(IsLeadingIconVisibleProperty, value);

#endregion

#region DependencyProperty: LeadingCommand
public static DependencyProperty LeadingCommandProperty { [DynamicDependency(nameof(GetLeadingCommand))] get; } = DependencyProperty.RegisterAttached(
"LeadingCommand",
typeof(ICommand),
typeof(ControlExtensions),
new PropertyMetadata(default));

[DynamicDependency(nameof(GetLeadingCommand))]
public static ICommand GetLeadingCommand(Control obj) => (ICommand)obj.GetValue(LeadingCommandProperty);

[DynamicDependency(nameof(SetLeadingCommand))]
public static void SetLeadingCommand(Control obj, ICommand value) => obj.SetValue(LeadingCommandProperty, value);
#endregion

#region DependencyProperty: TrailingIcon

public static DependencyProperty TrailingIconProperty { [DynamicDependency(nameof(GetTrailingIcon))] get; } = DependencyProperty.RegisterAttached(
"TrailingIcon",
typeof(IconElement),
typeof(ControlExtensions),
new PropertyMetadata(default));

[DynamicDependency(nameof(SetTrailingIcon))]
public static IconElement GetTrailingIcon(Control obj) => (IconElement)obj.GetValue(TrailingIconProperty);

[DynamicDependency(nameof(GetTrailingIcon))]
public static void SetTrailingIcon(Control obj, IconElement value) => obj.SetValue(TrailingIconProperty, value);
#endregion

#region DependencyProperty: IsTrailingIconVisible

public static DependencyProperty IsTrailingIconVisibleProperty { [DynamicDependency(nameof(GetIsTrailingIconVisible))] get; } = DependencyProperty.RegisterAttached(
"IsTrailingIconVisible",
typeof(bool),
typeof(ControlExtensions),
new PropertyMetadata(true));

[DynamicDependency(nameof(SetIsTrailingIconVisible))]
public static bool GetIsTrailingIconVisible(Control obj) => (bool)obj.GetValue(IsTrailingIconVisibleProperty);

[DynamicDependency(nameof(GetIsTrailingIconVisible))]
public static void SetIsTrailingIconVisible(Control obj, bool value) => obj.SetValue(IsTrailingIconVisibleProperty, value);

#endregion

#region DependencyProperty: TrailingCommand
public static DependencyProperty TrailingCommandProperty { [DynamicDependency(nameof(GetTrailingCommand))] get; } = DependencyProperty.RegisterAttached(
"TrailingCommand",
typeof(ICommand),
typeof(ControlExtensions),
new PropertyMetadata(default));

[DynamicDependency(nameof(GetTrailingCommand))]
public static ICommand GetTrailingCommand(Control obj) => (ICommand)obj.GetValue(TrailingCommandProperty);

[DynamicDependency(nameof(SetTrailingCommand))]
public static void SetTrailingCommand(Control obj, ICommand value) => obj.SetValue(TrailingCommandProperty, value);
#endregion

#region DependencyProperty: AlternateContent

public static DependencyProperty AlternateContentProperty { [DynamicDependency(nameof(GetAlternateContent))] get; } = DependencyProperty.RegisterAttached(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<um:FromNullToValueConverter x:Key="MaterialNullToTransparent"
NotNullValue="1"
NullValue="0" />

<um:FromEmptyStringOrNullObjectToValueConverter x:Key="MaterialEmptyOrNullToVisible"
NotEmptyOrNullValue="Collapsed"
EmptyOrNullValue="Visible" />
Expand Down
Loading

0 comments on commit a23c7e3

Please sign in to comment.