Skip to content

Effects - #1574

Merged
Redth merged 10 commits into
mainfrom
effects
Jul 12, 2021
Merged

Effects#1574
Redth merged 10 commits into
mainfrom
effects

Conversation

@PureWeen

@PureWeen PureWeen commented Jul 7, 2021 •

Copy link
Copy Markdown
Member

Description of Change

Implements #1226

Usage Examples

Using Routing Effects from Xamarin.Forms

Register your routing effect

appBuilder.ConfigureEffects(builder =>
{
	builder.Add<FocusRoutingEffect, FocusPlatformEffect>();
});
<Entry Text="Alert Simple">
    <Entry.Effects>
         <local:FocusRoutingEffect></local:FocusRoutingEffect>
    </Entry.Effects>
</Entry>

Just using the Platform Effect

Because of how MAUI works you don't really need the routing effect anymore so you can just ignore all registration and just add a multi targeted platform effect to xaml

<Entry Text="Alert Simple">
    <Entry.Effects>
         <local:FocusPlatformEffect></local:FocusPlatformEffect>
     </Entry.Effects>
</Entry>
public class FocusPlatformEffect : PlatformEffect
{
	public FocusPlatformEffect() : base()
	{
	}

#if WINDOWS
		protected override void OnAttached()
		{
			try
			{
				(Control as Microsoft.UI.Xaml.Controls.Control).Background = new Microsoft.UI.Xaml.Media.SolidColorBrush(Microsoft.UI.Colors.Cyan);
				(Control as MauiTextBox).BackgroundFocusBrush = new Microsoft.UI.Xaml.Media.SolidColorBrush(Microsoft.UI.Colors.White);
			}
			catch (Exception ex)
			{
				Debug.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
			}
		}
#endif

	protected override void OnDetached()
	{
	}
}

Register effects via assembly scanning

.ConfigureEffects(effects =>
{
	effects.AddCompatibilityEffects(Device.GetAssemblies());
})

@Redth

Redth commented Jul 8, 2021

Copy link
Copy Markdown
Member

Love that we don't really need the routing effect with MAUI, that makes the effect code so much cleaner.

namespace Microsoft.Maui.Controls
{
public partial class Element : Maui.IElement
public partial class Element : Maui.IElement, IEffectControlProvider

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In XF all the renderers implemented IEffectControlProvider so this just consolidates that behavior to the Element instead of the renderer

@PureWeen
PureWeen marked this pull request as ready for review July 8, 2021 18:20
return properties;
}

internal static void RegisterEffects(Assembly[] assemblies)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moves the register effects code to its own method so it's not getting called along side the other registration calls

Inner = Resolve(effectId);
}

protected RoutingEffect()

@PureWeen PureWeen Jul 8, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you register your effect via the builder you don't need to use an EffectId. I thought about creating a different base class but didn't want to require that of the user

@PureWeen
PureWeen requested a review from mattleibow July 8, 2021 19:58
@Redth
Redth merged commit 1668b81 into main Jul 12, 2021
@Redth
Redth deleted the effects branch July 12, 2021 15:40
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 14, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 16, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 20, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 4, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 4, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 9, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 11, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
shyunMin pushed a commit to shyunMin/maui that referenced this pull request Aug 22, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
shyunMin pushed a commit to shyunMin/maui that referenced this pull request Aug 22, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Dec 20, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Dec 27, 2021
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 3, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 17, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 19, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 21, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 27, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 4, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 8, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 10, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 21, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 23, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 25, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 28, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 2, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 2, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 3, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 4, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 7, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 8, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 8, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 9, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 11, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 14, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 14, 2022
- Effects (dotnet#1574)
- Improve Window and AnimationManager (dotnet#1653)
- and so on
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants