Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions android/src/main/java/com/swmansion/rnscreens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,10 @@ class Screen(context: ReactContext?) : FabricEnabledViewGroup(context) {
}

private fun notifyHeaderHeightChange(headerHeight: Double) {
UIManagerHelper.getEventDispatcherForReactTag(context as ReactContext, id)
?.dispatchEvent(HeaderHeightChangeEvent(id, headerHeight))
val screenContext = context as ReactContext
val surfaceId = UIManagerHelper.getSurfaceId(screenContext)
UIManagerHelper.getEventDispatcherForReactTag(screenContext, id)
?.dispatchEvent(HeaderHeightChangeEvent(surfaceId, id, headerHeight))
}

enum class StackPresentation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class HeaderAttachedEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class HeaderAttachedEvent(surfaceId: Int, viewId: Int) : Event<HeaderAttachedEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class HeaderBackButtonClickedEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class HeaderBackButtonClickedEvent(surfaceId: Int, viewId: Int) : Event<HeaderBackButtonClickedEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class HeaderDetachedEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class HeaderDetachedEvent(surfaceId: Int, viewId: Int) : Event<HeaderDetachedEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.swmansion.rnscreens.events

import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.events.RCTEventEmitter

class HeaderHeightChangeEvent(
surfaceId: Int,
viewId: Int,
private val headerHeight: Double
) : Event<HeaderHeightChangeEvent>(viewId) {
) : Event<HeaderHeightChangeEvent>(surfaceId, viewId) {

override fun getEventName() = EVENT_NAME

// As the same header height could appear twice, use header height as a coalescing key.
override fun getCoalescingKey(): Short = headerHeight.toInt().toShort()

override fun dispatch(rctEventEmitter: RCTEventEmitter) {
val map = Arguments.createMap()
map.putDouble("headerHeight", headerHeight)
rctEventEmitter.receiveEvent(viewTag, eventName, map)
override fun getEventData(): WritableMap? = Arguments.createMap().apply {
putDouble("headerHeight", headerHeight)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ScreenTransitionProgressEvent(
private val isClosing: Boolean,
private val isGoingForward: Boolean,
private val coalescingKey: Short
) : Event<ScreenAppearEvent?>(surfaceId, viewId) {
) : Event<ScreenTransitionProgressEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

override fun getCoalescingKey(): Short = coalescingKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class SearchBarBlurEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class SearchBarBlurEvent(surfaceId: Int, viewId: Int) : Event<SearchBarBlurEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SearchBarChangeTextEvent(
surfaceId: Int,
viewId: Int,
private val text: String?,
) : Event<ScreenAppearEvent>(surfaceId, viewId) {
) : Event<SearchBarChangeTextEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class SearchBarCloseEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class SearchBarCloseEvent(surfaceId: Int, viewId: Int) : Event<SearchBarCloseEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class SearchBarFocusEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class SearchBarFocusEvent(surfaceId: Int, viewId: Int) : Event<SearchBarFocusEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class SearchBarOpenEvent(surfaceId: Int, viewId: Int) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class SearchBarOpenEvent(surfaceId: Int, viewId: Int) : Event<SearchBarOpenEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.events.Event

class SearchBarSearchButtonPressEvent(surfaceId: Int, viewId: Int, private val text: String?) : Event<ScreenAppearEvent>(surfaceId, viewId) {
class SearchBarSearchButtonPressEvent(surfaceId: Int, viewId: Int, private val text: String?) : Event<SearchBarSearchButtonPressEvent>(surfaceId, viewId) {
override fun getEventName(): String = EVENT_NAME

// All events for a given view can be coalesced.
Expand Down