@@ -67,14 +67,11 @@ public static readonly BindableProperty CurrentGestureShiftProperty
67
67
= BindableProperty . Create ( nameof ( CurrentGestureShift ) , typeof ( double ) , typeof ( SideMenuView ) , 0.0 , BindingMode . OneWayToSource ) ;
68
68
69
69
public static readonly BindableProperty GestureThresholdProperty
70
- = BindableProperty . Create ( nameof ( GestureThreshold ) , typeof ( double ) , typeof ( SideMenuView ) , 7 .0) ;
70
+ = BindableProperty . Create ( nameof ( GestureThreshold ) , typeof ( double ) , typeof ( SideMenuView ) , - 1 .0) ;
71
71
72
72
public static readonly BindableProperty CancelVerticalGestureThresholdProperty
73
73
= BindableProperty . Create ( nameof ( CancelVerticalGestureThreshold ) , typeof ( double ) , typeof ( SideMenuView ) , 1.0 ) ;
74
74
75
- public static readonly BindableProperty AllowInterceptGestureProperty
76
- = BindableProperty . Create ( nameof ( AllowInterceptGesture ) , typeof ( bool ) , typeof ( SideMenuView ) , false ) ;
77
-
78
75
public static readonly BindableProperty StateProperty
79
76
= BindableProperty . Create ( nameof ( State ) , typeof ( SideMenuState ) , typeof ( SideMenuView ) , SideMenuState . MainViewShown , BindingMode . TwoWay , propertyChanged : OnStatePropertyChanged ) ;
80
77
@@ -90,36 +87,15 @@ public static readonly BindableProperty MenuWidthPercentageProperty
90
87
public static readonly BindableProperty MenuGestureEnabledProperty
91
88
= BindableProperty . CreateAttached ( nameof ( GetMenuGestureEnabled ) , typeof ( bool ) , typeof ( SideMenuView ) , true ) ;
92
89
93
- internal void OnPanUpdated ( object sender , PanUpdatedEventArgs e )
90
+ public SideMenuView ( )
94
91
{
95
- var shift = e . TotalX ;
96
- var verticalShift = e . TotalY ;
97
- switch ( e . StatusType )
98
- {
99
- case GestureStatus . Started :
100
- OnTouchStarted ( ) ;
101
- return ;
102
- case GestureStatus . Running :
103
- OnTouchChanged ( shift , verticalShift ) ;
104
- return ;
105
- case GestureStatus . Canceled :
106
- case GestureStatus . Completed :
107
- if ( Device . RuntimePlatform == Device . Android )
108
- OnTouchChanged ( shift , verticalShift ) ;
109
-
110
- OnTouchEnded ( ) ;
111
- return ;
112
- }
113
- }
114
-
115
- internal async void OnSwiped ( SwipeDirection swipeDirection )
116
- {
117
- await Task . Delay ( 1 ) ;
118
- if ( isGestureStarted )
119
- return ;
120
-
121
- var state = ResolveSwipeState ( swipeDirection == SwipeDirection . Right ) ;
122
- UpdateState ( state , true ) ;
92
+ #if __ANDROID__
93
+ if ( System . DateTime . Now . Ticks < 0 )
94
+ _ = new Xamarin . CommunityToolkit . Android . UI . Views . SideMenuViewRenderer ( null ) ;
95
+ #elif __IOS__
96
+ if ( System . DateTime . Now . Ticks < 0 )
97
+ _ = new Xamarin . CommunityToolkit . iOS . UI . Views . SideMenuViewRenderer ( ) ;
98
+ #endif
123
99
}
124
100
125
101
public new ISideMenuList < View > Children
@@ -149,12 +125,6 @@ public double CancelVerticalGestureThreshold
149
125
set => SetValue ( CancelVerticalGestureThresholdProperty , value ) ;
150
126
}
151
127
152
- public bool AllowInterceptGesture
153
- {
154
- get => ( bool ) GetValue ( AllowInterceptGestureProperty ) ;
155
- set => SetValue ( AllowInterceptGestureProperty , value ) ;
156
- }
157
-
158
128
public SideMenuState State
159
129
{
160
130
get => ( SideMenuState ) GetValue ( StateProperty ) ;
@@ -185,6 +155,46 @@ public static bool GetMenuGestureEnabled(BindableObject bindable)
185
155
public static void SetMenuGestureEnabled ( BindableObject bindable , bool value )
186
156
=> bindable . SetValue ( MenuGestureEnabledProperty , value ) ;
187
157
158
+ internal void OnPanUpdated ( object sender , PanUpdatedEventArgs e )
159
+ {
160
+ var shift = e . TotalX ;
161
+ var verticalShift = e . TotalY ;
162
+ switch ( e . StatusType )
163
+ {
164
+ case GestureStatus . Started :
165
+ OnTouchStarted ( ) ;
166
+ return ;
167
+ case GestureStatus . Running :
168
+ OnTouchChanged ( shift , verticalShift ) ;
169
+ return ;
170
+ case GestureStatus . Canceled :
171
+ case GestureStatus . Completed :
172
+ if ( Device . RuntimePlatform == Device . Android )
173
+ OnTouchChanged ( shift , verticalShift ) ;
174
+
175
+ OnTouchEnded ( ) ;
176
+ return ;
177
+ }
178
+ }
179
+
180
+ internal async void OnSwiped ( SwipeDirection swipeDirection )
181
+ {
182
+ await Task . Delay ( 1 ) ;
183
+ if ( isGestureStarted )
184
+ return ;
185
+
186
+ var state = ResolveSwipeState ( swipeDirection == SwipeDirection . Right ) ;
187
+ UpdateState ( state , true ) ;
188
+ }
189
+
190
+ internal bool CheckGestureEnabled ( SideMenuPosition menuPosition )
191
+ => menuPosition switch
192
+ {
193
+ SideMenuPosition . LeftMenu => CheckMenuGestureEnabled ( leftMenu ) ,
194
+ SideMenuPosition . RightMenu => CheckMenuGestureEnabled ( rightMenu ) ,
195
+ _ => true
196
+ } ;
197
+
188
198
protected override void OnControlInitialized ( AbsoluteLayout control )
189
199
{
190
200
children . CollectionChanged += OnChildrenCollectionChanged ;
@@ -548,5 +558,8 @@ void OnLayoutChanged(object sender, EventArgs e)
548
558
Control . RaiseChild ( mainView ) ;
549
559
Control . RaiseChild ( overlayView ) ;
550
560
}
561
+
562
+ bool CheckMenuGestureEnabled ( View menuView )
563
+ => menuView != null && GetMenuGestureEnabled ( menuView ) ;
551
564
}
552
565
}
0 commit comments