@@ -1201,7 +1201,7 @@ public bool CollapseOnOverlayTap
1201
1201
}
1202
1202
1203
1203
/// <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.
1205
1205
/// </summary>
1206
1206
/// <value>
1207
1207
/// It accepts double values, and the default value is 150ms.
@@ -1287,9 +1287,12 @@ public void Close()
1287
1287
}
1288
1288
1289
1289
/// <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.
1291
1293
/// </summary>
1292
- int SetAnimationDuration ( )
1294
+ /// <returns>A non-negative integer representing the animation duration.</returns>
1295
+ int GetClampedAnimationDuration ( )
1293
1296
{
1294
1297
return ( int ) Math . Max ( 0 , AnimationDuration ) ;
1295
1298
}
@@ -2135,13 +2138,13 @@ void AnimateBottomSheet(double targetPosition, Action? onFinish = null)
2135
2138
_overlayGrid . AbortAnimation ( "overlayGridAnimation" ) ;
2136
2139
}
2137
2140
2138
- int animationDuration = this . SetAnimationDuration ( ) ;
2139
- const int topPadding = 2 ;
2141
+ int animationDuration = this . GetClampedAnimationDuration ( ) ;
2142
+ const int topPadding = 2 ;
2140
2143
_isSheetOpen = true ;
2141
2144
if ( _bottomSheet is not null )
2142
2145
{
2143
2146
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 ) =>
2145
2148
{
2146
2149
UpdateBottomSheetHeight ( ) ;
2147
2150
onFinish ? . Invoke ( ) ;
@@ -2177,6 +2180,7 @@ void AnimateOverlay(int animationDuration)
2177
2180
2178
2181
var overlayGridAnimation = new Animation ( d =>
2179
2182
{
2183
+ // Ensure the opacity is only updated with valid numeric values to avoid rendering issues.
2180
2184
if ( ! double . IsNaN ( d ) )
2181
2185
{
2182
2186
_overlayGrid . Opacity = d ;
0 commit comments