Skip to content

Commit

Permalink
Convert ReactSwitchEvent to Kotlin (facebook#43881)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#43881

convert Java to Kotlin: `/react/views/switchview/ReactSwitchEvent.java`

Changelog:
[Internal] internal

Differential Revision: D55770377
  • Loading branch information
alanleedev authored and facebook-github-bot committed Apr 4, 2024
1 parent fd3ef7b commit f00e50a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 52 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.switchview

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 ReactSwitchManager once a switch is fully switched on/off */
internal class ReactSwitchEvent(surfaceId: Int, viewId: Int, private val isChecked: Boolean) :
Event<ReactSwitchEvent>(surfaceId, viewId) {

@Deprecated(
"Use the constructor with surfaceId, viewId and isChecked parameters.",
replaceWith = ReplaceWith("ReactSwitchEvent(surfaceId, viewId, isChecked)"))
constructor(viewId: Int, isChecked: Boolean) : this(ViewUtil.NO_SURFACE_ID, viewId, isChecked)

public override fun getEventName(): String {
return EVENT_NAME
}

public override fun getEventData(): WritableMap? {
val eventData = Arguments.createMap()
eventData.putInt("target", viewTag)
eventData.putBoolean("value", isChecked)
return eventData
}

private companion object {
private const val EVENT_NAME = "topChange"
}
}

0 comments on commit f00e50a

Please sign in to comment.