@@ -17,7 +17,7 @@ import com.facebook.react.views.view.ReactDrawableHelper
1717import com.facebook.react.views.view.ReactViewGroup
1818import com.facebook.yoga.YogaConstants
1919
20- abstract class MenuViewManagerBase : ReactClippingViewManager <MenuView >() {
20+ abstract class MenuViewManagerBase : ReactClippingViewManager <MenuView >() {
2121 override fun getName () = " MenuView"
2222
2323 @ReactProp(name = " actions" )
@@ -37,8 +37,12 @@ abstract class MenuViewManagerBase: ReactClippingViewManager<MenuView>() {
3737
3838 override fun getExportedCustomDirectEventTypeConstants (): MutableMap <String , Any > {
3939 return MapBuilder .of(
40- " onPressAction" ,
41- MapBuilder .of(" registrationName" , " onPressAction" )
40+ " onPressAction" ,
41+ MapBuilder .of(" registrationName" , " onPressAction" ),
42+ " onCloseMenu" ,
43+ MapBuilder .of(" registrationName" , " onCloseMenu" ),
44+ " onOpenMenu" ,
45+ MapBuilder .of(" registrationName" , " onOpenMenu" )
4246 )
4347 }
4448
@@ -82,7 +86,19 @@ abstract class MenuViewManagerBase: ReactClippingViewManager<MenuView>() {
8286 view.nextFocusUpId = viewId
8387 }
8488
85- @ReactPropGroup(names = [ViewProps .BORDER_RADIUS , ViewProps .BORDER_TOP_LEFT_RADIUS , ViewProps .BORDER_TOP_RIGHT_RADIUS , ViewProps .BORDER_BOTTOM_RIGHT_RADIUS , ViewProps .BORDER_BOTTOM_LEFT_RADIUS , ViewProps .BORDER_TOP_START_RADIUS , ViewProps .BORDER_TOP_END_RADIUS , ViewProps .BORDER_BOTTOM_START_RADIUS , ViewProps .BORDER_BOTTOM_END_RADIUS ])
89+ @ReactPropGroup(
90+ names =
91+ [
92+ ViewProps .BORDER_RADIUS ,
93+ ViewProps .BORDER_TOP_LEFT_RADIUS ,
94+ ViewProps .BORDER_TOP_RIGHT_RADIUS ,
95+ ViewProps .BORDER_BOTTOM_RIGHT_RADIUS ,
96+ ViewProps .BORDER_BOTTOM_LEFT_RADIUS ,
97+ ViewProps .BORDER_TOP_START_RADIUS ,
98+ ViewProps .BORDER_TOP_END_RADIUS ,
99+ ViewProps .BORDER_BOTTOM_START_RADIUS ,
100+ ViewProps .BORDER_BOTTOM_END_RADIUS ]
101+ )
86102 fun setBorderRadius (view : ReactViewGroup , index : Int , borderRadius : Float ) {
87103 var borderRadius = borderRadius
88104 if (! YogaConstants .isUndefined(borderRadius) && borderRadius < 0 ) {
@@ -109,33 +125,60 @@ abstract class MenuViewManagerBase: ReactClippingViewManager<MenuView>() {
109125 // We should keep using setters as `Val cannot be reassigned`
110126 view.setHitSlopRect(null )
111127 } else {
112- view.setHitSlopRect(Rect (
113- if (hitSlop.hasKey(" left" )) PixelUtil .toPixelFromDIP(hitSlop.getDouble(" left" )).toInt() else 0 ,
114- if (hitSlop.hasKey(" top" )) PixelUtil .toPixelFromDIP(hitSlop.getDouble(" top" )).toInt() else 0 ,
115- if (hitSlop.hasKey(" right" )) PixelUtil .toPixelFromDIP(hitSlop.getDouble(" right" )).toInt() else 0 ,
116- if (hitSlop.hasKey(" bottom" )) PixelUtil .toPixelFromDIP(hitSlop.getDouble(" bottom" )).toInt() else 0 ))
128+ view.setHitSlopRect(
129+ Rect (
130+ if (hitSlop.hasKey(" left" ))
131+ PixelUtil .toPixelFromDIP(hitSlop.getDouble(" left" )).toInt()
132+ else 0 ,
133+ if (hitSlop.hasKey(" top" ))
134+ PixelUtil .toPixelFromDIP(hitSlop.getDouble(" top" )).toInt()
135+ else 0 ,
136+ if (hitSlop.hasKey(" right" ))
137+ PixelUtil .toPixelFromDIP(hitSlop.getDouble(" right" )).toInt()
138+ else 0 ,
139+ if (hitSlop.hasKey(" bottom" ))
140+ PixelUtil .toPixelFromDIP(hitSlop.getDouble(" bottom" )).toInt()
141+ else 0
142+ )
143+ )
117144 }
118145 }
119146
120147 @ReactProp(name = " nativeBackgroundAndroid" )
121148 fun setNativeBackground (view : ReactViewGroup , @Nullable bg : ReadableMap ? ) {
122149 view.setTranslucentBackgroundDrawable(
123- if (bg == null ) null else ReactDrawableHelper .createDrawableFromJSDescription(view.context, bg))
150+ if (bg == null ) null
151+ else ReactDrawableHelper .createDrawableFromJSDescription(view.context, bg)
152+ )
124153 }
125154
126155 @TargetApi(Build .VERSION_CODES .M )
127156 @ReactProp(name = " nativeForegroundAndroid" )
128157 fun setNativeForeground (view : ReactViewGroup , @Nullable fg : ReadableMap ? ) {
129- view.foreground = if (fg == null ) null else ReactDrawableHelper .createDrawableFromJSDescription(view.context, fg)
158+ view.foreground =
159+ if (fg == null ) null
160+ else ReactDrawableHelper .createDrawableFromJSDescription(view.context, fg)
130161 }
131162
132163 @ReactProp(name = ViewProps .NEEDS_OFFSCREEN_ALPHA_COMPOSITING )
133164 fun setNeedsOffscreenAlphaCompositing (
134- view : ReactViewGroup , needsOffscreenAlphaCompositing : Boolean ) {
165+ view : ReactViewGroup ,
166+ needsOffscreenAlphaCompositing : Boolean
167+ ) {
135168 view.setNeedsOffscreenAlphaCompositing(needsOffscreenAlphaCompositing)
136169 }
137170
138- @ReactPropGroup(names = [ViewProps .BORDER_WIDTH , ViewProps .BORDER_LEFT_WIDTH , ViewProps .BORDER_RIGHT_WIDTH , ViewProps .BORDER_TOP_WIDTH , ViewProps .BORDER_BOTTOM_WIDTH , ViewProps .BORDER_START_WIDTH , ViewProps .BORDER_END_WIDTH ])
171+ @ReactPropGroup(
172+ names =
173+ [
174+ ViewProps .BORDER_WIDTH ,
175+ ViewProps .BORDER_LEFT_WIDTH ,
176+ ViewProps .BORDER_RIGHT_WIDTH ,
177+ ViewProps .BORDER_TOP_WIDTH ,
178+ ViewProps .BORDER_BOTTOM_WIDTH ,
179+ ViewProps .BORDER_START_WIDTH ,
180+ ViewProps .BORDER_END_WIDTH ]
181+ )
139182 fun setBorderWidth (view : ReactViewGroup , index : Int , width : Float ) {
140183 var width = width
141184 if (! YogaConstants .isUndefined(width) && width < 0 ) {
@@ -147,7 +190,18 @@ abstract class MenuViewManagerBase: ReactClippingViewManager<MenuView>() {
147190 view.setBorderWidth(SPACING_TYPES [index], width)
148191 }
149192
150- @ReactPropGroup(names = [ViewProps .BORDER_COLOR , ViewProps .BORDER_LEFT_COLOR , ViewProps .BORDER_RIGHT_COLOR , ViewProps .BORDER_TOP_COLOR , ViewProps .BORDER_BOTTOM_COLOR , ViewProps .BORDER_START_COLOR , ViewProps .BORDER_END_COLOR ], customType = " Color" )
193+ @ReactPropGroup(
194+ names =
195+ [
196+ ViewProps .BORDER_COLOR ,
197+ ViewProps .BORDER_LEFT_COLOR ,
198+ ViewProps .BORDER_RIGHT_COLOR ,
199+ ViewProps .BORDER_TOP_COLOR ,
200+ ViewProps .BORDER_BOTTOM_COLOR ,
201+ ViewProps .BORDER_START_COLOR ,
202+ ViewProps .BORDER_END_COLOR ],
203+ customType = " Color"
204+ )
151205 abstract fun setBorderColor (view : ReactViewGroup , index : Int , color : Int? )
152206
153207 @ReactProp(name = ViewProps .OVERFLOW )
@@ -181,14 +235,15 @@ abstract class MenuViewManagerBase: ReactClippingViewManager<MenuView>() {
181235
182236 companion object {
183237 val COMMAND_SHOW = 1
184- val SPACING_TYPES = arrayOf(
185- Spacing .ALL ,
186- Spacing .LEFT ,
187- Spacing .RIGHT ,
188- Spacing .TOP ,
189- Spacing .BOTTOM ,
190- Spacing .START ,
191- Spacing .END
192- )
238+ val SPACING_TYPES =
239+ arrayOf(
240+ Spacing .ALL ,
241+ Spacing .LEFT ,
242+ Spacing .RIGHT ,
243+ Spacing .TOP ,
244+ Spacing .BOTTOM ,
245+ Spacing .START ,
246+ Spacing .END
247+ )
193248 }
194249}
0 commit comments