Skip to content

Commit 7ce50b2

Browse files
sung-surookiejava
authored andcommitted
Fix UpdateBackground (#194)
* Fix UpdateBackground * Add ContentView Background mapper * Fix Editor/Entry/Label/Layout Background * Add IWrapperViewCanvas.Content * Add PageHandler Background mapper * Restore WrapperView * Remove unnecessary namespace
1 parent e46280f commit 7ce50b2

File tree

12 files changed

+46
-12
lines changed

12 files changed

+46
-12
lines changed

src/Core/src/Handlers/ContentView/ContentViewHandler.Tizen.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public override void SetVirtualView(IView view)
3939
NativeView.CrossPlatformArrange = VirtualView.CrossPlatformArrange;
4040
}
4141

42+
public static void MapBackground(ContentViewHandler handler, IContentView view)
43+
{
44+
handler.UpdateValue(nameof(handler.ContainerView));
45+
handler.GetWrappedNativeView()?.UpdateBackground(view);
46+
}
47+
4248
public static void MapContent(ContentViewHandler handler, IContentView page)
4349
{
4450
handler.UpdateContent();

src/Core/src/Handlers/ContentView/ContentViewHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ public partial class ContentViewHandler
66
public static IPropertyMapper<IContentView, ContentViewHandler> ContentViewMapper = new PropertyMapper<IContentView, ContentViewHandler>(ViewMapper)
77
{
88
[nameof(IContentView.Content)] = MapContent,
9+
#if TIZEN
10+
[nameof(IContentView.Background)] = MapBackground,
11+
#endif
912
};
1013

1114
public static CommandMapper<IPicker, PickerHandler> ContentViewCommandMapper = new(ViewCommandMapper)

src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ protected override void DisconnectHandler(Entry nativeView)
3333
nativeView.TextChanged -= OnTextChanged;
3434
}
3535

36+
public static void MapBackground(EditorHandler handler, IEditor editor)
37+
{
38+
handler.UpdateValue(nameof(handler.ContainerView));
39+
handler.GetWrappedNativeView()?.UpdateBackground(editor);
40+
}
41+
3642
public static void MapText(EditorHandler handler, IEditor editor)
3743
{
3844
handler.NativeView?.UpdateText(editor);

src/Core/src/Handlers/Editor/EditorHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public partial class EditorHandler
55
{
66
public static IPropertyMapper<IEditor, EditorHandler> EditorMapper = new PropertyMapper<IEditor, EditorHandler>(ViewHandler.ViewMapper)
77
{
8-
#if __ANDROID__
8+
#if __ANDROID__ || TIZEN
99
[nameof(IEditor.Background)] = MapBackground,
1010
#endif
1111
[nameof(IEditor.CharacterSpacing)] = MapCharacterSpacing,

src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ protected override void DisconnectHandler(Entry nativeView)
5454
nativeView.EntryLayoutUnfocused -= OnUnfocused;
5555
}
5656

57+
public static void MapBackground(EntryHandler handler, IEntry entry)
58+
{
59+
handler.UpdateValue(nameof(handler.ContainerView));
60+
handler.GetWrappedNativeView()?.UpdateBackground(entry);
61+
}
62+
5763
public static void MapText(EntryHandler handler, IEntry entry)
5864
{
5965
handler.NativeView?.UpdateText(entry);

src/Core/src/Handlers/Entry/EntryHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public partial class EntryHandler
77
{
88
public static IPropertyMapper<IEntry, EntryHandler> EntryMapper = new PropertyMapper<IEntry, EntryHandler>(ViewHandler.ViewMapper)
99
{
10-
#if __ANDROID__
10+
#if __ANDROID__ || TIZEN
1111
[nameof(IEntry.Background)] = MapBackground,
1212
#endif
1313
[nameof(IEntry.CharacterSpacing)] = MapCharacterSpacing,

src/Core/src/Handlers/Label/LabelHandler.Tizen.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ protected override Label CreateNativeView()
1717
return label;
1818
}
1919

20+
public static void MapBackground(LabelHandler handler, ILabel label)
21+
{
22+
handler.UpdateValue(nameof(handler.ContainerView));
23+
handler.GetWrappedNativeView()?.UpdateBackground(label);
24+
}
25+
2026
public static void MapText(LabelHandler handler, ILabel label)
2127
{
2228
handler.NativeView?.UpdateText(label);

src/Core/src/Handlers/Label/LabelHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public partial class LabelHandler
55
{
66
public static IPropertyMapper<ILabel, LabelHandler> LabelMapper = new PropertyMapper<ILabel, LabelHandler>(ViewHandler.ViewMapper)
77
{
8-
#if WINDOWS || __IOS__
8+
#if WINDOWS || __IOS__ || TIZEN
99
[nameof(ILabel.Background)] = MapBackground,
1010
#endif
1111
[nameof(ILabel.CharacterSpacing)] = MapCharacterSpacing,

src/Core/src/Handlers/Layout/LayoutHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public LayoutHandler(IPropertyMapper? mapper = null, CommandMapper? commandMappe
4343

4444
public static void MapBackground(ILayoutHandler handler, ILayout layout)
4545
{
46+
#if TIZEN
47+
handler.UpdateValue(nameof(handler.ContainerView));
48+
handler.GetWrappedNativeView()?.UpdateBackground(layout);
49+
#endif
4650
((NativeView?)handler.NativeView)?.UpdateBackground(layout);
4751
}
4852

src/Core/src/Handlers/Page/PageHandler.Tizen.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
using Tizen.UIExtensions.Common;
2-
using EColor = ElmSharp.Color;
1+
using EColor = ElmSharp.Color;
32

43
namespace Microsoft.Maui.Handlers
54
{
65
public partial class PageHandler : ContentViewHandler
76
{
8-
public static void MapTitle(PageHandler handler, IContentView page)
7+
public static void MapBackground(PageHandler handler, IContentView page)
98
{
9+
handler.UpdateValue(nameof(handler.ContainerView));
10+
if (page.Background != null && handler.NativeView.BackgroundColor != EColor.Transparent)
11+
{
12+
handler.NativeView.BackgroundColor = EColor.Transparent;
13+
}
14+
handler.GetWrappedNativeView()?.UpdateBackground(page);
1015
}
1116

12-
protected override ContentCanvas CreateNativeView()
17+
public static void MapTitle(PageHandler handler, IContentView page)
1318
{
1419
var view = base.CreateNativeView();
1520
view.BackgroundColor = (DeviceInfo.GetDeviceType() == DeviceType.TV) ? EColor.Transparent : EColor.White;

0 commit comments

Comments
 (0)