@@ -43,6 +43,11 @@ internal class SfIconButton : Grid, ITouchListener
43
43
/// </summary>
44
44
readonly bool _isHoveringOnReleased ;
45
45
46
+ /// <summary>
47
+ /// Holds the view which is used to clip.
48
+ /// </summary>
49
+ Grid clipView ;
50
+
46
51
#if __MACCATALYST__ || ( ! __ANDROID__ && ! __IOS__ )
47
52
/// <summary>
48
53
/// Holds the value to denotes the mouse cursor exited.
@@ -66,11 +71,15 @@ internal SfIconButton(View child, bool showTouchEffect = true, bool isSquareSele
66
71
_showTouchEffect = showTouchEffect ;
67
72
_isSquareSelection = isSquareSelection ;
68
73
_isHoveringOnReleased = isHoveringOnReleased ;
74
+ clipView = new Grid ( ) ;
69
75
EffectsView = new SfEffectsView ( ) ;
70
76
#if __IOS__
71
77
IgnoreSafeArea = true ;
78
+ clipView . IgnoreSafeArea = true ;
72
79
EffectsView . IgnoreSafeArea = true ;
73
80
#endif
81
+ //// - TODO directly clip the parent view cause the crash in the view. So, we add the grid view for the clip purpose.
82
+ clipView . Add ( this . EffectsView ) ;
74
83
Add ( EffectsView ) ;
75
84
EffectsView . Content = child ;
76
85
EffectsView . ShouldIgnoreTouches = true ;
@@ -200,16 +209,15 @@ void UpdateClip(double width, double height)
200
209
{
201
210
if ( _isSquareSelection || width < 0 || height < 0 )
202
211
{
203
- EffectsView . Clip = null ;
204
212
return ;
205
213
}
206
214
207
215
double centerX = Math . Min ( width , height ) / 2 ;
208
216
EllipseGeometry currentClip = new EllipseGeometry ( ) { Center = new Point ( width / 2 , height / 2 ) , RadiusX = centerX , RadiusY = centerX } ;
209
217
EllipseGeometry ? previousClip = null ;
210
- if ( EffectsView . Clip != null && EffectsView . Clip is EllipseGeometry )
218
+ if ( clipView . Clip != null && clipView . Clip is EllipseGeometry )
211
219
{
212
- previousClip = ( EllipseGeometry ) EffectsView . Clip ;
220
+ previousClip = ( EllipseGeometry ) clipView . Clip ;
213
221
}
214
222
215
223
//// If the previous and current clip values are same, then no need to update the effects view clip.
@@ -218,7 +226,7 @@ void UpdateClip(double width, double height)
218
226
return ;
219
227
}
220
228
221
- EffectsView . Clip = currentClip ;
229
+ clipView . Clip = currentClip ;
222
230
}
223
231
224
232
#if __MACCATALYST__ || ( ! __ANDROID__ && ! __IOS__ )
@@ -237,7 +245,7 @@ void ApplyCornerClip()
237
245
} ;
238
246
239
247
RoundRectangleGeometry ? previousClip = null ;
240
- if ( EffectsView . Clip != null && EffectsView . Clip is RoundRectangleGeometry previous )
248
+ if ( clipView . Clip != null && clipView . Clip is RoundRectangleGeometry previous )
241
249
{
242
250
previousClip = previous ;
243
251
}
@@ -248,7 +256,7 @@ void ApplyCornerClip()
248
256
return ;
249
257
}
250
258
251
- EffectsView . Clip = currentClip ;
259
+ clipView . Clip = currentClip ;
252
260
}
253
261
}
254
262
#endif
@@ -274,6 +282,20 @@ protected override Size MeasureOverride(double widthConstraint, double heightCon
274
282
return size ;
275
283
}
276
284
285
+ /// <summary>
286
+ /// Called when the size of the element is allocated.
287
+ /// Updates the corner clip for Mac Catalyst and non-Android/iOS platforms.
288
+ /// </summary>
289
+ /// <param name="width">The width allocated to the element.</param>
290
+ /// <param name="height">The height allocated to the element.</param>
291
+ protected override void OnSizeAllocated ( double width , double height )
292
+ {
293
+ base . OnSizeAllocated ( width , height ) ;
294
+ #if __MACCATALYST__ || ( ! __ANDROID__ && ! __IOS__ )
295
+ this . ApplyCornerClip ( ) ;
296
+ #endif
297
+ }
298
+
277
299
#endregion
278
300
279
301
#region Interface Implementation
0 commit comments