diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
index d4b53136c417..61fc589df4f3 100644
--- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
+++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml
@@ -4,4 +4,23 @@
x:Class="Maui.Controls.Sample.MainPage"
xmlns:local="clr-namespace:Maui.Controls.Sample">
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
index effdbcdb46d7..e44cb787916d 100644
--- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
+++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml.cs
@@ -14,5 +14,24 @@ public MainPage()
{
InitializeComponent();
}
+
+ private void Button_Clicked(object sender, EventArgs e)
+ {
+ Cross.IsVisible = !Cross.IsVisible;
+ }
+ }
+
+ public sealed class CrossDrawable : IDrawable
+ {
+ public void Draw(ICanvas canvas, RectF dirtyRect)
+ {
+ canvas.StrokeColor = Colors.Red;
+
+ // horizontal line
+ canvas.DrawLine(0, dirtyRect.Height / 2, dirtyRect.Width, dirtyRect.Height / 2);
+
+ // vertical line
+ canvas.DrawLine(dirtyRect.Width / 2, 0, dirtyRect.Width / 2, dirtyRect.Height);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs b/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs
index 1abce2d90178..4bf406baa27a 100644
--- a/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs
+++ b/src/Core/src/Handlers/ActivityIndicator/ActivityIndicatorHandler.Windows.cs
@@ -17,7 +17,7 @@ public partial class ActivityIndicatorHandler : ViewHandler ContainerAffectingProperties { get; }
+ }
}
\ No newline at end of file
diff --git a/src/Core/src/Handlers/Image/ImageHandler.Android.cs b/src/Core/src/Handlers/Image/ImageHandler.Android.cs
index e10e19f3b864..85d04831ea20 100644
--- a/src/Core/src/Handlers/Image/ImageHandler.Android.cs
+++ b/src/Core/src/Handlers/Image/ImageHandler.Android.cs
@@ -32,7 +32,7 @@ protected override void DisconnectHandler(ImageView platformView)
public static void MapBackground(IImageHandler handler, IImage image)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(image);
handler.ToPlatform().UpdateOpacity(image);
diff --git a/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs b/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs
index 3ad22785be1d..c3bb8d525a9a 100644
--- a/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs
+++ b/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs
@@ -21,7 +21,7 @@ protected override void DisconnectHandler(Image platformView)
public static void MapBackground(IImageHandler handler, IImage image)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform()?.UpdateBackground(image);
}
diff --git a/src/Core/src/Handlers/Image/ImageHandler.Windows.cs b/src/Core/src/Handlers/Image/ImageHandler.Windows.cs
index 3d65a70822a0..a3d308727408 100644
--- a/src/Core/src/Handlers/Image/ImageHandler.Windows.cs
+++ b/src/Core/src/Handlers/Image/ImageHandler.Windows.cs
@@ -22,7 +22,7 @@ protected override void DisconnectHandler(Image platformView)
public static void MapBackground(IImageHandler handler, IImage image)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(image);
}
diff --git a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs
index 5159b75814fa..97d5ad49659e 100644
--- a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs
+++ b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs
@@ -35,7 +35,7 @@ protected override void DisconnectHandler(UIImageView platformView)
public static void MapBackground(IImageHandler handler, IImage image)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(image);
}
diff --git a/src/Core/src/Handlers/Label/LabelHandler.Windows.cs b/src/Core/src/Handlers/Label/LabelHandler.Windows.cs
index 2cf6e715a2f4..dcad5c8d83e2 100644
--- a/src/Core/src/Handlers/Label/LabelHandler.Windows.cs
+++ b/src/Core/src/Handlers/Label/LabelHandler.Windows.cs
@@ -36,14 +36,14 @@ public static void MapHeight(ILabelHandler handler, ILabel view) =>
public static void MapBackground(ILabelHandler handler, ILabel label)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(label);
}
public static void MapOpacity(ILabelHandler handler, ILabel label)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Opacity));
handler.PlatformView.UpdateOpacity(label);
handler.ToPlatform().UpdateOpacity(label);
}
@@ -69,7 +69,7 @@ public static void MapHorizontalTextAlignment(ILabelHandler handler, ILabel labe
public static void MapVerticalTextAlignment(ILabelHandler handler, ILabel label)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(ILabel.VerticalTextAlignment));
handler.PlatformView?.UpdateVerticalTextAlignment(label);
}
diff --git a/src/Core/src/Handlers/Label/LabelHandler.iOS.cs b/src/Core/src/Handlers/Label/LabelHandler.iOS.cs
index 405dc5016577..aa057138d7cb 100644
--- a/src/Core/src/Handlers/Label/LabelHandler.iOS.cs
+++ b/src/Core/src/Handlers/Label/LabelHandler.iOS.cs
@@ -15,7 +15,7 @@ public partial class LabelHandler : ViewHandler
public static void MapBackground(ILabelHandler handler, ILabel label)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(label);
}
diff --git a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Android.cs b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Android.cs
index 4436fefcc636..811f238af211 100644
--- a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Android.cs
+++ b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Android.cs
@@ -11,7 +11,7 @@ protected override MauiShapeView CreatePlatformView()
public static void MapBackground(IShapeViewHandler handler, IShapeView shapeView)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(shapeView);
handler.PlatformView?.InvalidateShape(shapeView);
diff --git a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Windows.cs b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Windows.cs
index f7bb6678b4b2..770903a3e30f 100644
--- a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Windows.cs
+++ b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Windows.cs
@@ -13,7 +13,7 @@ protected override W2DGraphicsView CreatePlatformView()
public static void MapBackground(IShapeViewHandler handler, IShapeView shapeView)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(shapeView);
handler.PlatformView?.InvalidateShape(shapeView);
diff --git a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.iOS.cs b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.iOS.cs
index 45c47db79090..7a1494f8c505 100644
--- a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.iOS.cs
+++ b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.iOS.cs
@@ -13,7 +13,7 @@ protected override MauiShapeView CreatePlatformView()
public static void MapBackground(IShapeViewHandler handler, IShapeView shapeView)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Background));
handler.ToPlatform().UpdateBackground(shapeView);
handler.PlatformView?.InvalidateShape(shapeView);
diff --git a/src/Core/src/Handlers/View/AndroidBatchPropertyMapper.cs b/src/Core/src/Handlers/View/AndroidBatchPropertyMapper.cs
index 60d71571646f..c8e3677e9954 100644
--- a/src/Core/src/Handlers/View/AndroidBatchPropertyMapper.cs
+++ b/src/Core/src/Handlers/View/AndroidBatchPropertyMapper.cs
@@ -11,7 +11,6 @@ class AndroidBatchPropertyMapper : PropertyMapper SkipList = new(StringComparer.Ordinal)
{
- nameof(IView.Visibility),
nameof(IView.MinimumHeight),
nameof(IView.MinimumWidth),
nameof(IView.IsEnabled),
diff --git a/src/Core/src/Handlers/View/ViewHandler.cs b/src/Core/src/Handlers/View/ViewHandler.cs
index cbf40d7f0721..a378e7a8cdd1 100644
--- a/src/Core/src/Handlers/View/ViewHandler.cs
+++ b/src/Core/src/Handlers/View/ViewHandler.cs
@@ -1,3 +1,6 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
using Microsoft.Maui.Graphics;
#if __IOS__ || MACCATALYST
using PlatformView = UIKit.UIView;
@@ -13,7 +16,7 @@
namespace Microsoft.Maui.Handlers
{
- public abstract partial class ViewHandler : ElementHandler, IViewHandler
+ public abstract partial class ViewHandler : ElementHandler, IViewHandler, IDynamicContainerViewHandler
{
public static IPropertyMapper ViewMapper =
#if ANDROID
@@ -48,6 +51,7 @@ public abstract partial class ViewHandler : ElementHandler, IViewHandler
[nameof(IView.RotationY)] = MapRotationY,
[nameof(IView.AnchorX)] = MapAnchorX,
[nameof(IView.AnchorY)] = MapAnchorY,
+ [nameof(IDynamicContainerViewHandler.NeedsContainer)] = MapNeedsContainer,
[nameof(IViewHandler.ContainerView)] = MapContainerView,
[nameof(IBorder.Border)] = MapBorderView,
#if ANDROID || WINDOWS || TIZEN
@@ -70,14 +74,18 @@ public abstract partial class ViewHandler : ElementHandler, IViewHandler
};
bool _hasContainer;
+ readonly CollectionWithEvents _changesContainer = new();
internal DataFlowDirection DataFlowDirection { get; set; }
protected ViewHandler(IPropertyMapper mapper, CommandMapper? commandMapper = null)
: base(mapper, commandMapper ?? ViewCommandMapper)
{
+ _changesContainer.Changed += OnChangedContainerCollectionChanged;
}
+ ICollection IDynamicContainerViewHandler.ContainerAffectingProperties => _changesContainer;
+
public bool HasContainer
{
get => _hasContainer;
@@ -92,12 +100,33 @@ public bool HasContainer
SetupContainer();
else
RemoveContainer();
+
+ UpdateValue(nameof(IViewHandler.ContainerView));
}
}
public virtual bool NeedsContainer
{
- get => VirtualView.NeedsContainer();
+ get
+ {
+#if !TIZEN
+ if (VirtualView?.Clip is not null || VirtualView?.Shadow is not null)
+ return true;
+#endif
+#if ANDROID
+ if (VirtualView?.InputTransparent == true)
+ return true;
+#endif
+#if ANDROID || IOS
+ if (VirtualView is IBorder border)
+ return border.Border is not null;
+#endif
+#if WINDOWS || TIZEN
+ if (VirtualView is IBorderView border)
+ return border?.Shape is not null || border?.Stroke is not null;
+#endif
+ return false;
+ }
}
protected abstract void SetupContainer();
@@ -201,10 +230,24 @@ public static void MapIsEnabled(IViewHandler handler, IView view)
public static void MapVisibility(IViewHandler handler, IView view)
{
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Visibility));
+#if WINDOWS
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Opacity));
+#endif
+
if (handler.HasContainer)
+ {
((PlatformView?)handler.ContainerView)?.UpdateVisibility(view);
+#if WINDOWS
+ ((PlatformView?)handler.PlatformView)?.UpdateVisibility(Visibility.Visible, view.Opacity);
+#else
+ ((PlatformView?)handler.PlatformView)?.UpdateVisibility(Visibility.Visible);
+#endif
+ }
else
+ {
((PlatformView?)handler.PlatformView)?.UpdateVisibility(view);
+ }
}
public static void MapBackground(IViewHandler handler, IView view)
@@ -232,10 +275,24 @@ public static void MapFlowDirection(IViewHandler handler, IView view)
public static void MapOpacity(IViewHandler handler, IView view)
{
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Opacity));
+#if WINDOWS
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Visibility));
+#endif
+
if (handler.HasContainer)
+ {
((PlatformView?)handler.ContainerView)?.UpdateOpacity(view);
+#if WINDOWS
+ ((PlatformView?)handler.PlatformView)?.UpdateOpacity(1.0, view.Visibility);
+#else
+ ((PlatformView?)handler.PlatformView)?.UpdateOpacity(1.0);
+#endif
+ }
else
+ {
((PlatformView?)handler.PlatformView)?.UpdateOpacity(view);
+ }
}
public static void MapAutomationId(IViewHandler handler, IView view)
@@ -245,14 +302,14 @@ public static void MapAutomationId(IViewHandler handler, IView view)
public static void MapClip(IViewHandler handler, IView view)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Clip));
((PlatformView?)handler.ContainerView)?.UpdateClip(view);
}
public static void MapShadow(IViewHandler handler, IView view)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.Shadow));
((PlatformView?)handler.ContainerView)?.UpdateShadow(view);
}
@@ -270,27 +327,24 @@ public static void MapInvalidateMeasure(IViewHandler handler, IView view, object
(handler.PlatformView as PlatformView)?.InvalidateMeasure(view);
}
- public static void MapContainerView(IViewHandler handler, IView view)
+ public static void MapNeedsContainer(IViewHandler handler, IView view)
{
- if (handler is ViewHandler viewHandler)
- handler.HasContainer = viewHandler.NeedsContainer;
- else
- handler.HasContainer = view.NeedsContainer();
-
- UpdateInputTransparentOnContainerView(handler, view);
+ if (handler is IDynamicContainerViewHandler dyn && dyn.HasContainer != dyn.NeedsContainer)
+ dyn.HasContainer = dyn.NeedsContainer;
}
- static void UpdateInputTransparentOnContainerView(IViewHandler handler, IView view)
+ public static void MapContainerView(IViewHandler handler, IView view)
{
-#if ANDROID
- if (handler.ContainerView is WrapperView wrapper)
- wrapper.InputTransparent = view.InputTransparent;
-#endif
+ if (handler is IDynamicContainerViewHandler dyn)
+ {
+ foreach (var map in dyn.ContainerAffectingProperties)
+ handler.UpdateValue(map);
+ }
}
public static void MapBorderView(IViewHandler handler, IView view)
{
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IBorder.Border));
((PlatformView?)handler.ContainerView)?.UpdateBorder(view);
}
@@ -326,10 +380,10 @@ public static void MapFocus(IViewHandler handler, IView view, object? args)
public static void MapInputTransparent(IViewHandler handler, IView view)
{
#if ANDROID
- handler.UpdateValue(nameof(IViewHandler.ContainerView));
- UpdateInputTransparentOnContainerView(handler, view);
+ (handler as IDynamicContainerViewHandler)?.ContainerAffectingProperties?.Add(nameof(IView.InputTransparent));
+ ((PlatformView?)handler.ContainerView)?.UpdateInputTransparent(view);
#else
- ((PlatformView?)handler.PlatformView)?.UpdateInputTransparent(handler, view);
+ ((PlatformView?)handler.PlatformView)?.UpdateInputTransparent(view);
#endif
}
@@ -345,5 +399,52 @@ public static void MapToolTip(IViewHandler handler, IView view)
handler.ToPlatform().UpdateToolTip(tooltipContainer.ToolTip);
#endif
}
+
+ void OnChangedContainerCollectionChanged(object? sender, EventArgs e) =>
+ UpdateValue(nameof(IDynamicContainerViewHandler.NeedsContainer));
+
+ class CollectionWithEvents : ICollection
+ {
+ HashSet properties = new();
+
+ public event EventHandler? Changed;
+
+ public int Count => properties.Count;
+
+ public bool IsReadOnly => false;
+
+ public void Add(string item)
+ {
+ if (properties.Add(item))
+ Changed?.Invoke(this, EventArgs.Empty);
+ }
+
+ public void Clear()
+ {
+ if (properties.Count > 0)
+ {
+ properties.Clear();
+ Changed?.Invoke(this, EventArgs.Empty);
+ }
+ }
+
+ public bool Contains(string item) => properties.Contains(item);
+
+ public void CopyTo(string[] array, int arrayIndex) => properties.CopyTo(array, arrayIndex);
+
+ public IEnumerator GetEnumerator() => properties.GetEnumerator();
+
+ public bool Remove(string item)
+ {
+ if (properties.Remove(item))
+ {
+ Changed?.Invoke(this, EventArgs.Empty);
+ return true;
+ }
+ return false;
+ }
+
+ IEnumerator IEnumerable.GetEnumerator() => properties.GetEnumerator();
+ }
}
}
diff --git a/src/Core/src/Platform/Android/ViewExtensions.cs b/src/Core/src/Platform/Android/ViewExtensions.cs
index 296faecb4d1e..6c8048779dc0 100644
--- a/src/Core/src/Platform/Android/ViewExtensions.cs
+++ b/src/Core/src/Platform/Android/ViewExtensions.cs
@@ -26,20 +26,10 @@ public static void Initialize(this AView platformView, IView view)
{
var pivotX = (float)(view.AnchorX * platformView.ToPixels(view.Frame.Width));
var pivotY = (float)(view.AnchorY * platformView.ToPixels(view.Frame.Height));
- int visibility;
-
- if (view is IActivityIndicator a)
- {
- visibility = (int)a.GetActivityIndicatorVisibility();
- }
- else
- {
- visibility = (int)view.Visibility.ToPlatformVisibility();
- }
// NOTE: use named arguments for clarity
PlatformInterop.Set(platformView,
- visibility: visibility,
+ visibility: 0,
layoutDirection: (int)GetLayoutDirection(view),
minimumHeight: (int)platformView.ToPixels(view.MinimumHeight),
minimumWidth: (int)platformView.ToPixels(view.MinimumWidth),
@@ -91,9 +81,12 @@ public static void Unfocus(this AView platformView, IView view)
platformView.ClearFocus();
}
- public static void UpdateVisibility(this AView platformView, IView view)
+ public static void UpdateVisibility(this AView platformView, IView view) =>
+ ViewExtensions.UpdateVisibility(platformView, view.Visibility);
+
+ public static void UpdateVisibility(this AView platformView, Visibility visibility)
{
- platformView.Visibility = view.Visibility.ToPlatformVisibility();
+ platformView.Visibility = visibility.ToPlatformVisibility();
}
public static void UpdateClip(this AView platformView, IView view)
@@ -107,6 +100,13 @@ public static void UpdateShadow(this AView platformView, IView view)
if (platformView is WrapperView wrapper)
wrapper.Shadow = view.Shadow;
}
+
+ public static void UpdateInputTransparent(this AView platformView, IView view)
+ {
+ if (platformView is WrapperView wrapper)
+ wrapper.InputTransparent = view.InputTransparent;
+ }
+
public static void UpdateBorder(this AView platformView, IView view)
{
if (platformView is WrapperView wrapper)
@@ -236,9 +236,12 @@ internal static void UpdateBackground(this AView platformView, Paint? background
}
}
- public static void UpdateOpacity(this AView platformView, IView view)
+ public static void UpdateOpacity(this AView platformView, IView view) =>
+ ViewExtensions.UpdateOpacity(platformView, view.Opacity);
+
+ public static void UpdateOpacity(this AView platformView, double opacity)
{
- platformView.Alpha = (float)view.Opacity;
+ platformView.Alpha = (float)opacity;
}
public static void UpdateFlowDirection(this AView platformView, IView view)
diff --git a/src/Core/src/Platform/Standard/ViewExtensions.cs b/src/Core/src/Platform/Standard/ViewExtensions.cs
index 6745888fb93d..155104b59511 100644
--- a/src/Core/src/Platform/Standard/ViewExtensions.cs
+++ b/src/Core/src/Platform/Standard/ViewExtensions.cs
@@ -12,6 +12,8 @@ public static void Unfocus(this object platformView, IView view) { }
public static void UpdateVisibility(this object platformView, IView view) { }
+ public static void UpdateVisibility(this object platformView, Visibility visibility) { }
+
public static Task UpdateBackgroundImageSourceAsync(this object platformView, IImageSource? imageSource, IImageSourceServiceProvider? provider)
=> Task.CompletedTask;
@@ -29,6 +31,8 @@ public static void UpdateBorder(this object platformView, IView view) { }
public static void UpdateOpacity(this object platformView, IView view) { }
+ public static void UpdateOpacity(this object platformView, double opacity) { }
+
public static void UpdateSemantics(this object platformView, IView view) { }
public static void UpdateFlowDirection(this object platformView, IView view) { }
@@ -78,5 +82,7 @@ public static void UpdateMaximumWidth(this object platformView, IView view) { }
=> null;
public static void UpdateInputTransparent(this object nativeView, IViewHandler handler, IView view) { }
+
+ public static void UpdateInputTransparent(this object nativeView, IView view) { }
}
}
diff --git a/src/Core/src/Platform/Tizen/ViewExtensions.cs b/src/Core/src/Platform/Tizen/ViewExtensions.cs
index cdcb7a1bf141..e846023f6733 100644
--- a/src/Core/src/Platform/Tizen/ViewExtensions.cs
+++ b/src/Core/src/Platform/Tizen/ViewExtensions.cs
@@ -30,9 +30,12 @@ public static void Unfocus(this NView platformView, IView view)
Tizen.NUI.FocusManager.Instance.ClearFocus();
}
- public static void UpdateVisibility(this NView platformView, IView view)
+ public static void UpdateVisibility(this NView platformView, IView view) =>
+ ViewExtensions.UpdateVisibility(platformView, view.Visibility);
+
+ public static void UpdateVisibility(this NView platformView, Visibility visibility)
{
- if (view.Visibility.ToPlatformVisibility())
+ if (visibility.ToPlatformVisibility())
{
platformView.Show();
platformView.Layout?.RequestLayout();
@@ -134,9 +137,12 @@ public static void UpdateBorder(this NView platformView, IView view)
wrapperView.Border = border.Border;
}
- public static void UpdateOpacity(this NView platformView, IView view)
+ public static void UpdateOpacity(this NView platformView, IView view) =>
+ ViewExtensions.UpdateOpacity(platformView, view.Opacity);
+
+ public static void UpdateOpacity(this NView platformView, double opacity)
{
- platformView.Opacity = (float)view.Opacity;
+ platformView.Opacity = (float)opacity;
}
public static void UpdateClip(this NView platformView, IView view)
@@ -215,7 +221,10 @@ public static void UpdateMaximumHeight(this NView platformView, IView view)
// NUI MaximumSize is not working properly
}
- public static void UpdateInputTransparent(this NView platformView, IViewHandler handler, IView view)
+ public static void UpdateInputTransparent(this NView platformView, IViewHandler handler, IView view) =>
+ UpdateInputTransparent(platformView, view);
+
+ public static void UpdateInputTransparent(this NView platformView, IView view)
{
platformView.Sensitive = !view.InputTransparent;
}
@@ -333,13 +342,5 @@ internal static IDisposable OnUnloaded(this NView view, Action action)
view.RemovedFromWindow += routedEventHandler;
return disposable;
}
-
- internal static bool NeedsContainer(this IView? view)
- {
- if (view is IBorderView border)
- return border?.Shape != null || border?.Stroke != null;
-
- return false;
- }
}
}
diff --git a/src/Core/src/Platform/Windows/ViewExtensions.cs b/src/Core/src/Platform/Windows/ViewExtensions.cs
index 2120a2c944e9..7212f1f4ba56 100644
--- a/src/Core/src/Platform/Windows/ViewExtensions.cs
+++ b/src/Core/src/Platform/Windows/ViewExtensions.cs
@@ -41,12 +41,14 @@ public static void Unfocus(this FrameworkElement platformView, IView view)
UnfocusControl(control);
}
- public static void UpdateVisibility(this FrameworkElement platformView, IView view)
+ public static void UpdateVisibility(this FrameworkElement platformView, IView view) =>
+ ViewExtensions.UpdateVisibility(platformView, view.Visibility, view.Opacity);
+
+ public static void UpdateVisibility(this FrameworkElement platformView, Visibility visibility, double opacity)
{
- double opacity = view.Opacity;
var wasCollapsed = platformView.Visibility == UI.Xaml.Visibility.Collapsed;
- switch (view.Visibility)
+ switch (visibility)
{
case Visibility.Visible:
platformView.Opacity = opacity;
@@ -62,7 +64,7 @@ public static void UpdateVisibility(this FrameworkElement platformView, IView vi
break;
}
- if (view.Visibility != Visibility.Collapsed && wasCollapsed)
+ if (visibility != Visibility.Collapsed && wasCollapsed)
{
// We may need to force the parent layout (if any) to re-layout to accomodate the new size
(platformView.Parent as FrameworkElement)?.InvalidateMeasure();
@@ -92,9 +94,12 @@ public static void UpdateBorder(this FrameworkElement platformView, IView view)
wrapperView.Border = border;
}
- public static void UpdateOpacity(this FrameworkElement platformView, IView view)
+ public static void UpdateOpacity(this FrameworkElement platformView, IView view) =>
+ ViewExtensions.UpdateOpacity(platformView, view.Opacity, view.Visibility);
+
+ public static void UpdateOpacity(this FrameworkElement platformView, double opacity, Visibility visibility)
{
- platformView.Opacity = view.Visibility == Visibility.Hidden ? 0 : view.Opacity;
+ platformView.Opacity = visibility == Visibility.Hidden ? 0 : opacity;
}
public static void UpdateBackground(this ContentPanel platformView, IBorderStroke border)
@@ -420,7 +425,10 @@ internal static void UnfocusControl(Control control)
return null;
}
- public static void UpdateInputTransparent(this FrameworkElement nativeView, IViewHandler handler, IView view)
+ public static void UpdateInputTransparent(this FrameworkElement nativeView, IViewHandler handler, IView view) =>
+ UpdateInputTransparent(nativeView, view);
+
+ public static void UpdateInputTransparent(this FrameworkElement nativeView, IView view)
{
if (nativeView is UIElement element)
{
diff --git a/src/Core/src/Platform/iOS/ViewExtensions.cs b/src/Core/src/Platform/iOS/ViewExtensions.cs
index c8c86c527622..917985bc99d4 100644
--- a/src/Core/src/Platform/iOS/ViewExtensions.cs
+++ b/src/Core/src/Platform/iOS/ViewExtensions.cs
@@ -199,9 +199,12 @@ static void PropagateFlowDirection(UISemanticContentAttribute semanticContentAtt
}
}
- public static void UpdateOpacity(this UIView platformView, IView view)
+ public static void UpdateOpacity(this UIView platformView, IView view) =>
+ ViewExtensions.UpdateOpacity(platformView, view.Opacity);
+
+ public static void UpdateOpacity(this UIView platformView, double opacity)
{
- platformView.Alpha = (float)view.Opacity;
+ platformView.Alpha = (float)opacity;
}
public static void UpdateAutomationId(this UIView platformView, IView view) =>
@@ -523,7 +526,10 @@ internal static Size LayoutToMeasuredSize(this IView view, double width, double
return size;
}
- public static void UpdateInputTransparent(this UIView platformView, IViewHandler handler, IView view)
+ public static void UpdateInputTransparent(this UIView platformView, IViewHandler handler, IView view) =>
+ UpdateInputTransparent(platformView, view);
+
+ public static void UpdateInputTransparent(this UIView platformView, IView view)
{
if (view is ITextInput textInput)
{
diff --git a/src/Core/src/ViewExtensions.cs b/src/Core/src/ViewExtensions.cs
index 75cc700f25f7..d99da8b2bbef 100644
--- a/src/Core/src/ViewExtensions.cs
+++ b/src/Core/src/ViewExtensions.cs
@@ -47,28 +47,5 @@ public static partial class ViewExtensions
async static Task CaptureAsync(PlatformView window) =>
await Screenshot.Default.CaptureAsync(window);
#endif
-
-#if !TIZEN
- internal static bool NeedsContainer(this IView? view)
- {
- if (view?.Clip != null || view?.Shadow != null)
- return true;
-
-#if ANDROID
- if (view?.InputTransparent == true)
- return true;
-#endif
-
-#if ANDROID || IOS
- if (view is IBorder border && border.Border != null)
- return true;
-#elif WINDOWS
- if (view is IBorderView border)
- return border?.Shape != null || border?.Stroke != null;
-#endif
- return false;
- }
-#endif
-
}
}