Kotlinify DrawerSlideEvent (#43836)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43836

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: alanleedev

Differential Revision: D55709887

fbshipit-source-id: ce15c18dcfdcf68eba0973ac2277a377435149fb
This commit is contained in:
Fabrizio Cucci
2024-04-04 02:00:36 -07:00
committed by Facebook GitHub Bot
parent c34dfb036b
commit 4b580c0060
3 changed files with 47 additions and 52 deletions
@@ -5998,13 +5998,16 @@ public final class com/facebook/react/views/drawer/events/DrawerOpenedEvent : co
public final class com/facebook/react/views/drawer/events/DrawerOpenedEvent$Companion {
}
public class com/facebook/react/views/drawer/events/DrawerSlideEvent : com/facebook/react/uimanager/events/Event {
public final class com/facebook/react/views/drawer/events/DrawerSlideEvent : com/facebook/react/uimanager/events/Event {
public static final field Companion Lcom/facebook/react/views/drawer/events/DrawerSlideEvent$Companion;
public static final field EVENT_NAME Ljava/lang/String;
public fun <init> (IF)V
public fun <init> (IIF)V
protected fun getEventData ()Lcom/facebook/react/bridge/WritableMap;
public fun getEventName ()Ljava/lang/String;
public fun getOffset ()F
public final fun getOffset ()F
}
public final class com/facebook/react/views/drawer/events/DrawerSlideEvent$Companion {
}
public class com/facebook/react/views/drawer/events/DrawerStateChangedEvent : com/facebook/react/uimanager/events/Event {
@@ -1,49 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.drawer.events;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;
/** Event emitted by a DrawerLayout as it is being moved open/closed. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class DrawerSlideEvent extends Event<DrawerSlideEvent> {
public static final String EVENT_NAME = "topDrawerSlide";
private final float mOffset;
@Deprecated
public DrawerSlideEvent(int viewId, float offset) {
this(ViewUtil.NO_SURFACE_ID, viewId, offset);
}
public DrawerSlideEvent(int surfaceId, int viewId, float offset) {
super(surfaceId, viewId);
mOffset = offset;
}
public float getOffset() {
return mOffset;
}
@Override
public String getEventName() {
return EVENT_NAME;
}
@Override
protected WritableMap getEventData() {
WritableMap eventData = Arguments.createMap();
eventData.putDouble("offset", getOffset());
return eventData;
}
}
@@ -0,0 +1,41 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.drawer.events
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.common.ViewUtil
import com.facebook.react.uimanager.events.Event
/** Event emitted by a DrawerLayout as it is being moved open/closed. */
public class DrawerSlideEvent : Event<DrawerSlideEvent> {
private val offset: Float
@Deprecated(
"Use constructor with surfaceId", ReplaceWith("DrawerSlideEvent(surfaceId, viewId, offset)"))
public constructor(viewId: Int, offset: Float) : this(ViewUtil.NO_SURFACE_ID, viewId, offset)
public constructor(surfaceId: Int, viewId: Int, offset: Float) : super(surfaceId, viewId) {
this.offset = offset
}
public fun getOffset(): Float = offset
override public fun getEventName(): String = EVENT_NAME
override protected fun getEventData(): WritableMap? {
val eventData: WritableMap = Arguments.createMap()
eventData.putDouble("offset", getOffset().toDouble())
return eventData
}
public companion object {
public const val EVENT_NAME: String = "topDrawerSlide"
}
}