Skip to content

Commit 420a69e

Browse files
Merge branch 'main' of https://github.com/syncfusion/maui-toolkit into internal_public
# Conflicts: # maui/src/BottomSheet/SfBottomSheet.cs # maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Navigation/SfBottomSheetUnitTests.cs
2 parents d3c77a6 + dbe5e9a commit 420a69e

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

maui/src/BottomSheet/SfBottomSheet.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ public bool CollapseOnOverlayTap
12011201
}
12021202

12031203
/// <summary>
1204-
/// Gets or sets a value that can be used to adjust the duration of the opening and closing animations.
1204+
/// Gets or sets the duration, in milliseconds, for the opening and closing animations.
12051205
/// </summary>
12061206
/// <value>
12071207
/// It accepts double values, and the default value is 150ms.
@@ -1287,9 +1287,12 @@ public void Close()
12871287
}
12881288

12891289
/// <summary>
1290-
/// Updates the animation duration with the given value.
1290+
/// Returns the value of <c>AnimationDuration</c>, ensuring it is clamped to a non-negative integer.
1291+
/// This method is useful when passing the duration to animation APIs that require a <c>uint</c> value,
1292+
/// preventing issues caused by negative durations.
12911293
/// </summary>
1292-
int SetAnimationDuration()
1294+
/// <returns>A non-negative integer representing the animation duration.</returns>
1295+
int GetClampedAnimationDuration()
12931296
{
12941297
return (int)Math.Max(0, AnimationDuration);
12951298
}
@@ -2135,13 +2138,13 @@ void AnimateBottomSheet(double targetPosition, Action? onFinish = null)
21352138
_overlayGrid.AbortAnimation("overlayGridAnimation");
21362139
}
21372140

2138-
int animationDuration =this.SetAnimationDuration();
2139-
const int topPadding = 2;
2141+
int animationDuration = this.GetClampedAnimationDuration();
2142+
const int topPadding = 2;
21402143
_isSheetOpen = true;
21412144
if (_bottomSheet is not null)
21422145
{
21432146
var bottomSheetAnimation = new Animation(d => _bottomSheet.TranslationY = d, _bottomSheet.TranslationY, targetPosition + topPadding);
2144-
_bottomSheet?.Animate("bottomSheetAnimation", bottomSheetAnimation, length: (uint)animationDuration, easing: Easing.Linear, finished: (v, e) =>
2147+
_bottomSheet?.Animate("bottomSheetAnimation", bottomSheetAnimation, length: (uint)animationDuration, easing: Easing.Linear, finished: (v, e) =>
21452148
{
21462149
UpdateBottomSheetHeight();
21472150
onFinish?.Invoke();
@@ -2177,6 +2180,7 @@ void AnimateOverlay(int animationDuration)
21772180

21782181
var overlayGridAnimation = new Animation(d =>
21792182
{
2183+
// Ensure the opacity is only updated with valid numeric values to avoid rendering issues.
21802184
if (!double.IsNaN(d))
21812185
{
21822186
_overlayGrid.Opacity = d;

maui/tests/Syncfusion.Maui.Toolkit.UnitTest/Navigation/SfBottomSheetUnitTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Constructor_InitializesDefaultsCorrectly()
3838
Assert.Equal(4d, _bottomSheet.GrabberHeight);
3939
Assert.Equal(32d, _bottomSheet.GrabberWidth);
4040
Assert.Equal(12d, _bottomSheet.GrabberCornerRadius);
41-
Assert.Equal(150d,_bottomSheet.AnimationDuration);
41+
Assert.Equal(150d, _bottomSheet.AnimationDuration);
4242
if (_bottomSheet.GrabberBackground is SolidColorBrush grabberBrush)
4343
{
4444
var grabberColor = grabberBrush.Color;
@@ -477,12 +477,12 @@ public void CollapseOnOverlayTap(bool input, bool expected)
477477
}
478478

479479
[Theory]
480-
[InlineData(500d,500d)]
481-
[InlineData(0d,0d)]
482-
[InlineData(-500d,-500d)]
483-
public void AnimationDuration(double input, double expected)
480+
[InlineData(500d, 500d)]
481+
[InlineData(0d, 0d)]
482+
[InlineData(-500d, -500d)]
483+
public void AnimationDurationProperty_ReturnsSetValue(double input, double expected)
484484
{
485-
_bottomSheet.AnimationDuration=input;
485+
_bottomSheet.AnimationDuration = input;
486486

487487
var actual = _bottomSheet.AnimationDuration;
488488

@@ -749,10 +749,10 @@ public void UpdateGrabberHeightProperty(double input, double expected)
749749
}
750750

751751
[Fact]
752-
public void SetAnimationDuration()
752+
public void GetClampedAnimationDuration()
753753
{
754754
_bottomSheet.AnimationDuration = -500;
755-
var actual = InvokePrivateMethod(_bottomSheet, "SetAnimationDuration");
755+
var actual = InvokePrivateMethod(_bottomSheet, "GetClampedAnimationDuration");
756756
Assert.Equal(0, actual);
757757
}
758758

0 commit comments

Comments
 (0)