Skip to content

Commit

Permalink
chore: add homeIndicatorHidden & activityState props for Fabric (…
Browse files Browse the repository at this point in the history
…6) (#1443)

* chore: add homeIndicatorHidden prop to codegen

* chore: add prop update on Fabric

* chore: add noop for Android

This prop is iOS only

* chore: move `activityState` prop to common section in RNSScreen
interface

* chore: move activityState setter to common section in RNSScreenView impl

* refact: linter suggestion

* chore: make RNSScreenView#reactSuperview common & make it implement
RNSScreenContainerDelegate protocol

This hasn't been tested yet. However in any instance it crashes (as
    the protocol might be not implemented) we can just implement noops
for Fabric

* chore: move activityState to implemented section in codegen config files

* chore: make series of methods shared (see details)

* `RNSScreenView#notifyFinishTransitioning`
* `RNSScreen#notifyFinishTransitioning`
* `willMoveToParentViewController`
* `RNSScreenContainer#updateContainer`

These methods were coupled together.

* fix: handle activityState on Fabric

Default value for the prop (when it is not set) on Fabric is -1 instead
of nil (I believe we can not get nil from C++) thus this improved
condition should work for both archs.

* chore: add `preventNativeDismiss` prop for Fabric (7) (#1444)

* chore: move preventNativeDismiss prop to common section in RNSScreen
interface

* fix: merge artifact

* chore: add preventNativeDismiss prop to codegen

* chore: add preventNativeDismiss prop update

* fix: add noop for Android

* chore: unify business logic between archs (8) (#1446)

* chore: unify RNSScreen#vieDidLayoutSubviews

* chore: make RNSScreenStack#hitTest:withEvent: method shared

#1416 (comment)

* chore: make RNSScreenStackView#isScrollViewPanGestureRecongnizer & some
helper methods shared

#1416 (comment)

* chore: move backButtonInCustomView to shared sectionin
RNSScreenStackHeaderConfig.h

* chore: move backButtonInCustomView prop to implemented section in JS

* chore: update `backButtonInCustomView` for Fabric

* chore: unify
RNSScreenStackHeaderConfigView#willShowViewController:animated:withConfig

* refact: linter suggestion

* fix: RNSScreen viewDidLayoutSubviews

* chore: copy interfaces to android/src/paper directory

* fix: commit address in comment

It changed after I rebased
  • Loading branch information
kkafar authored May 13, 2022
1 parent 2e74e5c commit 19ece9d
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class ScreenViewManager : ViewGroupManager<Screen>(), RNSScreenManagerInterface<
view.nativeBackButtonDismissalEnabled = nativeBackButtonDismissalEnabled
}

// these props are not available on Android, however we must override their getters
// these props are not available on Android, however we must override their setters
override fun setFullScreenSwipeEnabled(view: Screen?, value: Boolean) = Unit

override fun setTransitionDuration(view: Screen?, value: Int) = Unit
Expand All @@ -151,6 +151,10 @@ class ScreenViewManager : ViewGroupManager<Screen>(), RNSScreenManagerInterface<

override fun setGestureResponseDistance(view: Screen?, value: ReadableMap?) = Unit

override fun setHomeIndicatorHidden(view: Screen?, value: Boolean) = Unit

override fun setPreventNativeDismiss(view: Screen?, value: Boolean) = Unit

override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
val map: MutableMap<String, Any> = MapBuilder.of(
ScreenDismissedEvent.EVENT_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ColorPropConverter;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;

Expand All @@ -22,9 +23,18 @@ public RNSScreenManagerDelegate(U viewManager) {
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case "customAnimationOnSwipe":
mViewManager.setCustomAnimationOnSwipe(view, value == null ? false : (boolean) value);
break;
case "fullScreenSwipeEnabled":
mViewManager.setFullScreenSwipeEnabled(view, value == null ? false : (boolean) value);
break;
case "homeIndicatorHidden":
mViewManager.setHomeIndicatorHidden(view, value == null ? false : (boolean) value);
break;
case "preventNativeDismiss":
mViewManager.setPreventNativeDismiss(view, value == null ? false : (boolean) value);
break;
case "gestureEnabled":
mViewManager.setGestureEnabled(view, value == null ? true : (boolean) value);
break;
Expand All @@ -46,6 +56,9 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "statusBarTranslucent":
mViewManager.setStatusBarTranslucent(view, value == null ? false : (boolean) value);
break;
case "gestureResponseDistance":
mViewManager.setGestureResponseDistance(view, (ReadableMap) value);
break;
case "stackPresentation":
mViewManager.setStackPresentation(view, (String) value);
break;
Expand All @@ -58,6 +71,12 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "replaceAnimation":
mViewManager.setReplaceAnimation(view, (String) value);
break;
case "hideKeyboardOnSwipe":
mViewManager.setHideKeyboardOnSwipe(view, value == null ? false : (boolean) value);
break;
case "activityState":
mViewManager.setActivityState(view, value == null ? -1 : ((Double) value).intValue());
break;
case "navigationBarColor":
mViewManager.setNavigationBarColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
Expand All @@ -67,9 +86,6 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "nativeBackButtonDismissalEnabled":
mViewManager.setNativeBackButtonDismissalEnabled(view, value == null ? false : (boolean) value);
break;
case "activityState":
mViewManager.setActivityState(view, value == null ? -1 : ((Double) value).intValue());
break;
default:
super.setProperty(view, propName, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;

public interface RNSScreenManagerInterface<T extends View> {
void setCustomAnimationOnSwipe(T view, boolean value);
void setFullScreenSwipeEnabled(T view, boolean value);
void setHomeIndicatorHidden(T view, boolean value);
void setPreventNativeDismiss(T view, boolean value);
void setGestureEnabled(T view, boolean value);
void setStatusBarColor(T view, @Nullable Integer value);
void setStatusBarHidden(T view, boolean value);
void setScreenOrientation(T view, @Nullable String value);
void setStatusBarAnimation(T view, @Nullable String value);
void setStatusBarStyle(T view, @Nullable String value);
void setStatusBarTranslucent(T view, boolean value);
void setGestureResponseDistance(T view, @Nullable ReadableMap value);
void setStackPresentation(T view, @Nullable String value);
void setStackAnimation(T view, @Nullable String value);
void setTransitionDuration(T view, int value);
void setReplaceAnimation(T view, @Nullable String value);
void setHideKeyboardOnSwipe(T view, boolean value);
void setActivityState(T view, int value);
void setNavigationBarColor(T view, @Nullable Integer value);
void setNavigationBarHidden(T view, boolean value);
void setNativeBackButtonDismissalEnabled(T view, boolean value);
void setActivityState(T view, int value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public void setProperty(T view, String propName, @Nullable Object value) {
case "hideBackButton":
mViewManager.setHideBackButton(view, value == null ? false : (boolean) value);
break;
case "topInsetEnabled":
mViewManager.setTopInsetEnabled(view, value == null ? false : (boolean) value);
break;
case "backButtonInCustomView":
mViewManager.setBackButtonInCustomView(view, value == null ? false : (boolean) value);
break;
case "topInsetEnabled":
mViewManager.setTopInsetEnabled(view, value == null ? false : (boolean) value);
break;
default:
super.setProperty(view, propName, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public interface RNSScreenStackHeaderConfigManagerInterface<T extends View> {
void setTitleColor(T view, @Nullable Integer value);
void setDisableBackButtonMenu(T view, boolean value);
void setHideBackButton(T view, boolean value);
void setTopInsetEnabled(T view, boolean value);
void setBackButtonInCustomView(T view, boolean value);
void setTopInsetEnabled(T view, boolean value);
}
14 changes: 6 additions & 8 deletions ios/RNSScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)initWithView:(UIView *)view;
- (UIViewController *)findChildVCForConfigAndTrait:(RNSWindowTrait)trait includingModals:(BOOL)includingModals;
- (void)notifyFinishTransitioning;
#ifdef RN_FABRIC_ENABLED
- (void)setViewToSnapshot:(UIView *)snapshot;
- (void)resetViewToScreen;
#else
- (void)notifyFinishTransitioning;
#endif

@end
Expand All @@ -60,8 +59,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL dismissed;
@property (nonatomic) BOOL hideKeyboardOnSwipe;
@property (nonatomic) BOOL customAnimationOnSwipe;
@property (nonatomic) BOOL preventNativeDismiss;
@property (nonatomic, retain) RNSScreen *controller;
@property (nonatomic, copy) NSDictionary *gestureResponseDistance;
@property (nonatomic) int activityState;
@property (weak, nonatomic) UIView<RNSScreenContainerDelegate> *reactSuperview;

#if !TARGET_OS_TV
@property (nonatomic) RNSStatusBarStyle statusBarStyle;
Expand All @@ -73,7 +75,6 @@ NS_ASSUME_NONNULL_BEGIN

#ifdef RN_FABRIC_ENABLED
@property (weak, nonatomic) UIView *config;
@property (weak, nonatomic) UIView *reactSuperview;
#else
@property (nonatomic, copy) RCTDirectEventBlock onAppear;
@property (nonatomic, copy) RCTDirectEventBlock onDisappear;
Expand All @@ -82,12 +83,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) RCTDirectEventBlock onWillDisappear;
@property (nonatomic, copy) RCTDirectEventBlock onNativeDismissCancelled;
@property (nonatomic, copy) RCTDirectEventBlock onTransitionProgress;

@property (weak, nonatomic) UIView<RNSScreenContainerDelegate> *reactSuperview;
@property (nonatomic) int activityState;
@property (nonatomic) BOOL preventNativeDismiss;
#endif

- (void)notifyFinishTransitioning;

#ifdef RN_FABRIC_ENABLED
- (void)notifyWillAppear;
- (void)notifyWillDisappear;
Expand All @@ -96,7 +95,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateBounds;
- (void)notifyDismissedWithCount:(int)dismissCount;
#else
- (void)notifyFinishTransitioning;
- (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingForward:(BOOL)goingForward;
#endif

Expand Down
Loading

0 comments on commit 19ece9d

Please sign in to comment.