SlideShare una empresa de Scribd logo
DotNetDom: El futuro de Xamarin
javiersuarezruiz@hotmail.com
https://javiersuarezruiz.wordpress.com
¡No dudéis en preguntar!
DotNetDom: El futuro de Xamarin
El viaje hacia un único .NET
– .De .NET 5 a .NET 6
.NET Framework
Mono / Xamarin
.NET Core
.NET
Un SDK, un BCL, herramientas unificadas
Mobile & Desktop Cross-platform UI nativa
UI web Cross-platform
Investigaciones en la nube
Continuar mejorando la velocidad, tamaño, diagnóstico en
servicios Azure
La vision de un .NET
UI nativa cross platform
Proyecto único, Código compartido
Despliegue a multiples dispositivos, mobile & desktop
Disponible con .NET 6
.NET 6
.NET Multi-platform App UI
github.com/dotnet/maui
WinUI Mac
Catalyst
Android
iOS
iOS
macOS
Mac Catalyst
Jonathan Dick – Pool Math
Gracias Frank! https://praeclarum.org/2020/11/10/catalyst.html
WinUI 3
https://github.com/xamarin/Xamarin.Forms/tree/winui3_desktop
.NET Multi-platform App UI
Blazor Reusar componentes UI entre nativo y web
Creado e encima de .NET Multi-platform App UI
Contenedor de app nativo & embedded controls
Disponible con .NET 6
Puede usar la App nativa
container & controles
macOS
.NET MAUI: Otros detalles
DESKTOP MOBILE
Windows
macOS
iOS
Android
.NET MAUI
File | New
• Multi-platform App UI (.NET)
CLI
• dotnet install maui
• dotnet new maui
Namespaces
• Microsoft.Maui (antes Xamarin.Forms)
• Microsoft.Essentials (antes Xamarin.Essentials)
Los objetivos de .NET MAUI
La arquitectura de .NET MAUI
Las API de Android, iOS, macOS y Windows están unificadas en una API abstracta que permite una
experiencia de desarrollo que permita escribir una vez y ejecutar en cualquier plataforma, al tiempo
que proporciona un acceso total a todos los aspectos de cada plataforma nativa.
App Code interactúa principalmente con .NET
MAUI API (1).
Según sea necesario, App Code puede acceder
directamente las API de la plataforma (2) a
través Handlers, etc.
.NET MAUI accede directamente las API de la
plataforma nativa (3).
Android iOS macOS Windows
Xamarin.Android Xamarin.iOS Xamarin.Mac WinUI
.NET MAUI
App Code
Mono Runtime WinRT
.NET 6 BCL
1
2
3
Xamarin.Forms 5 .NET MAUI
Platforms
Android API 19+ API 21+
iOS 9 – 15 10+
Linux (GTK#) Community Community
macOS Community Microsoft
Tizen Samsung Samsung
Windows UWP Microsoft
WPF Community
WinUI 3 Microsoft
WPF Community
Features
Renderers Tightly coupled to BindableObject Loosely coupled, no Core deps
App Models MVVM / RxUI MVVM / RxUI (MVU experimental)
Single Project No Yes
Multi-Targeting No Yes
Multi-Window No Yes
Pixel Drawn Controls No Yes
Misc
.NET X.iOS, X.Android, UWP, … .NET 6 +
Project System Franken-Proj SDK Style
dotnet CLI No Yes
Tools
Visual Studio 2019 Yes Yes
Visual Studio 2019 for Mac Yes Yes
Visual Studio Code No Experimental
Roadmap
Timeline
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
¿Dónde tengo más información?
https://aka.ms/discord-maui
https://github.com/dotnet/maui
DotNetDom: El futuro de Xamarin
Aplicación y eventos relacionados con el ciclo de vida
En .NET MAUI habra soporte a multi-
ventana y por ese motivo, la jerarquía
relacionada con la aplicación cambia:
Application > Window > Page
A su vez, se cubre una de las peticiones
con mayor interés, más información
relacionada con el ciclo de vida.
https://github.com/dotnet/maui/issues/30
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
¿Por qué este cambio con respecto a Xamarin.Forms?
Xamarin.Forms.Button
- Renderers estan muy acoplados a components Xamarin.Forms
[assembly: ExportRenderer (typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CustomRenderer.iOS {
public class MyEntryRenderer : EntryRenderer
- Assembly Scanning es muy lento
- Es difícil acceder a código nativo desde código xplat
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
boxView.On<iOS>().UseBlurEffect(BlurEffectStyle.ExtraLight);
// You need to know to export this renderer and tie it to a core type…
[assembly: ExportRenderer (typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CustomRenderer.iOS
{
// You need to know what type to inherit from…
public class MyEntryRenderer : EntryRenderer
{
// You need to know what method to override…
protected override void OnElementChanged (ElementChangedEventArgs<Entry> e)
{
// You need to know when to do your work (before? after?)
base.OnElementChanged (e);
// You need to know that we call the native view “Control”
// Spoiler alert: this varies from platform to platform and
// sometimes it even varies from renderer to renderer!
if (Control != null) {
// Finally! We can change the color!
Control.BackgroundColor = UIColor.FromRGB (204, 153, 255);
}
}
}
}
public class MyEntry : Entry
{
}
Los objetivos de los Handlers
- Mejorar el rendimiento
- Registrar, acceder y modificar código nativo desde Xplat de forma sencilla
RegistrarHandlers.Handlers.Register<Xamarin.Forms.Label, LabelHandler>();
#if MONOANDROID
RegistrarHandlers.Handlers.Register<Xamarin.Forms.Label,
Xamarin.Forms.Platform.Android.LabelRenderer>();
RegistrarHandlers.Handlers.Register<Xamarin.Forms.Button,
Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer>();
#endif
- Eliminar assembly scanning
Estrategia actual con los Renderers
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs
e)
{
if (e.PropertyName == Button.TextColorProperty.PropertyName)
UpdateTextColor();
else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
UpdateEnabled();
else if (e.PropertyName == Button.FontProperty.PropertyName)
UpdateFont();
else if (e.PropertyName == Button.CharacterSpacingProperty.PropertyName)
UpdateCharacterSpacing();
base.OnElementPropertyChanged(sender, e);
}
private void UpdateFont()
private void UpdateTextColor()
Estrategia con .NET MAUI Handlers
public partial class LabelHandler : AbstractViewHandler<ILabel, TextView>
{
protected override TextView CreateView() => new TextView(Context);
public static void MapText(IViewHandler handler, ILabel view) =>
(handler as LabelHandler).TypedNativeView.UpdateText(view);
}
public static class TextViewExtensions
{
public static void UpdateText(this TextView textView, IText text)
{
textView.Text = text.Text;
}
public partial class LabelHandler
{
public static PropertyMapper<ILabel> LabelMapper =
new PropertyMapper<ILabel>(ViewHandler.ViewMapper)
{
[nameof(ILabel.Text)] = MapPropertyText,
DotNetDom: El futuro de Xamarin
.NET MAUI e inyección de dependencias
.NET MAUI usará un concepto de Host similar al existente en otros frameworks como ASP.NET. Esto
permitirá usar los contenedores y proveedores para nuestros Handlers, así como configurar con el
archivo de configuración de la aplicación, u otras características como el ciclo de vida y los servicios
integrados, las extensiones de registro, etc.
El AppBuilder estará oculto por defecto, pero permitiremos editarlo. De esta forma, puede ampliarlo
registrando servicios nativos, configurar logging, registrar nuevos Handlers.
En .NET MAUI, vamos a utilizar Microsoft Dependency Injection para registrar Handlers personalizados.
var (host,app) = App.CreateDefaultBuilder()
.RegisterHandler<IButton, CustomHandlers.CustomPinkTextButtonHandler>()
.ConfigureServices(ConfigureExtraServices)
.Init<MyApp>();
var page = app.GetStartup()
https://github.com/xamarin/Xamarin.Forms/pull/12460
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
Microsoft.Maui.Graphics
https://github.com/dotnet/Microsoft.Maui.Graphics
GraphicsControls
• GraphicsControls es una librería experimental
que ofrece controles dibujados permitiendo
elegir entre Cupertino, Fluent y Material.
• Ofrece los controles disponibles en
Xamarin.Forms Visual.
• Soporte a accesibilidad, RTL, cambios de
tema, etc.
https://github.com/dotnet/GraphicsControls
Visual
Estamos validando con empresas y clientes de Xamarin.Forms el
concepto de dibujado.
En caso de pasar de la fase experimental, la idea es reemplazar
los Renderers de Visual Material por Handlers con controles
dibujados. Esto permitirá tener controles exactamente con el
mismo renderizado pixel-perfect en todas las plataformas, con
alto rendimiento y fáciles de extender.
DotNetDom: El futuro de Xamarin
Más cambios
• Proyecto único.
• .NET 6.
• C# Hot Reload.
• Shell vNext.
• Nuevos Layouts.
• Xamarin Essentials para a integrarse con .NET MAUI.
• ¡Y más!
DotNetDom: El futuro de Xamarin
Productivity
Productivity
Productivity
Productivity
Productivity
Productivity
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
Usando Renderers “antiguos” en .NET MAUI
Puedes elegir entre adaptar tu código a Handlers o seguir
usando Renderers.
Usando Handlers
• Requiere ”algo de tiempo" para realizar la conversión de
código.
• Cada Handler es equivalente a un Fast Renderer en conjunto
con cambios en Layouts para buscar mejoras de rendimiento.
• Permite más opciones de extensibilidad.
Usando Renderers
• No requiere cambios.
• No tienes ventajas de las ventajas añadidas con handlers
(rendimiento, extensibilidad, etc.)
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
Aunque, puede que te interese migrar bajo tu conveniencia.
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
¿Preguntas?

Más contenido relacionado

PPTX
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
PPTX
Monkey Conf 2020: .NET MAUI Handlers
PPTX
Taller Xamarin Monkey Conf 2018
PPTX
Monkey Conf 2019: Presente y futuro de Xamarin.Forms
PPTX
Analizando interfaces de usuario avanzadas con Xamarin.Forms
PPTX
Creando controles para Xamarin.Forms
PPTX
.Net Conf Sevilla 2018
PPTX
Monkey Conf 2018: Conociendo Xamarin.Forms Shell
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
Monkey Conf 2020: .NET MAUI Handlers
Taller Xamarin Monkey Conf 2018
Monkey Conf 2019: Presente y futuro de Xamarin.Forms
Analizando interfaces de usuario avanzadas con Xamarin.Forms
Creando controles para Xamarin.Forms
.Net Conf Sevilla 2018
Monkey Conf 2018: Conociendo Xamarin.Forms Shell

La actualidad más candente (20)

PPTX
DotNet2018: Xamarin.Forms Everywhere!
PPTX
WinObjC: Windows Bridge para iOS
PPTX
dotNetMálaga 2017 - Trucos y consejos rendimiento Xamarin.Forms
PPTX
OpenSouthCode 2018: Taller Xamarin
PPTX
Introducción a Xamarin
PPTX
Extendiendo Xamarin.Forms
PPTX
Xamarin Dev Days Málaga 2017 - Apps conectadas con Azure
PPTX
Xamarin REvolve 2016
PPTX
Novedades de Xamarin 4
PPTX
DotNet 2019: Optimizando Apps con Xamarin.Forms
PPTX
SVQXDG - Introducción a Embeddinator-4000
PPTX
Servicios Xamarin
PDF
Arquitectura xamarin - Nuestra primera app
PPTX
Novedades en Visual Studio Online
PPTX
Desktop App Converter
PPTX
re-Connect Madrid: Novedades Xamarin
PPTX
Integración Continua con Apps Xamarin
PPTX
Reconnect(); Sevilla - Introducción a Xamarin 4
PPTX
Interfaces nativas Cross-Platform con Xamarin.Forms
PPTX
Reconnect(); Sevilla - Keynote
DotNet2018: Xamarin.Forms Everywhere!
WinObjC: Windows Bridge para iOS
dotNetMálaga 2017 - Trucos y consejos rendimiento Xamarin.Forms
OpenSouthCode 2018: Taller Xamarin
Introducción a Xamarin
Extendiendo Xamarin.Forms
Xamarin Dev Days Málaga 2017 - Apps conectadas con Azure
Xamarin REvolve 2016
Novedades de Xamarin 4
DotNet 2019: Optimizando Apps con Xamarin.Forms
SVQXDG - Introducción a Embeddinator-4000
Servicios Xamarin
Arquitectura xamarin - Nuestra primera app
Novedades en Visual Studio Online
Desktop App Converter
re-Connect Madrid: Novedades Xamarin
Integración Continua con Apps Xamarin
Reconnect(); Sevilla - Introducción a Xamarin 4
Interfaces nativas Cross-Platform con Xamarin.Forms
Reconnect(); Sevilla - Keynote
Publicidad

Similar a DotNetDom: El futuro de Xamarin (20)

PPTX
Azure Tech Frogs La vida despues de Xamarin NET MAUI y el desarrollo de apps....
PPTX
Evento Bolivia - Fundamentos de Xamarin - Desarrollo de apps moviles multipla...
PPTX
Semana Lambda - Fundamentos de Xamarin - Desarrollo de apps moviles multiplat...
PPTX
Back2Learn MSFT UCuenca - Desarrollo de apps móviles multiplataforma con Xam...
PPTX
Codemotion 2017 - Taller Xamarin
PPTX
Primer vistazo a .NET MAUI
PPTX
dotNetMálaga - Taller Xamarin
PDF
Introduction to .NET MAUI.pdf
PPTX
Introduction to xamarin
PPTX
Semanahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
PPTX
primera aplicacion Xamarin.pptx
PPTX
Hablemos de .NET 6 y .NET MAUI
PDF
Topicos Selectos de Xamarin
PPTX
COECYS - Introducción al desarrollo de apps multiplataforma con Xamarin.pptx
PDF
Introduccion-a-Xamarin-y-Xamarin.Forms_1.pdf
PDF
Azure Storage y Xamarin - Tec Tianguistenco
PPTX
Xamarin Dev Days Madrid - Taller Xamarin
PPTX
Plain Concepts Tech Day: Desarrollo de aplicaciones multiplataforma con Xamarin
PPTX
Women Who Code Bogota: Introduction to Xamarin Forms
PPTX
Semana 02 Aplicacion Movil.pptx
Azure Tech Frogs La vida despues de Xamarin NET MAUI y el desarrollo de apps....
Evento Bolivia - Fundamentos de Xamarin - Desarrollo de apps moviles multipla...
Semana Lambda - Fundamentos de Xamarin - Desarrollo de apps moviles multiplat...
Back2Learn MSFT UCuenca - Desarrollo de apps móviles multiplataforma con Xam...
Codemotion 2017 - Taller Xamarin
Primer vistazo a .NET MAUI
dotNetMálaga - Taller Xamarin
Introduction to .NET MAUI.pdf
Introduction to xamarin
Semanahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
primera aplicacion Xamarin.pptx
Hablemos de .NET 6 y .NET MAUI
Topicos Selectos de Xamarin
COECYS - Introducción al desarrollo de apps multiplataforma con Xamarin.pptx
Introduccion-a-Xamarin-y-Xamarin.Forms_1.pdf
Azure Storage y Xamarin - Tec Tianguistenco
Xamarin Dev Days Madrid - Taller Xamarin
Plain Concepts Tech Day: Desarrollo de aplicaciones multiplataforma con Xamarin
Women Who Code Bogota: Introduction to Xamarin Forms
Semana 02 Aplicacion Movil.pptx
Publicidad

Más de Javier Suárez Ruiz (14)

PPTX
Cape Town MS Developer User Group: Xamarin Community Toolkit
PPTX
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
PPTX
Crear interfaces de usuario atractivas con Xamarin.Forms
PPTX
#XamarinUIJuly Summary
PPTX
Novedades Xamarin 3.0 Preview
PPTX
Desarrollo Xamarin, más allá del desarrollo
PPTX
Introducción a Xamarin.Forms
PPTX
Introducción a Xamarin
PPTX
Aumento de productividad, herramientas Xamarin
PPTX
Novedades Xamarin Connect(); 2017
PPTX
dotNetMálaga 2017 - Taller Hololens con Wave Engine
PPTX
Embeddinator-4000
PPTX
Xamarin Hol - Módulo V: Mobile DevOps con Visual Studio Team Services y Hocke...
PPTX
Xamarin Dev Days Madrid 2017 - Xamarin.Forms
Cape Town MS Developer User Group: Xamarin Community Toolkit
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
Crear interfaces de usuario atractivas con Xamarin.Forms
#XamarinUIJuly Summary
Novedades Xamarin 3.0 Preview
Desarrollo Xamarin, más allá del desarrollo
Introducción a Xamarin.Forms
Introducción a Xamarin
Aumento de productividad, herramientas Xamarin
Novedades Xamarin Connect(); 2017
dotNetMálaga 2017 - Taller Hololens con Wave Engine
Embeddinator-4000
Xamarin Hol - Módulo V: Mobile DevOps con Visual Studio Team Services y Hocke...
Xamarin Dev Days Madrid 2017 - Xamarin.Forms

Último (8)

PDF
Su punto de partida en la IA: Microsoft 365 Copilot Chat
DOCX
trabajo programacion.docxxdxxxddxdxxdxdxxxdxxdxdxd
PPTX
sistemas de informacion.................
PPTX
Derechos_de_Autor_y_Creative_Commons.pptx
PDF
AutoCAD Herramientas para el futuro, Juan Fandiño
PDF
DIMENSIONADO DE UNA INSTALACION FOTOVOLTAICA.pdf
PDF
modelos de control para sistemas digitales
PDF
simulacion de teoria de control para maquinas
Su punto de partida en la IA: Microsoft 365 Copilot Chat
trabajo programacion.docxxdxxxddxdxxdxdxxxdxxdxdxd
sistemas de informacion.................
Derechos_de_Autor_y_Creative_Commons.pptx
AutoCAD Herramientas para el futuro, Juan Fandiño
DIMENSIONADO DE UNA INSTALACION FOTOVOLTAICA.pdf
modelos de control para sistemas digitales
simulacion de teoria de control para maquinas

DotNetDom: El futuro de Xamarin

  • 3. ¡No dudéis en preguntar!
  • 5. El viaje hacia un único .NET
  • 6. – .De .NET 5 a .NET 6 .NET Framework Mono / Xamarin .NET Core .NET Un SDK, un BCL, herramientas unificadas Mobile & Desktop Cross-platform UI nativa UI web Cross-platform Investigaciones en la nube Continuar mejorando la velocidad, tamaño, diagnóstico en servicios Azure La vision de un .NET
  • 7. UI nativa cross platform Proyecto único, Código compartido Despliegue a multiples dispositivos, mobile & desktop Disponible con .NET 6 .NET 6 .NET Multi-platform App UI github.com/dotnet/maui WinUI Mac Catalyst Android iOS iOS macOS
  • 8. Mac Catalyst Jonathan Dick – Pool Math Gracias Frank! https://praeclarum.org/2020/11/10/catalyst.html
  • 10. .NET Multi-platform App UI Blazor Reusar componentes UI entre nativo y web Creado e encima de .NET Multi-platform App UI Contenedor de app nativo & embedded controls Disponible con .NET 6 Puede usar la App nativa container & controles macOS
  • 11. .NET MAUI: Otros detalles DESKTOP MOBILE Windows macOS iOS Android .NET MAUI File | New • Multi-platform App UI (.NET) CLI • dotnet install maui • dotnet new maui Namespaces • Microsoft.Maui (antes Xamarin.Forms) • Microsoft.Essentials (antes Xamarin.Essentials)
  • 12. Los objetivos de .NET MAUI
  • 13. La arquitectura de .NET MAUI Las API de Android, iOS, macOS y Windows están unificadas en una API abstracta que permite una experiencia de desarrollo que permita escribir una vez y ejecutar en cualquier plataforma, al tiempo que proporciona un acceso total a todos los aspectos de cada plataforma nativa. App Code interactúa principalmente con .NET MAUI API (1). Según sea necesario, App Code puede acceder directamente las API de la plataforma (2) a través Handlers, etc. .NET MAUI accede directamente las API de la plataforma nativa (3). Android iOS macOS Windows Xamarin.Android Xamarin.iOS Xamarin.Mac WinUI .NET MAUI App Code Mono Runtime WinRT .NET 6 BCL 1 2 3
  • 14. Xamarin.Forms 5 .NET MAUI Platforms Android API 19+ API 21+ iOS 9 – 15 10+ Linux (GTK#) Community Community macOS Community Microsoft Tizen Samsung Samsung Windows UWP Microsoft WPF Community WinUI 3 Microsoft WPF Community Features Renderers Tightly coupled to BindableObject Loosely coupled, no Core deps App Models MVVM / RxUI MVVM / RxUI (MVU experimental) Single Project No Yes Multi-Targeting No Yes Multi-Window No Yes Pixel Drawn Controls No Yes Misc .NET X.iOS, X.Android, UWP, … .NET 6 + Project System Franken-Proj SDK Style dotnet CLI No Yes Tools Visual Studio 2019 Yes Yes Visual Studio 2019 for Mac Yes Yes Visual Studio Code No Experimental
  • 19. ¿Dónde tengo más información? https://aka.ms/discord-maui https://github.com/dotnet/maui
  • 21. Aplicación y eventos relacionados con el ciclo de vida En .NET MAUI habra soporte a multi- ventana y por ese motivo, la jerarquía relacionada con la aplicación cambia: Application > Window > Page A su vez, se cubre una de las peticiones con mayor interés, más información relacionada con el ciclo de vida. https://github.com/dotnet/maui/issues/30
  • 24. ¿Por qué este cambio con respecto a Xamarin.Forms? Xamarin.Forms.Button - Renderers estan muy acoplados a components Xamarin.Forms [assembly: ExportRenderer (typeof(MyEntry), typeof(MyEntryRenderer))] namespace CustomRenderer.iOS { public class MyEntryRenderer : EntryRenderer - Assembly Scanning es muy lento - Es difícil acceder a código nativo desde código xplat using Xamarin.Forms.PlatformConfiguration; using Xamarin.Forms.PlatformConfiguration.iOSSpecific; boxView.On<iOS>().UseBlurEffect(BlurEffectStyle.ExtraLight);
  • 25. // You need to know to export this renderer and tie it to a core type… [assembly: ExportRenderer (typeof(MyEntry), typeof(MyEntryRenderer))] namespace CustomRenderer.iOS { // You need to know what type to inherit from… public class MyEntryRenderer : EntryRenderer { // You need to know what method to override… protected override void OnElementChanged (ElementChangedEventArgs<Entry> e) { // You need to know when to do your work (before? after?) base.OnElementChanged (e); // You need to know that we call the native view “Control” // Spoiler alert: this varies from platform to platform and // sometimes it even varies from renderer to renderer! if (Control != null) { // Finally! We can change the color! Control.BackgroundColor = UIColor.FromRGB (204, 153, 255); } } } } public class MyEntry : Entry { }
  • 26. Los objetivos de los Handlers - Mejorar el rendimiento - Registrar, acceder y modificar código nativo desde Xplat de forma sencilla RegistrarHandlers.Handlers.Register<Xamarin.Forms.Label, LabelHandler>(); #if MONOANDROID RegistrarHandlers.Handlers.Register<Xamarin.Forms.Label, Xamarin.Forms.Platform.Android.LabelRenderer>(); RegistrarHandlers.Handlers.Register<Xamarin.Forms.Button, Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer>(); #endif - Eliminar assembly scanning
  • 27. Estrategia actual con los Renderers protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == Button.TextColorProperty.PropertyName) UpdateTextColor(); else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName) UpdateEnabled(); else if (e.PropertyName == Button.FontProperty.PropertyName) UpdateFont(); else if (e.PropertyName == Button.CharacterSpacingProperty.PropertyName) UpdateCharacterSpacing(); base.OnElementPropertyChanged(sender, e); } private void UpdateFont() private void UpdateTextColor()
  • 28. Estrategia con .NET MAUI Handlers public partial class LabelHandler : AbstractViewHandler<ILabel, TextView> { protected override TextView CreateView() => new TextView(Context); public static void MapText(IViewHandler handler, ILabel view) => (handler as LabelHandler).TypedNativeView.UpdateText(view); } public static class TextViewExtensions { public static void UpdateText(this TextView textView, IText text) { textView.Text = text.Text; } public partial class LabelHandler { public static PropertyMapper<ILabel> LabelMapper = new PropertyMapper<ILabel>(ViewHandler.ViewMapper) { [nameof(ILabel.Text)] = MapPropertyText,
  • 30. .NET MAUI e inyección de dependencias .NET MAUI usará un concepto de Host similar al existente en otros frameworks como ASP.NET. Esto permitirá usar los contenedores y proveedores para nuestros Handlers, así como configurar con el archivo de configuración de la aplicación, u otras características como el ciclo de vida y los servicios integrados, las extensiones de registro, etc. El AppBuilder estará oculto por defecto, pero permitiremos editarlo. De esta forma, puede ampliarlo registrando servicios nativos, configurar logging, registrar nuevos Handlers. En .NET MAUI, vamos a utilizar Microsoft Dependency Injection para registrar Handlers personalizados. var (host,app) = App.CreateDefaultBuilder() .RegisterHandler<IButton, CustomHandlers.CustomPinkTextButtonHandler>() .ConfigureServices(ConfigureExtraServices) .Init<MyApp>(); var page = app.GetStartup() https://github.com/xamarin/Xamarin.Forms/pull/12460
  • 34. GraphicsControls • GraphicsControls es una librería experimental que ofrece controles dibujados permitiendo elegir entre Cupertino, Fluent y Material. • Ofrece los controles disponibles en Xamarin.Forms Visual. • Soporte a accesibilidad, RTL, cambios de tema, etc. https://github.com/dotnet/GraphicsControls
  • 35. Visual Estamos validando con empresas y clientes de Xamarin.Forms el concepto de dibujado. En caso de pasar de la fase experimental, la idea es reemplazar los Renderers de Visual Material por Handlers con controles dibujados. Esto permitirá tener controles exactamente con el mismo renderizado pixel-perfect en todas las plataformas, con alto rendimiento y fáciles de extender.
  • 37. Más cambios • Proyecto único. • .NET 6. • C# Hot Reload. • Shell vNext. • Nuevos Layouts. • Xamarin Essentials para a integrarse con .NET MAUI. • ¡Y más!
  • 48. Usando Renderers “antiguos” en .NET MAUI Puedes elegir entre adaptar tu código a Handlers o seguir usando Renderers. Usando Handlers • Requiere ”algo de tiempo" para realizar la conversión de código. • Cada Handler es equivalente a un Fast Renderer en conjunto con cambios en Layouts para buscar mejoras de rendimiento. • Permite más opciones de extensibilidad. Usando Renderers • No requiere cambios. • No tienes ventajas de las ventajas añadidas con handlers (rendimiento, extensibilidad, etc.)
  • 60. Aunque, puede que te interese migrar bajo tu conveniencia.

Notas del editor

  • #6: Now let’s talk about the future…..
  • #8: We’re making progress on .NET Multi-platform App UI that we announced almost a year ago at Build 2020. It will help you deliver performant, beautiful and consistent app experiences across various platforms and devices, and allow you to share code across your mobile and desktop apps. .NET MAUI under the hood uses technologies out there today for building native apps on Windows with WinUI, Mac Catalyst for macOS, and of course, iOS and Android. .NET MAUI abstracts all those frameworks into a single framework built on .NET 6. <CLICK> That means it will allow you to build these apps for any device from a single codebase and project system. <CLICK> And that includes desktop and mobile across operating systems, Windows, macOS, iOS and Android. <CLICK> It will be part of the unified .NET in the .NET 6 timeframe <CLICK> and preview 1 dropped last week so you can go check it out!
  • #11: Blazor has become a very popular way to write .NET web apps. We first supported Blazor on the server, then in the browser with WebAssembly, and now we’re extending it again, to enable you to write Blazor desktop apps in .NET 6. This enables you to create hybrid client apps, which combine web and native UI together in a native client application. It is primarily targeted at web developers that want provide rich client and offline experiences for their users. Blazor hybrid desktop apps is built on top of .NET Multi-platform App UI. It relies on that UI stack for a native application container and native controls (should you want to use them). 
  • #17: maddy
  • #18: maddy
  • #19: maddy
  • #20: maddy
  • #25: In Xamarin.Forms, the Renderers are tightly couple to Xamarin.Forms components. In the ButtonRenderer, have several references to a Xamarin.Forms Button which is a bindable object implementing INotifyPropertyChanged, etc. The other topic is, the Xamarin.Forms Registrar where register the available renderers, etc. In this case, use assembly scanning and it is really slow. What happens is basically, Xamarin.Forms goes through and scans all your assemblies for assembly attributes and then automatically registers to the framework, and Allow to use that components. This is great because is easy to use, and try to remove some requirements from the user, but impact in the performance. The third topic is, in some cases is really complex to reach the native platform from cross platform code. Mainly, because the way that dependency tree works. The button renderer depends on button component so, the button has no concept of a renderer. When you are in the Button context, have no context or reference to the renderer. If you want to Access the native layer, you have different options. You can register your own custom renderer and interact with it or, use an API, that is great but very difficult to discover. I am talking about Platform Specifics. At the end, is not doing anything really special, just setting a cross platform pproperty to a native UI control property.
  • #26: Relying on event handlers to orchestrate behavior and property changes Lots of boilerplate code Tons of knowledge required about order of events, both on the platform side and on the Xamarin.Forms side (i.e,, Does this need to happen on ElementChanged? What about ElementPropertyChanged? Etc.)
  • #27: There are several ideas driving this, but one of the most important ones is performance minded and simplified. Achieve a much better performance and allow to understand how everything Works in a easy way. Mostly, if you are a new developer. In Xamarin.Forms is a Little bit hard to understanding how to get the renderer, the lifecycle, etc. Also, is complex as we mentioned to Access to any native element from the cross platform layer. So, what we are doing is sort of moving everything into the cross-platform side to allow you Access things within the context of your shared application. So you can see in the slides some samples, and as you can see, the idea is to allow register any handler you want. For sure, there are handlers registered by defaut, but, you can swap those in and out. The idea behind this is, we are not going to use assembly scanning by default. In next slides we will see that we will allow the use of scanning assembly for a very specific case. This is for teo reason; first one, to gain performance and second one; to simplify the registration process. Of course, the code sample from the slides, also Works with multitargeting so you can include it in cross platform code.
  • #28: Now, I am going to compare the ways renderers strategy Works in Xamarin.Forms and .NET MAUI. In Xamarin.Forms, there are some huge if statements, some consistency problems, all of the methods to update any property are privates.
  • #29: The .NET MAUI strategy is more function based. The idea here is that, all the update methods we have seen before, will be moved to extensión methods. Why?. Will be public methods that you will be able to apply in your own handlers. Also, is very powerful for cross-platform, because since the way everything Works is créate a standard API across all platforms, for example, the LabelExtensions, you can use it from a cross platform class, and you can say, handler, UpdateText and in every platform will use the same method with the correct implementation for the platform. So, image this, and we will see this in samples more later, but can have just one class to implement the Handler while in Xamarin.Forms we used several projects, several clases, etc. Finally, the mapper is just a dictionary of functions, so before when you saw the Xamarin.Forms property changed stuff, what was doing is just mapping string with methods. And is what the mapper is doing but standarizing that to use a structure and something much more pluggable.
  • #38: All this is poising the framework to be easily to extend, and allow more customization options. Shell vNext: More customization options, more explicit API, more integrated with MVVM frameworks, etc.