-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first look at adding full screen swipe
- Loading branch information
Showing
28 changed files
with
440 additions
and
61 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
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
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
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
60 changes: 60 additions & 0 deletions
60
android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt
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,60 @@ | ||
package com.swmansion.rnscreens | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule | ||
import com.facebook.react.bridge.ReactMethod | ||
import com.facebook.react.bridge.UiThreadUtil | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.UIManagerHelper | ||
|
||
@ReactModule(name = ScreensModule.REACT_CLASS) | ||
class ScreensModule(private val mReactContext: ReactApplicationContext) : ReactContextBaseJavaModule( | ||
mReactContext | ||
) { | ||
override fun getName(): String { | ||
return REACT_CLASS | ||
} | ||
|
||
@ReactMethod | ||
fun startTransition(reactTag: Int) { | ||
UiThreadUtil.runOnUiThread( | ||
Runnable { | ||
val uiManager = UIManagerHelper.getUIManagerForReactTag(mReactContext, reactTag) | ||
val stack = uiManager?.resolveView(reactTag) | ||
if (stack is ScreenStack) { | ||
stack.attachBelowTop() | ||
} | ||
} | ||
) | ||
} | ||
|
||
@ReactMethod | ||
fun updateTransition(reactTag: Int, progress: Double) { | ||
UiThreadUtil.runOnUiThread( | ||
Runnable { | ||
val uiManager = UIManagerHelper.getUIManagerForReactTag(mReactContext, reactTag) | ||
val stack = uiManager?.resolveView(reactTag) | ||
if (stack is ScreenStack) { | ||
// stack.attachBelowTop() | ||
} | ||
} | ||
) | ||
} | ||
|
||
@ReactMethod | ||
fun finishTransition(reactTag: Int, canceled: Boolean) { | ||
UiThreadUtil.runOnUiThread( | ||
Runnable { | ||
val uiManager = UIManagerHelper.getUIManagerForReactTag(mReactContext, reactTag) | ||
val stack = uiManager?.resolveView(reactTag) | ||
if (stack is ScreenStack) { | ||
stack.detachTop() | ||
} | ||
} | ||
) | ||
} | ||
|
||
companion object { | ||
const val REACT_CLASS = "RNSModule" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"main": "../lib/commonjs/gesture-handler/index", | ||
"module": "../lib/module/gesture-handler/index", | ||
"react-native": "../src/gesture-handler/index", | ||
"types": "../lib/typescript/gesture-handler/index" | ||
} |
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,13 @@ | ||
#ifdef RCT_NEW_ARCH_ENABLED | ||
#import <rnscreens/rnscreens.h> | ||
#else | ||
#import <React/RCTBridge.h> | ||
#endif | ||
|
||
@interface RNSModule : NSObject | ||
#ifdef RCT_NEW_ARCH_ENABLED | ||
<NativeScreensModuleSpec> | ||
#else | ||
<RCTBridgeModule> | ||
#endif | ||
@end |
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,89 @@ | ||
#import "RNSModule.h" | ||
#import <React/RCTBridge.h> | ||
#import <React/RCTUIManager.h> | ||
#import <React/RCTUIManagerUtils.h> | ||
#import "RNSScreenStack.h" | ||
|
||
@implementation RNSModule | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
#ifdef RCT_NEW_ARCH_ENABLED | ||
@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED; | ||
#endif // RCT_NEW_ARCH_ENABLED | ||
@synthesize bridge = _bridge; | ||
|
||
- (dispatch_queue_t)methodQueue | ||
{ | ||
// It seems that due to how UIBlocks work with uiManager, we need to call the methods there | ||
// for the blocks to be dispatched before the batch is completed | ||
return dispatch_get_main_queue(); | ||
} | ||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(startTransition : (nonnull NSNumber *)reactTag) | ||
{ | ||
RNSScreenStackView *view = [self getScreenStackView:reactTag]; | ||
|
||
if (![view isKindOfClass:[RNSScreenStackView class]]) { | ||
RCTLogError(@"Invalid svg returned from registry, expecting RNSScreenStackView, got: %@", view); | ||
return @(0); | ||
} | ||
|
||
dispatch_sync(dispatch_get_main_queue(), ^{ | ||
[view startScreenTransition]; | ||
}); | ||
return @(1); | ||
} | ||
|
||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(updateTransition : (nonnull NSNumber *)reactTag progress : (double)progress) | ||
{ | ||
RNSScreenStackView *view = [self getScreenStackView:reactTag]; | ||
|
||
if (![view isKindOfClass:[RNSScreenStackView class]]) { | ||
RCTLogError(@"Invalid svg returned from registry, expecting RNSScreenStackView, got: %@", view); | ||
return @(0); | ||
} | ||
dispatch_sync(dispatch_get_main_queue(), ^{ | ||
[view updateScreenTransition:progress]; | ||
}); | ||
|
||
return @(1); | ||
} | ||
|
||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(finishTransition : (nonnull NSNumber *)reactTag canceled : (BOOL)canceled) | ||
{ | ||
RNSScreenStackView *view = [self getScreenStackView:reactTag]; | ||
|
||
if (![view isKindOfClass:[RNSScreenStackView class]]) { | ||
RCTLogError(@"Invalid svg returned from registry, expecting RNSScreenStackView, got: %@", view); | ||
return @(0); | ||
} | ||
dispatch_sync(dispatch_get_main_queue(), ^{ | ||
[view finishScreenTransition:canceled]; | ||
}); | ||
return @(1); | ||
} | ||
|
||
- (RNSScreenStackView *)getScreenStackView:(NSNumber *)reactTag | ||
{ | ||
__block RNSScreenStackView *view; | ||
#ifdef RCT_NEW_ARCH_ENABLED | ||
dispatch_sync(dispatch_get_main_queue(), ^{ | ||
view = [self.viewRegistry_DEPRECATED viewForReactTag:reactTag]; | ||
}); | ||
#else | ||
dispatch_sync(dispatch_get_main_queue(), ^{ | ||
view = [self.bridge.uiManager viewForReactTag:reactTag]; | ||
}); | ||
#endif // RCT_NEW_ARCH_ENABLED | ||
return view; | ||
} | ||
|
||
#ifdef RCT_NEW_ARCH_ENABLED | ||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule: | ||
(const facebook::react::ObjCTurboModule::InitParams &)params | ||
{ | ||
return std::make_shared<facebook::react::NativeScreensModuleSpecJSI>(params); | ||
} | ||
#endif | ||
|
||
@end |
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.