@@ -13,16 +13,23 @@ internal class BottomSheetBorder : SfBorder, ITouchListener
13
13
// To store the weak reference of bottom sheet instance.
14
14
readonly WeakReference < SfBottomSheet > ? _bottomSheetRef ;
15
15
16
- #endregion
16
+ #if IOS
17
+
18
+ // To store the child count of bottom sheet
19
+ double _childLoopCount ;
20
+
21
+ #endif
22
+
23
+ #endregion
17
24
18
25
#region Constructor
19
26
20
27
/// <summary>
21
- /// Initializes a new instance of the <see cref="BottomSheetBorder"/> class.
22
- /// </summary>
23
- /// <param name="bottomSheet">The SfBottomSheet instance.</param>
24
- /// <exception cref="ArgumentNullException">Thrown if bottomSheet is null.</exception>
25
- public BottomSheetBorder ( SfBottomSheet bottomSheet )
28
+ /// Initializes a new instance of the <see cref="BottomSheetBorder"/> class.
29
+ /// </summary>
30
+ /// <param name="bottomSheet">The SfBottomSheet instance.</param>
31
+ /// <exception cref="ArgumentNullException">Thrown if bottomSheet is null.</exception>
32
+ public BottomSheetBorder ( SfBottomSheet bottomSheet )
26
33
{
27
34
if ( bottomSheet is not null )
28
35
{
@@ -33,6 +40,72 @@ public BottomSheetBorder(SfBottomSheet bottomSheet)
33
40
34
41
#endregion
35
42
43
+ #region Private Methods
44
+
45
+ #if IOS
46
+ /// <summary>
47
+ /// Gets the X and Y coordinates of the specified element based on the screen.
48
+ /// </summary>
49
+ /// <param name="element">The current element for which coordinates are requested.</param>
50
+ /// <param name="touchPoint">The current element for which coordinates are requested.</param>
51
+ bool IsChildElementScrolled ( IVisualTreeElement ? element , Point touchPoint )
52
+ {
53
+ if ( element is null )
54
+ {
55
+ return false ;
56
+ }
57
+
58
+ var view = element as View ;
59
+ if ( view is null || view . Handler is null || view . Handler . PlatformView is null )
60
+ {
61
+ return false ;
62
+ }
63
+
64
+ if ( view is ScrollView || view is ListView || view is CollectionView )
65
+ {
66
+ return true ;
67
+ }
68
+
69
+ foreach ( var childView in element . GetVisualChildren ( ) . OfType < View > ( ) )
70
+ {
71
+ if ( childView is null || childView . Handler is null || childView . Handler . PlatformView is null )
72
+ {
73
+ return false ;
74
+ }
75
+
76
+ var childNativeView = childView . Handler . PlatformView ;
77
+
78
+ // Here items X and Y position converts based on screen.
79
+ Point locationOnScreen = ChildLocationToScreen ( childNativeView ) ;
80
+ var bottom = locationOnScreen . Y + childView . Bounds . Height ;
81
+ var right = locationOnScreen . X + childView . Bounds . Width ;
82
+
83
+ // We loop through child only 10 times.
84
+ if ( touchPoint . Y >= locationOnScreen . Y && touchPoint . Y <= bottom && touchPoint . X >= locationOnScreen . X && touchPoint . X <= right && _childLoopCount <= 10 )
85
+ {
86
+ _childLoopCount ++ ;
87
+ return IsChildElementScrolled ( childView , touchPoint ) ;
88
+ }
89
+ }
90
+
91
+ _childLoopCount = 0 ;
92
+ return false ;
93
+ }
94
+
95
+ Point ChildLocationToScreen ( object child )
96
+ {
97
+ if ( child is UIKit . UIView view && this . Handler is not null )
98
+ {
99
+ var point = view . ConvertPointToView ( view . Bounds . Location , Handler . PlatformView as UIKit . UIView ) ;
100
+ return new Microsoft . Maui . Graphics . Point ( point . X , point . Y ) ;
101
+ }
102
+
103
+ return new Microsoft . Maui . Graphics . Point ( 0 , 0 ) ;
104
+ }
105
+ #endif
106
+
107
+ #endregion
108
+
36
109
#region Interface Implementation
37
110
38
111
/// <summary>
@@ -42,15 +115,32 @@ public BottomSheetBorder(SfBottomSheet bottomSheet)
42
115
public void OnTouch ( Toolkit . Internals . PointerEventArgs e )
43
116
{
44
117
#if IOS || MACCATALYST || ANDROID
118
+
119
+ #if IOS
120
+ if ( Content is null )
121
+ {
122
+ return ;
123
+ }
124
+
125
+ var firstDescendant = Content . GetVisualTreeDescendants ( ) . FirstOrDefault ( ) ;
126
+ if ( firstDescendant is not null && IsChildElementScrolled ( firstDescendant , e . TouchPoint ) )
127
+ {
128
+ return ;
129
+ }
130
+
131
+ #endif
45
132
if ( e is not null && _bottomSheetRef is not null )
46
133
{
47
134
if ( _bottomSheetRef . TryGetTarget ( out var bottomSheet ) )
48
135
{
49
136
bottomSheet . OnHandleTouch ( e . Action , e . TouchPoint ) ;
50
137
}
51
138
}
139
+
52
140
#endif
53
141
}
142
+
54
143
#endregion
144
+
55
145
}
56
146
}
0 commit comments