diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt index 080b79819e..523066266b 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt @@ -313,6 +313,13 @@ class ScreenStackHeaderConfigViewManager : logNotAvailable("backButtonDisplayMode") } + override fun setBackButtonUseModernImplementation( + view: ScreenStackHeaderConfig?, + value: Boolean, + ) { + logNotAvailable("backButtonUseModernImplementation") + } + override fun setBlurEffect( view: ScreenStackHeaderConfig?, value: String?, diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java index 3ef1e7a08d..db1dca705c 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java @@ -97,6 +97,9 @@ public void setProperty(T view, String propName, @Nullable Object value) { case "backButtonDisplayMode": mViewManager.setBackButtonDisplayMode(view, (String) value); break; + case "backButtonUseModernImplementation": + mViewManager.setBackButtonUseModernImplementation(view, value == null ? false : (boolean) value); + break; case "hideBackButton": mViewManager.setHideBackButton(view, value == null ? false : (boolean) value); break; diff --git a/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java b/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java index 0f1bc58396..99c90c6178 100644 --- a/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +++ b/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java @@ -39,6 +39,7 @@ public interface RNSScreenStackHeaderConfigManagerInterface { void setTitleColor(T view, @Nullable Integer value); void setDisableBackButtonMenu(T view, boolean value); void setBackButtonDisplayMode(T view, @Nullable String value); + void setBackButtonUseModernImplementation(T view, boolean value); void setHideBackButton(T view, boolean value); void setBackButtonInCustomView(T view, boolean value); void setBlurEffect(T view, @Nullable String value); diff --git a/apps/src/tests/Test2809/index.tsx b/apps/src/tests/Test2809/index.tsx index e44c724fb2..3ef0212394 100644 --- a/apps/src/tests/Test2809/index.tsx +++ b/apps/src/tests/Test2809/index.tsx @@ -10,45 +10,190 @@ import { createStackWithOptions } from './Shared'; // Naming convention: // Enabled/Disabled - based on headerBackButtonMenu value // Default/Generic/Minimal - based on headerBackButtonDisplayMode value -// DefaultText/CustomText/StyledText - based on label content +// DefaultText/CustomText/StyledText/CustomStyledText - based on label content // headerBackButtonMenu: enabled // headerBackButtonDisplayMode: default const EnabledDefaultDefaultText = createStackWithOptions({}, {}); -const EnabledDefaultCustomText = createStackWithOptions({}, { headerBackTitle: 'Custom' }); -const EnabledDefaultStyledText = createStackWithOptions({}, { headerBackTitleStyle: {fontSize: 30} }); +const EnabledDefaultCustomText = createStackWithOptions( + {}, + { headerBackTitle: 'Custom' }, +); +const EnabledDefaultStyledText = createStackWithOptions( + {}, + { headerBackTitleStyle: { fontSize: 30 } }, +); +const EnabledDefaultCustomStyledText = createStackWithOptions( + {}, + { headerBackTitle: 'Custom', headerBackTitleStyle: { fontSize: 30 } }, +); // headerBackButtonDisplayMode: generic -const EnabledGenericDefaultText = createStackWithOptions({}, { headerBackButtonDisplayMode: 'generic' }); -const EnabledGenericCustomText = createStackWithOptions({}, { headerBackButtonDisplayMode: 'generic', headerBackTitle: 'Custom' }); -const EnabledGenericStyledText = createStackWithOptions({}, { headerBackButtonDisplayMode: 'generic', headerBackTitleStyle: {fontSize: 30} }); +const EnabledGenericDefaultText = createStackWithOptions( + {}, + { headerBackButtonDisplayMode: 'generic' }, +); +const EnabledGenericCustomText = createStackWithOptions( + {}, + { headerBackButtonDisplayMode: 'generic', headerBackTitle: 'Custom' }, +); +const EnabledGenericStyledText = createStackWithOptions( + {}, + { + headerBackButtonDisplayMode: 'generic', + headerBackTitleStyle: { fontSize: 30 }, + }, +); +const EnabledGenericCustomStyledText = createStackWithOptions( + {}, + { + headerBackButtonDisplayMode: 'generic', + headerBackTitle: 'Custom', + headerBackTitleStyle: { fontSize: 30 }, + }, +); // headerBackButtonDisplayMode: generic -const EnabledMinimalDefaultText = createStackWithOptions({}, { headerBackButtonDisplayMode: 'minimal' }); -const EnabledMinimalCustomText = createStackWithOptions({}, { headerBackButtonDisplayMode: 'minimal', headerBackTitle: 'Custom' }); -const EnabledMinimalStyledText = createStackWithOptions({}, { headerBackButtonDisplayMode: 'minimal', headerBackTitleStyle: {fontSize: 30} }); +const EnabledMinimalDefaultText = createStackWithOptions( + {}, + { headerBackButtonDisplayMode: 'minimal' }, +); +const EnabledMinimalCustomText = createStackWithOptions( + {}, + { headerBackButtonDisplayMode: 'minimal', headerBackTitle: 'Custom' }, +); +const EnabledMinimalStyledText = createStackWithOptions( + {}, + { + headerBackButtonDisplayMode: 'minimal', + headerBackTitleStyle: { fontSize: 30 }, + }, +); +const EnabledMinimalCustomStyledText = createStackWithOptions( + {}, + { + headerBackButtonDisplayMode: 'minimal', + headerBackTitle: 'Custom', + headerBackTitleStyle: { fontSize: 30 }, + }, +); // headerBackButtonMenu: disabled // headerBackButtonDisplayMode: default -const DisabledDefaultDefaultText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false }); -const DisabledDefaultCustomText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackTitle: 'Custom' }); -const DisabledDefaultStyledText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackTitleStyle: {fontSize: 30}}); +const DisabledDefaultDefaultText = createStackWithOptions( + {}, + { headerBackButtonMenuEnabled: false }, +); +const DisabledDefaultCustomText = createStackWithOptions( + {}, + { headerBackButtonMenuEnabled: false, headerBackTitle: 'Custom' }, +); +const DisabledDefaultStyledText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackTitleStyle: { fontSize: 30 }, + }, +); +const DisabledDefaultCustomStyledText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackTitle: 'Custom', + headerBackTitleStyle: { fontSize: 30 }, + }, +); // headerBackButtonDisplayMode: generic -const DisabledGenericDefaultText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackButtonDisplayMode: 'generic' }); -const DisabledGenericCustomText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackButtonDisplayMode: 'generic', headerBackTitle: 'Custom' }); -const DisabledGenericStyledText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackButtonDisplayMode: 'generic', headerBackTitleStyle: {fontSize: 30} }); +const DisabledGenericDefaultText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackButtonDisplayMode: 'generic', + }, +); +const DisabledGenericCustomText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackButtonDisplayMode: 'generic', + headerBackTitle: 'Custom', + }, +); +const DisabledGenericStyledText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackButtonDisplayMode: 'generic', + headerBackTitleStyle: { fontSize: 30 }, + }, +); +const DisabledGenericCustomStyledText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackTitle: 'Custom', + headerBackButtonDisplayMode: 'generic', + headerBackTitleStyle: { fontSize: 30 }, + }, +); // headerBackButtonDisplayMode: generic -const DisabledMinimalDefaultText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackButtonDisplayMode: 'minimal' }); -const DisabledMinimalCustomText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackButtonDisplayMode: 'minimal', headerBackTitle: 'Custom' }); -const DisabledMinimalStyledText = createStackWithOptions({}, { headerBackButtonMenuEnabled: false, headerBackButtonDisplayMode: 'minimal', headerBackTitleStyle: {fontSize: 30} }); +const DisabledMinimalDefaultText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackButtonDisplayMode: 'minimal', + }, +); +const DisabledMinimalCustomText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackButtonDisplayMode: 'minimal', + headerBackTitle: 'Custom', + }, +); +const DisabledMinimalStyledText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackButtonDisplayMode: 'minimal', + headerBackTitleStyle: { fontSize: 30 }, + }, +); +const DisabledMinimalCustomStyledText = createStackWithOptions( + {}, + { + headerBackButtonMenuEnabled: false, + headerBackTitle: 'Custom', + headerBackButtonDisplayMode: 'minimal', + headerBackTitleStyle: { fontSize: 30 }, + }, +); // Custom -const CustomLongDefaultText = createStackWithOptions({ headerTitle: 'LongLongLongLongLong'}, {}); -const CustomDefaultTextWithLongTitle = createStackWithOptions({}, {headerTitle: 'LongLongLongLongLongLongLong'}); -const CustomLongCustomText = createStackWithOptions({}, { headerBackTitle: 'LongLongLongLongLong' }); -const CustomCustomTextWithLongTitle = createStackWithOptions({}, {headerBackTitle: 'CustomBack', headerTitle: 'LongLongLongLongLongLongLong'}); - -const Button = ({title, onPress}: {title: string, onPress: () => void}) => ( - - {title} +const CustomLongDefaultText = createStackWithOptions( + { headerTitle: 'LongLongLongLongLong' }, + {}, +); +const CustomDefaultTextWithLongTitle = createStackWithOptions( + {}, + { headerTitle: 'LongLongLongLongLongLongLong' }, +); +const CustomLongCustomText = createStackWithOptions( + {}, + { headerBackTitle: 'LongLongLongLongLong' }, +); +const CustomCustomTextWithLongTitle = createStackWithOptions( + {}, + { + headerBackTitle: 'CustomBack', + headerTitle: 'LongLongLongLongLongLongLong', + }, +); + +const Button = ({ title, onPress }: { title: string; onPress: () => void }) => ( + + {title} ); @@ -58,7 +203,8 @@ function Home({ navigation: NativeStackNavigationProp; }) { return ( - +