Skip to content

Commit

Permalink
[Tizen] Refactor compat renderers (dotnet#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiejava authored and myroot committed Aug 25, 2022
1 parent 8c7ebb8 commit 87ce3c1
Show file tree
Hide file tree
Showing 17 changed files with 808 additions and 103 deletions.
16 changes: 0 additions & 16 deletions src/Compatibility/Core/src/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#elif TIZEN
using Microsoft.Maui.Controls.Compatibility.Platform.Tizen;
using Microsoft.Maui.Graphics.Skia;
using BoxRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.BoxViewRenderer;
using CollectionViewRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.StructuredItemsViewRenderer;
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;
Expand Down Expand Up @@ -101,29 +99,15 @@ public static MauiAppBuilder UseMauiCompatibility(this MauiAppBuilder builder)
#if TIZEN
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable CS0612 // Type or member is obsolete
handlers.TryAddCompatibilityRenderer(typeof(ContentView), typeof(LayoutRenderer));
handlers.TryAddCompatibilityRenderer(typeof(TabbedPage), typeof(TabbedPageRenderer));
handlers.TryAddCompatibilityRenderer(typeof(NavigationPage), typeof(NavigationPageRenderer));
handlers.TryAddCompatibilityRenderer(typeof(FlyoutPage), typeof(FlyoutPageRenderer));
handlers.TryAddCompatibilityRenderer(typeof(ListView), typeof(ListViewRenderer));
handlers.TryAddCompatibilityRenderer(typeof(Cell), typeof(CellRenderer));
handlers.TryAddCompatibilityRenderer(typeof(ImageCell), typeof(ImageCellRenderer));
handlers.TryAddCompatibilityRenderer(typeof(EntryCell), typeof(EntryCellRenderer));
handlers.TryAddCompatibilityRenderer(typeof(TextCell), typeof(TextCellRenderer));
handlers.TryAddCompatibilityRenderer(typeof(ViewCell), typeof(ViewCellRenderer));
handlers.TryAddCompatibilityRenderer(typeof(SwitchCell), typeof(SwitchCellRenderer));
handlers.TryAddCompatibilityRenderer(typeof(TableView), typeof(TableViewRenderer));
handlers.TryAddCompatibilityRenderer(typeof(Frame), typeof(FrameRenderer));
#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
#endif
// Shimmed renderers go directly to the registrar to load Image Handlers
Internals.Registrar.Registered.Register(typeof(FileImageSource), typeof(FileImageSourceHandler));
Internals.Registrar.Registered.Register(typeof(StreamImageSource), typeof(StreamImagesourceHandler));
Internals.Registrar.Registered.Register(typeof(UriImageSource), typeof(ImageLoaderSourceHandler));
#if !TIZEN
Internals.Registrar.Registered.Register(typeof(FontImageSource), typeof(FontImageSourceHandler));
#endif
Internals.Registrar.Registered.Register(typeof(Microsoft.Maui.EmbeddedFont), typeof(Microsoft.Maui.EmbeddedFontLoader));
#endif

Expand Down
68 changes: 1 addition & 67 deletions src/Compatibility/Core/src/Tizen/Renderers/DefaultRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<VisualElement>
}
}

[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class EllipseRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class LineRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class PathRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class PolygonRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class PolylineRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class RectangleRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class EntryRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class EditorRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ButtonRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class RadioButtonRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class SliderRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class WebViewRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class SearchBarRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class SwitchRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class SwipeViewRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class DatePickerRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class TimePickerRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class PickerRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class StepperRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ProgressBarRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ActivityIndicatorRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class CheckBoxRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class CarouselPageRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class FlyoutPageRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class RefreshViewRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ImageButtonRenderer : DefaultRenderer { }
#pragma warning disable CS0612 // Type or member is obsolete
public class NativeViewWrapperRenderer : DefaultRenderer { }
public class NativeViewWrapperRenderer : DefaultRenderer { }
#pragma warning restore CS0612 // Type or member is obsolete
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ShellRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class CellRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ImageCellRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class EntryCellRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class TextCellRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class ViewCellRenderer : DefaultRenderer { }
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class SwitchCellRenderer : DefaultRenderer { }
}
5 changes: 3 additions & 2 deletions src/Compatibility/Core/src/Tizen/Renderers/FrameRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Microsoft.Maui.Controls.Platform;
using System;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
using SkiaSharp;
using Tizen.NUI;
using Tizen.UIExtensions.NUI;

namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
[Obsolete("Use Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer instead")]
public class FrameRenderer : LayoutRenderer
{
static float s_borderWidth = 1.0f;
Expand Down
9 changes: 9 additions & 0 deletions src/Compatibility/Core/src/Tizen/Renderers/ImageRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Maui.Controls.Platform;
Expand Down Expand Up @@ -120,4 +121,12 @@ public sealed class StreamImageSourceHandler : IImageSourceHandler
return false;
}
}

public sealed class FontImageSourceHandler : IImageSourceHandler
{
public Task<bool> LoadImageAsync(NUIImage image, ImageSource imageSource, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotSupportedException($"FontImageSource: {imageSource}");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using Microsoft.Maui.Controls.Platform;
using Tizen.UIExtensions.NUI;
Expand All @@ -7,7 +8,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
[Obsolete("Use Microsoft.Maui.Controls.Platform.Compatibility.ListViewRenderer instead")]
public class ListViewRenderer : ViewRenderer<ListView, TCollectionView>
{
bool _isUpdateFromUI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable

using System;
using System.Linq;
using Microsoft.Maui.Controls.Platform;
using Tizen.NUI;
Expand All @@ -12,7 +13,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
[Obsolete("Use Microsoft.Maui.Controls.Platform.Compatibility.TabbedRenderer instead")]
public class TabbedPageRenderer : VisualElementRenderer<TabbedPage>
{
NCollectionView? _tabbedView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
[Obsolete("Use Microsoft.Maui.Controls.Platform.Compatibility.TableViewRenderer instead")]
public class TableViewRenderer : ViewRenderer<TableView, TCollectionView>
{
List<Cell> _items = new List<Cell>();
Expand Down
3 changes: 0 additions & 3 deletions src/Controls/samples/Controls.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public static MauiApp CreateMauiApp()
var appBuilder = MauiApp.CreateBuilder();

appBuilder.UseMauiApp<XamlApp>();
#if TIZEN
appBuilder.UseMauiCompatibility();
#endif
var services = appBuilder.Services;

if (UseMauiGraphicsSkia)
Expand Down
Loading

0 comments on commit 87ce3c1

Please sign in to comment.