Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[net6.0] [Tizen] Add requesting re-layout step #12434

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Core/src/Handlers/ScrollView/ScrollViewHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ void OnContentLayoutUpdated(object? sender, Tizen.UIExtensions.Common.LayoutEven

void OnContentLayoutUpdated()
{
var viewGroup = _contentHandler?.PlatformView as LayoutViewGroup;
if (viewGroup != null)
{
viewGroup.IsLayoutUpdating++;
}

var platformGeometry = PlatformView.GetBounds().ToDP();
var measuredSize = VirtualView.CrossPlatformMeasure(platformGeometry.Width, platformGeometry.Height);

Expand All @@ -115,6 +121,11 @@ void OnContentLayoutUpdated()
UpdateContentSize();
}
_measureCache = measuredSize;

if (viewGroup != null)
{
viewGroup.IsLayoutUpdating--;
}
}

public static void MapContent(IScrollViewHandler handler, IScrollView scrollView)
Expand Down
7 changes: 7 additions & 0 deletions src/Core/src/Platform/Tizen/LayoutViewGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class LayoutViewGroup : ViewGroup, IMeasurable
Size _measureCache;

bool _needMeasureUpdate;
internal int IsLayoutUpdating { get; set; } = 0;

public LayoutViewGroup(IView view)
{
Expand All @@ -28,6 +29,10 @@ public void SetNeedMeasureUpdate()
{
_needMeasureUpdate = true;
MarkChanged();
if (IsLayoutUpdating == 0)
{
Layout.RequestLayout();
}
}

public void ClearNeedMeasureUpdate()
Expand Down Expand Up @@ -64,6 +69,7 @@ public Size InvokeCrossPlatformMeasure(double availableWidth, double availableHe

void OnLayoutUpdated(object? sender, LayoutEventArgs e)
{
IsLayoutUpdating++;
var platformGeometry = this.GetBounds().ToDP();

if (_needMeasureUpdate || _measureCache != platformGeometry.Size)
Expand All @@ -76,6 +82,7 @@ void OnLayoutUpdated(object? sender, LayoutEventArgs e)
platformGeometry.Y = 0;
CrossPlatformArrange?.Invoke(platformGeometry);
}
IsLayoutUpdating--;
}
}
}