-
-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native-stack] Add transitionStart and transitionEnd events (#499)
Implement transitionStart and transitionEnd events in native stack, similar to the events available in js stack. On Android there isn't really a concept of nested stacks and it uses only one fragment manager. This means a single "transition" so we need a way to trigger this transition on all nested stacks of a screen. To do that we added a way for nested stacks to register on their parent screen so when a screen is dismissed it can also call the dismiss method on all its child stacks.
- Loading branch information
1 parent
df1551d
commit b1078b2
Showing
14 changed files
with
391 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
android/src/main/java/com/swmansion/rnscreens/ScreenDisappearEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.swmansion.rnscreens; | ||
|
||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.uimanager.events.Event; | ||
import com.facebook.react.uimanager.events.RCTEventEmitter; | ||
|
||
public class ScreenDisappearEvent extends Event<ScreenAppearEvent> { | ||
|
||
public static final String EVENT_NAME = "topDisappear"; | ||
|
||
public ScreenDisappearEvent(int viewId) { | ||
super(viewId); | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
public short getCoalescingKey() { | ||
// All events for a given view can be coalesced. | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void dispatch(RCTEventEmitter rctEventEmitter) { | ||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), Arguments.createMap()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
android/src/main/java/com/swmansion/rnscreens/ScreenWillAppearEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.swmansion.rnscreens; | ||
|
||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.uimanager.events.Event; | ||
import com.facebook.react.uimanager.events.RCTEventEmitter; | ||
|
||
public class ScreenWillAppearEvent extends Event<ScreenAppearEvent> { | ||
|
||
public static final String EVENT_NAME = "topWillAppear"; | ||
|
||
public ScreenWillAppearEvent(int viewId) { | ||
super(viewId); | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
public short getCoalescingKey() { | ||
// All events for a given view can be coalesced. | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void dispatch(RCTEventEmitter rctEventEmitter) { | ||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), Arguments.createMap()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
android/src/main/java/com/swmansion/rnscreens/ScreenWillDisappearEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.swmansion.rnscreens; | ||
|
||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.uimanager.events.Event; | ||
import com.facebook.react.uimanager.events.RCTEventEmitter; | ||
|
||
public class ScreenWillDisappearEvent extends Event<ScreenAppearEvent> { | ||
|
||
public static final String EVENT_NAME = "topWillDisappear"; | ||
|
||
public ScreenWillDisappearEvent(int viewId) { | ||
super(viewId); | ||
} | ||
|
||
@Override | ||
public String getEventName() { | ||
return EVENT_NAME; | ||
} | ||
|
||
@Override | ||
public short getCoalescingKey() { | ||
// All events for a given view can be coalesced. | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void dispatch(RCTEventEmitter rctEventEmitter) { | ||
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), Arguments.createMap()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.