Skip to content

Commit

Permalink
Bump to latest
Browse files Browse the repository at this point in the history
- Apply to start adding in APIs for adding legacy renderers via assembly scanning (dotnet#1333)
- Update to IMauiContext (dotnet#1357)
- and so on
  • Loading branch information
rookiejava committed Aug 9, 2021
1 parent 9c6f457 commit 7c87a7b
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 408 deletions.
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
using OpenGLViewRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.DefaultRenderer;
using StreamImagesourceHandler = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.StreamImageSourceHandler;
using ImageLoaderSourceHandler = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.UriImageSourceHandler;
using DefaultRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.DefaultRenderer;
#endif

namespace Microsoft.Maui.Controls.Hosting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static IMauiHandlersCollection AddCompatibilityRenderer<TControlType, TRe
public static IMauiHandlersCollection AddCompatibilityRenderers(this IMauiHandlersCollection handlersCollection, params global::System.Reflection.Assembly[] assemblies)
{

#if __ANDROID__ || __IOS__ || WINDOWS || MACCATALYST
#if __ANDROID__ || __IOS__ || WINDOWS || MACCATALYST || TIZEN

Internals.Registrar.RegisterAll(
assemblies,
Expand Down Expand Up @@ -86,7 +86,7 @@ public static IFontCollection AddCompatibilityFonts(this IFontCollection fontCol
public static IImageSourceServiceCollection AddCompatibilityServices(this IImageSourceServiceCollection services, params global::System.Reflection.Assembly[] assemblies)
{

#if __ANDROID__ || __IOS__ || WINDOWS || MACCATALYST
#if __ANDROID__ || __IOS__ || WINDOWS || MACCATALYST || TIZEN
Internals.Registrar.RegisterAll(
assemblies,
null,
Expand Down
100 changes: 0 additions & 100 deletions src/Compatibility/Core/src/RendererToHandlerShim.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,105 +29,5 @@ public override ERect GetNativeContentGeometry()
{
return VisualElementRenderer?.GetNativeContentGeometry() ?? new ERect();
}

//public static IViewHandler CreateShim(object renderer)
//{
// if (renderer is IViewHandler handler)
// return handler;

// if (renderer is IVisualElementRenderer ivr)
// return new RendererToHandlerShim(ivr);

// return new RendererToHandlerShim();
//}

//public RendererToHandlerShim() : base(ViewHandler.ViewMapper)
//{
//}

//public RendererToHandlerShim(IVisualElementRenderer visualElementRenderer) : this()
//{
// if (visualElementRenderer != null)
// SetupRenderer(visualElementRenderer);
//}

//public void SetupRenderer(IVisualElementRenderer visualElementRenderer)
//{
// VisualElementRenderer = visualElementRenderer;
// VisualElementRenderer.ElementChanged += OnElementChanged;

// if (VisualElementRenderer.Element is IView view)
// {
// view.Handler = this;
// SetVirtualView(view);
// }
// else if (VisualElementRenderer.Element != null)
// throw new Exception($"{VisualElementRenderer.Element} must implement: {nameof(IView)}");
//}

//void OnElementChanged(object sender, VisualElementChangedEventArgs e)
//{
// if (e.OldElement is IView view)
// view.Handler = null;

// if (e.NewElement is IView newView)
// {
// newView.Handler = this;
// this.SetVirtualView(newView);
// }
// else if (e.NewElement != null)
// throw new Exception($"{e.NewElement} must implement: {nameof(IView)}");
//}

//protected override EvasObject CreateNativeView()
//{
// return VisualElementRenderer.NativeView;
//}

//protected override void ConnectHandler(EvasObject nativeView)
//{
// base.ConnectHandler(nativeView);
// VirtualView.Handler = this;
//}

//protected override void DisconnectHandler(EvasObject nativeView)
//{
// Platform.Tizen.Platform.SetRenderer(VisualElementRenderer.Element, VisualElementRenderer);

// VisualElementRenderer.SetElement(null);

// base.DisconnectHandler(nativeView);
// VirtualView.Handler = null;
//}

//public override void SetVirtualView(IView view)
//{
// if (VisualElementRenderer == null)
// {
// var renderer = Internals.Registrar.Registered.GetHandlerForObject<IVisualElementRenderer>(view) ?? new DefaultRenderer();

// SetupRenderer(renderer);
// }

// if (VisualElementRenderer.Element != view)
// {
// VisualElementRenderer.SetElement((VisualElement)view);
// }
// else
// {
// base.SetVirtualView(view);
// }

// Platform.Tizen.Platform.SetRenderer(VisualElementRenderer.Element, VisualElementRenderer);
//}

//public override void UpdateValue(string property)
//{
// base.UpdateValue(property);
// if (property == "Frame")
// {
// NativeArrange(VisualElementRenderer.Element.Bounds);
// }
//}
}
}
12 changes: 0 additions & 12 deletions src/Compatibility/Core/src/Tizen/ExportCellAttribute.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Compatibility/Core/src/Tizen/ExportHandlerAttribute.cs

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions src/Compatibility/Core/src/Tizen/ExportRendererAttribute.cs

This file was deleted.

121 changes: 0 additions & 121 deletions src/Compatibility/Core/src/Tizen/Forms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
Device.SetIdiom(TargetIdiom.Unsupported);
}

if (options?.Flags.HasFlag(InitializationFlags.SkipRenderers) != true)
RegisterCompatRenderers(options);

Application.AccentColor = GetAccentColor(profile);
ExpressionSearch.Default = new TizenExpressionSearch();

Expand All @@ -511,124 +508,6 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
IsInitialized = true;
}

// Once we get essentials/cg converted to using startup.cs
// we will delete all the renderer code inside this file
internal static void RenderersRegistered()
{
IsInitializedRenderers = true;
}

internal static void RegisterCompatRenderers(InitializationOptions options)
{
if (!IsInitializedRenderers)
{
IsInitializedRenderers = true;
if (options != null)
{
s_platformType = options.PlatformType;
s_useMessagingCenter = options.UseMessagingCenter;
UseSkiaSharp = options.UseSkiaSharp;
UseFastLayout = options.UseFastLayout;

// renderers
if (options.Handlers != null)
{
Registrar.RegisterRenderers(options.Handlers);
}
else
{
// static registrar
if (options.StaticRegistarStrategy != StaticRegistrarStrategy.None)
{
s_staticRegistrarStrategy = options.StaticRegistarStrategy;
StaticRegistrar.RegisterHandlers(options.CustomHandlers);

if (options.StaticRegistarStrategy == StaticRegistrarStrategy.All)
{
Registrar.RegisterAll(new Type[]
{
typeof(ExportRendererAttribute),
typeof(ExportImageSourceHandlerAttribute),
typeof(ExportCellAttribute),
typeof(ExportHandlerAttribute),
typeof(ExportFontAttribute)
});

if (UseSkiaSharp)
RegisterSkiaSharpRenderers();
}
}
else
{
Registrar.RegisterAll(new Type[]
{
typeof(ExportRendererAttribute),
typeof(ExportImageSourceHandlerAttribute),
typeof(ExportCellAttribute),
typeof(ExportHandlerAttribute),
typeof(ExportFontAttribute)
});

if (UseSkiaSharp)
RegisterSkiaSharpRenderers();

if (UseFastLayout)
Registrar.Registered.Register(typeof(Layout), typeof(FastLayoutRenderer));
}
}

// effects
var effectScopes = options.EffectScopes;
if (effectScopes != null)
{
for (var i = 0; i < effectScopes.Length; i++)
{
var effectScope = effectScopes[0];
Registrar.RegisterEffects(effectScope.Name, effectScope.Effects);
}
}

// css
Registrar.RegisterStylesheets(options.Flags);
}
else
{
Registrar.RegisterAll(new Type[]
{
typeof(ExportRendererAttribute),
typeof(ExportImageSourceHandlerAttribute),
typeof(ExportCellAttribute),
typeof(ExportHandlerAttribute),
typeof(ExportFontAttribute)
});
}
}
}

internal static void RegisterCompatRenderers(
Assembly[] assemblies,
Assembly defaultRendererAssembly,
Action<Type> viewRegistered)
{
if (IsInitializedRenderers)
return;

IsInitializedRenderers = true;

// Only need to do this once
Controls.Internals.Registrar.RegisterAll(
assemblies,
defaultRendererAssembly,
new[] {
typeof(ExportRendererAttribute),
typeof(ExportImageSourceHandlerAttribute),
typeof(ExportCellAttribute),
typeof(ExportHandlerAttribute),
typeof(ExportFontAttribute)
}, default(InitializationFlags),
viewRegistered);
}

static void RegisterSkiaSharpRenderers()
{
// Register all skiasharp-based rednerers here.
Expand Down
Loading

0 comments on commit 7c87a7b

Please sign in to comment.