Skip to content

Commit

Permalink
Fix UpdateBackground (#194)
Browse files Browse the repository at this point in the history
* Fix UpdateBackground

* Add ContentView Background mapper

* Fix Editor/Entry/Label/Layout Background

* Add IWrapperViewCanvas.Content

* Add PageHandler Background mapper

* Restore WrapperView

* Remove unnecessary namespace
  • Loading branch information
sung-su authored and rookiejava committed Oct 12, 2021
1 parent e46280f commit 7ce50b2
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/Core/src/Handlers/ContentView/ContentViewHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public override void SetVirtualView(IView view)
NativeView.CrossPlatformArrange = VirtualView.CrossPlatformArrange;
}

public static void MapBackground(ContentViewHandler handler, IContentView view)
{
handler.UpdateValue(nameof(handler.ContainerView));
handler.GetWrappedNativeView()?.UpdateBackground(view);
}

public static void MapContent(ContentViewHandler handler, IContentView page)
{
handler.UpdateContent();
Expand Down
3 changes: 3 additions & 0 deletions src/Core/src/Handlers/ContentView/ContentViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public partial class ContentViewHandler
public static IPropertyMapper<IContentView, ContentViewHandler> ContentViewMapper = new PropertyMapper<IContentView, ContentViewHandler>(ViewMapper)
{
[nameof(IContentView.Content)] = MapContent,
#if TIZEN
[nameof(IContentView.Background)] = MapBackground,
#endif
};

public static CommandMapper<IPicker, PickerHandler> ContentViewCommandMapper = new(ViewCommandMapper)
Expand Down
6 changes: 6 additions & 0 deletions src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ protected override void DisconnectHandler(Entry nativeView)
nativeView.TextChanged -= OnTextChanged;
}

public static void MapBackground(EditorHandler handler, IEditor editor)
{
handler.UpdateValue(nameof(handler.ContainerView));
handler.GetWrappedNativeView()?.UpdateBackground(editor);
}

public static void MapText(EditorHandler handler, IEditor editor)
{
handler.NativeView?.UpdateText(editor);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Editor/EditorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public partial class EditorHandler
{
public static IPropertyMapper<IEditor, EditorHandler> EditorMapper = new PropertyMapper<IEditor, EditorHandler>(ViewHandler.ViewMapper)
{
#if __ANDROID__
#if __ANDROID__ || TIZEN
[nameof(IEditor.Background)] = MapBackground,
#endif
[nameof(IEditor.CharacterSpacing)] = MapCharacterSpacing,
Expand Down
6 changes: 6 additions & 0 deletions src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ protected override void DisconnectHandler(Entry nativeView)
nativeView.EntryLayoutUnfocused -= OnUnfocused;
}

public static void MapBackground(EntryHandler handler, IEntry entry)
{
handler.UpdateValue(nameof(handler.ContainerView));
handler.GetWrappedNativeView()?.UpdateBackground(entry);
}

public static void MapText(EntryHandler handler, IEntry entry)
{
handler.NativeView?.UpdateText(entry);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Entry/EntryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public partial class EntryHandler
{
public static IPropertyMapper<IEntry, EntryHandler> EntryMapper = new PropertyMapper<IEntry, EntryHandler>(ViewHandler.ViewMapper)
{
#if __ANDROID__
#if __ANDROID__ || TIZEN
[nameof(IEntry.Background)] = MapBackground,
#endif
[nameof(IEntry.CharacterSpacing)] = MapCharacterSpacing,
Expand Down
6 changes: 6 additions & 0 deletions src/Core/src/Handlers/Label/LabelHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ protected override Label CreateNativeView()
return label;
}

public static void MapBackground(LabelHandler handler, ILabel label)
{
handler.UpdateValue(nameof(handler.ContainerView));
handler.GetWrappedNativeView()?.UpdateBackground(label);
}

public static void MapText(LabelHandler handler, ILabel label)
{
handler.NativeView?.UpdateText(label);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Label/LabelHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public partial class LabelHandler
{
public static IPropertyMapper<ILabel, LabelHandler> LabelMapper = new PropertyMapper<ILabel, LabelHandler>(ViewHandler.ViewMapper)
{
#if WINDOWS || __IOS__
#if WINDOWS || __IOS__ || TIZEN
[nameof(ILabel.Background)] = MapBackground,
#endif
[nameof(ILabel.CharacterSpacing)] = MapCharacterSpacing,
Expand Down
4 changes: 4 additions & 0 deletions src/Core/src/Handlers/Layout/LayoutHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public LayoutHandler(IPropertyMapper? mapper = null, CommandMapper? commandMappe

public static void MapBackground(ILayoutHandler handler, ILayout layout)
{
#if TIZEN
handler.UpdateValue(nameof(handler.ContainerView));
handler.GetWrappedNativeView()?.UpdateBackground(layout);
#endif
((NativeView?)handler.NativeView)?.UpdateBackground(layout);
}

Expand Down
13 changes: 9 additions & 4 deletions src/Core/src/Handlers/Page/PageHandler.Tizen.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using Tizen.UIExtensions.Common;
using EColor = ElmSharp.Color;
using EColor = ElmSharp.Color;

namespace Microsoft.Maui.Handlers
{
public partial class PageHandler : ContentViewHandler
{
public static void MapTitle(PageHandler handler, IContentView page)
public static void MapBackground(PageHandler handler, IContentView page)
{
handler.UpdateValue(nameof(handler.ContainerView));
if (page.Background != null && handler.NativeView.BackgroundColor != EColor.Transparent)
{
handler.NativeView.BackgroundColor = EColor.Transparent;
}
handler.GetWrappedNativeView()?.UpdateBackground(page);
}

protected override ContentCanvas CreateNativeView()
public static void MapTitle(PageHandler handler, IContentView page)
{
var view = base.CreateNativeView();
view.BackgroundColor = (DeviceInfo.GetDeviceType() == DeviceType.TV) ? EColor.Transparent : EColor.White;
Expand Down
3 changes: 3 additions & 0 deletions src/Core/src/Handlers/Page/PageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ public partial class PageHandler : ContentViewHandler
{
public static IPropertyMapper<IContentView, PageHandler> PageMapper = new PropertyMapper<IContentView, PageHandler>(ContentViewMapper)
{
#if TIZEN
[nameof(IContentView.Background)] = MapBackground,
#endif
[nameof(ITitledElement.Title)] = MapTitle
};

Expand Down
5 changes: 0 additions & 5 deletions src/Core/src/Handlers/View/ViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,7 @@ public static void MapVisibility(IViewHandler handler, IView view)

public static void MapBackground(IViewHandler handler, IView view)
{
#if TIZEN
handler.UpdateValue(nameof(IViewHandler.ContainerView));
handler.GetWrappedNativeView()?.UpdateBackground(view);
#else
((NativeView?)handler.NativeView)?.UpdateBackground(view);
#endif
}

public static void MapFlowDirection(IViewHandler handler, IView view)
Expand Down

0 comments on commit 7ce50b2

Please sign in to comment.