From 712ff8cdba59bd5f8bb1790f60171e0f126e415c Mon Sep 17 00:00:00 2001 From: Zeya Peng Date: Mon, 10 Jun 2024 20:48:12 -0700 Subject: [PATCH] make RNTesterApp's back button customizable Summary: ## Changelog make RNTesterApp take a `customBackButton` prop to enable overriding whether to display back button and the look by default, only ios platform has a back button, and android app relies on back button on navigation bar that comes with platform [Internal] Reviewed By: christophpurrer Differential Revision: D58218208 fbshipit-source-id: 63a47390cc6d3de057b92a3c522c1b00d942c69d --- packages/rn-tester/js/RNTesterAppShared.js | 22 +++++++++-- .../rn-tester/js/components/RNTTitleBar.js | 37 ++++++------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/packages/rn-tester/js/RNTesterAppShared.js b/packages/rn-tester/js/RNTesterAppShared.js index a693a0768792cd..0e803557800f88 100644 --- a/packages/rn-tester/js/RNTesterAppShared.js +++ b/packages/rn-tester/js/RNTesterAppShared.js @@ -28,7 +28,9 @@ import { import * as React from 'react'; import { BackHandler, + Button, Linking, + Platform, StyleSheet, View, useColorScheme, @@ -36,13 +38,17 @@ import { // RNTester App currently uses in memory storage for storing navigation state +type BackButton = ({onBack: () => void}) => React.Node; + const RNTesterApp = ({ testList, + customBackButton, }: { testList?: { components?: Array, apis?: Array, }, + customBackButton?: BackButton, }): React.Node => { const [state, dispatch] = React.useReducer( RNTesterNavigationReducer, @@ -227,6 +233,14 @@ const RNTesterApp = ({ ? 'Components' : 'APIs'; + const BackButtonComponent: ?BackButton = customBackButton + ? customBackButton + : Platform.OS === 'ios' + ? ({onBack}) => ( +