Skip to content

Commit 2c3b6a0

Browse files
Revert "Make it possible to define when the IconTintBehavior gets applied (#2304)"
This reverts commit af82af8.
1 parent af82af8 commit 2c3b6a0

File tree

4 files changed

+3
-93
lines changed

4 files changed

+3
-93
lines changed

src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.android.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ protected override void OnAttachedTo(View bindable, AndroidView platformView)
2020
base.OnAttachedTo(bindable, platformView);
2121
nativeView = platformView;
2222

23-
if (ApplyOn is IconTintColorApplyOn.OnBehaviorAttachedTo)
24-
{
25-
ApplyTintColor(nativeView, TintColor);
26-
}
23+
ApplyTintColor(nativeView, TintColor);
2724

28-
bindable.Loaded += OnBindableLoaded;
2925
bindable.PropertyChanged += OnElementPropertyChanged;
3026
PropertyChanged += OnTintedImagePropertyChanged;
3127
}
@@ -37,20 +33,9 @@ protected override void OnDetachedFrom(View bindable, AndroidView platformView)
3733

3834
ClearTintColor(platformView);
3935

40-
bindable.Loaded -= OnBindableLoaded;
4136
bindable.PropertyChanged -= OnElementPropertyChanged;
4237
PropertyChanged -= OnTintedImagePropertyChanged;
4338
}
44-
45-
void OnBindableLoaded(object? sender, EventArgs e)
46-
{
47-
if (ApplyOn is not IconTintColorApplyOn.OnViewLoaded)
48-
{
49-
return;
50-
}
51-
52-
ApplyTintColor(nativeView, TintColor);
53-
}
5439

5540
static void ApplyTintColor(AndroidView? nativeView, Color? tintColor)
5641
{

src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.macios.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ protected override void OnViewPropertyChanged(View sender, PropertyChangedEventA
3030
protected override void OnAttachedTo(View bindable, UIView platformView)
3131
{
3232
base.OnAttachedTo(bindable, platformView);
33-
34-
bindable.Loaded += OnBindableLoaded;
3533

36-
if (ApplyOn is IconTintColorApplyOn.OnBehaviorAttachedTo)
37-
{
38-
ApplyTintColor(platformView, bindable, TintColor);
39-
}
34+
ApplyTintColor(platformView, bindable, TintColor);
4035

4136
PropertyChanged += (s, e) =>
4237
{
@@ -51,27 +46,9 @@ protected override void OnAttachedTo(View bindable, UIView platformView)
5146
protected override void OnDetachedFrom(View bindable, UIView platformView)
5247
{
5348
base.OnDetachedFrom(bindable, platformView);
54-
55-
bindable.Loaded -= OnBindableLoaded;
5649

5750
ClearTintColor(platformView, bindable);
5851
}
59-
60-
void OnBindableLoaded(object? sender, EventArgs e)
61-
{
62-
if (ApplyOn is not IconTintColorApplyOn.OnViewLoaded)
63-
{
64-
return;
65-
}
66-
67-
if (sender is not View view
68-
|| view.Handler?.PlatformView is not UIView platformView)
69-
{
70-
return;
71-
}
72-
73-
ApplyTintColor(platformView, view, TintColor);
74-
}
7552

7653
static void ClearTintColor(UIView platformView, View element)
7754
{

src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.shared.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
11
namespace CommunityToolkit.Maui.Behaviors;
22

3-
/// <summary>
4-
/// When to apply the status bar color and style.
5-
/// </summary>
6-
public enum IconTintColorApplyOn
7-
{
8-
/// <summary>
9-
/// Apply color when the behavior has been attached to the view.
10-
/// </summary>
11-
OnBehaviorAttachedTo,
12-
13-
/// <summary>
14-
/// Apply color when the view has been loaded.
15-
/// </summary>
16-
OnViewLoaded
17-
}
18-
193
/// <summary>
204
/// A behavior that allows you to tint an icon with a specified <see cref="Color"/>.
215
/// </summary>
226
public partial class IconTintColorBehavior : BasePlatformBehavior<View>
237
{
24-
/// <summary>
25-
/// <see cref="BindableProperty"/> that manages the ApplyOn property.
26-
/// </summary>
27-
public static readonly BindableProperty ApplyOnProperty =
28-
BindableProperty.Create(nameof(ApplyOn), typeof(IconTintColorApplyOn), typeof(IconTintColorBehavior), IconTintColorApplyOn.OnBehaviorAttachedTo);
29-
308
/// <summary>
319
/// Attached Bindable Property for the <see cref="TintColor"/>.
3210
/// </summary>
3311
public static readonly BindableProperty TintColorProperty =
3412
BindableProperty.Create(nameof(TintColor), typeof(Color), typeof(IconTintColorBehavior), default);
3513

36-
/// <summary>
37-
/// When the status bar color should be applied.
38-
/// </summary>
39-
public IconTintColorApplyOn ApplyOn
40-
{
41-
get => (IconTintColorApplyOn)GetValue(ApplyOnProperty);
42-
set => SetValue(ApplyOnProperty, value);
43-
}
44-
4514
/// <summary>
4615
/// Property that represents the <see cref="Color"/> that Icon will be tinted.
4716
/// </summary>

src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.windows.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ protected override void OnAttachedTo(View bindable, FrameworkElement platformVie
2525
{
2626
base.OnAttachedTo(bindable, platformView);
2727

28-
if (ApplyOn is IconTintColorApplyOn.OnBehaviorAttachedTo)
29-
{
30-
ApplyTintColor(platformView, bindable, TintColor);
31-
}
28+
ApplyTintColor(platformView, bindable, TintColor);
3229

33-
bindable.Loaded += OnBindableLoaded;
3430
bindable.PropertyChanged += OnElementPropertyChanged;
3531
this.PropertyChanged += (s, e) =>
3632
{
@@ -54,25 +50,8 @@ protected override void OnDetachedFrom(View bindable, FrameworkElement platformV
5450
base.OnDetachedFrom(bindable, platformView);
5551

5652
bindable.PropertyChanged -= OnElementPropertyChanged;
57-
bindable.Loaded -= OnBindableLoaded;
5853
RemoveTintColor(platformView);
5954
}
60-
61-
void OnBindableLoaded(object? sender, EventArgs e)
62-
{
63-
if (ApplyOn is not IconTintColorApplyOn.OnViewLoaded)
64-
{
65-
return;
66-
}
67-
68-
if (sender is not View view
69-
|| view.Handler?.PlatformView is not FrameworkElement platformView)
70-
{
71-
return;
72-
}
73-
74-
ApplyTintColor(platformView, view, TintColor);
75-
}
7655

7756
static bool TryGetButtonImage(WButton button, [NotNullWhen(true)] out WImage? image)
7857
{

0 commit comments

Comments
 (0)