Skip to content

Commit

Permalink
Effects (#1574)
Browse files Browse the repository at this point in the history
* Effects

* - fix calls to deleted method

* - fix

* - fix gallery

* - winui gallery

* - ios gallery

* - add rest of the platforms effects

* - fix sample order

* - TempPage

* - add assembly scanning registration of effects
  • Loading branch information
PureWeen committed Jul 12, 2021
1 parent bcf9ee7 commit 1668b81
Show file tree
Hide file tree
Showing 44 changed files with 440 additions and 78 deletions.
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Android;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Effects;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(AttachedStateEffectRenderer), AttachedStateEffect.EffectName)]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Android
Expand Down
@@ -1,4 +1,5 @@
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using Microsoft.Maui.Controls.Platform;

namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Android
{
Expand Down
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using AndroidX.Core.View;
using AndroidX.Core.View.Accessibility;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(ContentDescriptionEffectRenderer), ContentDescriptionEffect.EffectName)]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Android
Expand Down
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using AView = Android.Views.View;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.Android.RippleEffect), nameof(Microsoft.Maui.Controls.Compatibility.ControlGallery.Android.RippleEffect))]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.Android
Expand Down
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.Android._58406EffectRenderer), Bugzilla58406.EffectName)]

Expand Down
4 changes: 4 additions & 0 deletions src/Compatibility/ControlGallery/src/Core/Startup.cs
Expand Up @@ -29,6 +29,10 @@ public virtual void Configure(IAppHostBuilder appBuilder)
.ConfigureServices(services =>
{
DependencyService.Register(Device.GetAssemblies());
})
.ConfigureEffects(effects =>
{
effects.AddCompatibilityEffects(Device.GetAssemblies());
});
}
}
Expand Down
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Effects;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(AttachedStateEffectRenderer), AttachedStateEffect.EffectName)]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI
Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/ControlGallery/src/WinUI/BorderEffect.cs
@@ -1,6 +1,7 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;

Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/ControlGallery/src/WinUI/FocusEffect.cs
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Controls.Platform;
using Microsoft.UI;
using Microsoft.UI.Xaml.Media;
using Windows.UI;
Expand Down
Expand Up @@ -2,6 +2,7 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml.Controls;

[assembly: ExportEffect(typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI._58406EffectRenderer), Bugzilla58406.EffectName)]
Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/ControlGallery/src/iOS/AppDelegate.cs
Expand Up @@ -14,6 +14,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Size = Microsoft.Maui.Graphics.Size;
using Microsoft.Maui.Controls.Platform;

[assembly: Dependency(typeof(TestCloudService))]
[assembly: Dependency(typeof(CacheService))]
Expand Down
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Effects;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(AttachedStateEffectRenderer), AttachedStateEffect.EffectName)]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS
Expand Down
@@ -1,5 +1,6 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS.CustomEffects.FooEffect), nameof(Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS.CustomEffects.FooEffect))]

Expand Down
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS;
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(GradientEffect), Issue6334.EffectName)]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS
Expand Down
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(SearchbarEffect), "SearchbarEffect")]
namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS
Expand Down
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues;
using Microsoft.Maui.Controls.Compatibility;
using Microsoft.Maui.Controls.Compatibility.Platform.iOS;
using Microsoft.Maui.Controls.Platform;

[assembly: ExportEffect(typeof(Microsoft.Maui.Controls.Compatibility.ControlGallery.iOS._58406EffectRenderer), Bugzilla58406.EffectName)]

Expand Down
@@ -1,4 +1,5 @@
using Android.Views;
using Microsoft.Maui.Controls.Platform;
using AView = Android.Views.View;

namespace Microsoft.Maui.Controls.Compatibility.Platform.Android.FastRenderers
Expand Down Expand Up @@ -28,8 +29,8 @@ public void RegisterEffect(Effect effect)
return;
}

platformEffect.SetControl(_control);
platformEffect.SetContainer(_container);
platformEffect.Container = _container;
platformEffect.Control = _control;
}
}
}
10 changes: 0 additions & 10 deletions src/Compatibility/Core/src/Android/PlatformEffect.cs

This file was deleted.

Expand Up @@ -272,8 +272,8 @@ void IEffectControlProvider.RegisterEffect(Effect effect)

void OnRegisterEffect(PlatformEffect effect)
{
effect.SetContainer(this);
effect.SetControl(this);
effect.Container = this;
effect.Control = this;
}
}
}
Expand Up @@ -318,8 +318,8 @@ void IEffectControlProvider.RegisterEffect(Effect effect)

void OnRegisterEffect(PlatformEffect effect)
{
effect.SetContainer(this);
effect.SetControl(this);
effect.Container = this;
effect.Control = this;
}

static int GetDistance(double start, double position, double v)
Expand Down
2 changes: 1 addition & 1 deletion src/Compatibility/Core/src/Android/ViewRenderer.cs
Expand Up @@ -198,7 +198,7 @@ protected override void OnLayout(bool changed, int l, int t, int r, int b)
protected override void OnRegisterEffect(PlatformEffect effect)
{
base.OnRegisterEffect(effect);
effect.SetControl(Control);
effect.Control = Control;
}

void SetupAutomationDefaults()
Expand Down
Expand Up @@ -412,7 +412,7 @@ void UpdateParentPageTraversalOrder()

protected virtual void OnRegisterEffect(PlatformEffect effect)
{
effect.SetContainer(this);
effect.Container = this;
}

void SetupAutomationDefaults()
Expand Down
@@ -1,4 +1,5 @@
using System;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;

namespace Microsoft.Maui.Controls.Compatibility
Expand Down Expand Up @@ -101,5 +102,13 @@ public static IImageSourceServiceCollection AddCompatibilityServices(this IImage
#endif
return services;
}



public static IEffectsBuilder AddCompatibilityEffects(this IEffectsBuilder effectsBuilder, params global::System.Reflection.Assembly[] assemblies)
{
Internals.Registrar.RegisterEffects(assemblies);
return effectsBuilder;
}
}
}
8 changes: 0 additions & 8 deletions src/Compatibility/Core/src/WinUI/PlatformEffect.cs

This file was deleted.

5 changes: 3 additions & 2 deletions src/Compatibility/Core/src/WinUI/VisualElementRenderer.cs
Expand Up @@ -397,10 +397,11 @@ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEv

protected virtual void OnRegisterEffect(PlatformEffect effect)
{
effect.SetContainer(this);
effect.SetControl(Control);
effect.Container = this;
effect.Control = Control;
}


protected virtual void SetAutomationId(string id)
{
this.SetAutomationPropertiesAutomationId(id);
Expand Down
13 changes: 0 additions & 13 deletions src/Compatibility/Core/src/iOS/PlatformEffect.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Compatibility/Core/src/iOS/ShadowEffect.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using UIKit;
using PlatformElement = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.VisualElement;
Expand Down
2 changes: 1 addition & 1 deletion src/Compatibility/Core/src/iOS/ViewRenderer.cs
Expand Up @@ -169,7 +169,7 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
protected override void OnRegisterEffect(PlatformEffect effect)
{
base.OnRegisterEffect(effect);
effect.SetControl(Control);
effect.Control = Control;
}

protected override void SetAccessibilityHint()
Expand Down
6 changes: 3 additions & 3 deletions src/Compatibility/Core/src/iOS/VisualElementRenderer.cs
Expand Up @@ -108,8 +108,8 @@ public static void RegisterEffect(Effect effect, NativeView container, NativeVie
if (platformEffect == null)
return;

platformEffect.SetContainer(container);
platformEffect.SetControl(control);
platformEffect.Container = container;
platformEffect.Control = control;
}

#if __MOBILE__
Expand Down Expand Up @@ -445,7 +445,7 @@ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEv

protected virtual void OnRegisterEffect(PlatformEffect effect)
{
effect.SetContainer(this);
effect.Container = this;
}

protected virtual void SetAccessibilityHint()
Expand Down
Expand Up @@ -54,7 +54,6 @@
<MauiSplashScreen Include="Resources\Images\dotnet_bot.svg" Color="#FFFFFF" />
<AndroidResource Remove="Resources\**" />
</ItemGroup>

<Import Condition=" '$(UseMaui)' != 'true' " Project="..\..\..\BlazorWebView\src\Maui\build\Microsoft.AspNetCore.Components.WebView.Maui.targets" />

</Project>
32 changes: 32 additions & 0 deletions src/Controls/samples/Controls.Sample/Pages/Core/EffectsPage.xaml
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<views:BasePage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.EffectsPage"
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base"
xmlns:local="clr-namespace:Maui.Controls.Sample.Pages"
Title="Alerts">
<views:BasePage.Content>
<StackLayout
Margin="12">
<Label
Text="Entry With Focus Routing Effect"
Style="{StaticResource Headline}"/>
<Entry
Text="Alert Simple">
<Entry.Effects>
<local:FocusRoutingEffect></local:FocusRoutingEffect>
</Entry.Effects>
</Entry>
<Label
Text="Entry With Focus Platform Effect"
Style="{StaticResource Headline}"/>
<Entry
Text="Alert Simple">
<Entry.Effects>
<local:FocusPlatformEffect></local:FocusPlatformEffect>
</Entry.Effects>
</Entry>
</StackLayout>
</views:BasePage.Content>
</views:BasePage>

0 comments on commit 1668b81

Please sign in to comment.