Skip to content

Commit

Permalink
Remove RNTester Bookmarks (facebook#41016)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#41016

This hasn't been very useful since AsyncStorage/persistence was removed, but takes up a good amount of usable screen real-estate for information in the center of the screen. Remove it.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D50297980

fbshipit-source-id: 296a377dffc89c5c203ca6264351a2a1a8281cc3
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Oct 17, 2023
1 parent ab81c16 commit 26b4145
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 315 deletions.
33 changes: 5 additions & 28 deletions packages/rn-tester/js/RNTesterAppShared.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @flow
*/

import {RNTesterEmptyBookmarksState} from './components/RNTesterEmptyBookmarksState';
import RNTesterModuleContainer from './components/RNTesterModuleContainer';
import RNTesterModuleList from './components/RNTesterModuleList';
import RNTesterNavBar, {navBarHeight} from './components/RNTesterNavbar';
Expand All @@ -21,7 +20,7 @@ import {
} from './utils/RNTesterNavigationReducer';
import {
Screens,
getExamplesListWithBookmarksAndRecentlyUsed,
getExamplesListWithRecentlyUsed,
initialNavigationState,
} from './utils/testerStateUtils';
import * as React from 'react';
Expand All @@ -41,14 +40,12 @@ const RNTesterApp = (): React.Node => {
activeModuleTitle,
activeModuleExampleKey,
screen,
bookmarks,
recentlyUsed,
} = state;

const examplesList = React.useMemo(
() =>
getExamplesListWithBookmarksAndRecentlyUsed({bookmarks, recentlyUsed}),
[bookmarks, recentlyUsed],
() => getExamplesListWithRecentlyUsed({recentlyUsed}),
[recentlyUsed],
);

const handleBackPress = React.useCallback(() => {
Expand Down Expand Up @@ -97,16 +94,6 @@ const RNTesterApp = (): React.Node => {
[dispatch],
);

const toggleBookmark = React.useCallback(
({exampleType, key}: any) => {
dispatch({
type: RNTesterNavigationActionsType.BOOKMARK_PRESS,
data: {exampleType, key},
});
},
[dispatch],
);

const handleNavBarPress = React.useCallback(
(args: {screen: string}) => {
dispatch({
Expand Down Expand Up @@ -134,16 +121,10 @@ const RNTesterApp = (): React.Node => {
? activeModuleTitle
: screen === Screens.COMPONENTS
? 'Components'
: screen === Screens.APIS
? 'APIs'
: 'Bookmarks';
: 'APIs';

const activeExampleList =
screen === Screens.COMPONENTS
? examplesList.components
: screen === Screens.APIS
? examplesList.apis
: examplesList.bookmarks;
screen === Screens.COMPONENTS ? examplesList.components : examplesList.apis;

return (
<RNTesterThemeContext.Provider value={theme}>
Expand All @@ -163,13 +144,9 @@ const RNTesterApp = (): React.Node => {
example={activeModuleExample}
onExampleCardPress={handleModuleExampleCardPress}
/>
) : screen === Screens.BOOKMARKS &&
examplesList.bookmarks.length === 0 ? (
<RNTesterEmptyBookmarksState />
) : (
<RNTesterModuleList
sections={activeExampleList}
toggleBookmark={toggleBookmark}
handleModuleCardPress={handleModuleCardPress}
/>
)}
Expand Down
Binary file removed packages/rn-tester/js/assets/bookmark-filled.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed packages/rn-tester/js/assets/bookmark-outline.png
Binary file not shown.
3 changes: 0 additions & 3 deletions packages/rn-tester/js/components/RNTPressableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Props = {
testID?: ?string,
onPressIn?: ?() => mixed,
onPressOut?: ?() => mixed,
rightAddOn?: ?React.Node,
bottomAddOn?: ?React.Node,
children?: ?React.Node,
title: string,
Expand All @@ -34,7 +33,6 @@ export default function RNTPressableRow({
onPressOut,
title,
description,
rightAddOn,
bottomAddOn,
onPress,
style,
Expand All @@ -58,7 +56,6 @@ export default function RNTPressableRow({
onPress={onPress}>
<View style={styles.topRowStyle}>
<RNTesterComponentTitle>{title}</RNTesterComponentTitle>
{rightAddOn}
</View>
<Text
style={[styles.descriptionText, {color: theme.SecondaryLabelColor}]}>
Expand Down
60 changes: 0 additions & 60 deletions packages/rn-tester/js/components/RNTesterBookmarkButton.js

This file was deleted.

69 changes: 0 additions & 69 deletions packages/rn-tester/js/components/RNTesterEmptyBookmarksState.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/rn-tester/js/components/RNTesterExampleFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Props<T> = {
disableSearch?: boolean,
testID?: string,
hideFilterPills?: boolean,
page: 'examples_page' | 'components_page' | 'bookmarks_page',
page: 'examples_page' | 'components_page',
sections: $ReadOnlyArray<SectionData<T>>,
...
};
Expand Down
34 changes: 2 additions & 32 deletions packages/rn-tester/js/components/RNTesterModuleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ const RNTesterExampleFilter = require('./RNTesterExampleFilter');
import RNTPressableRow from './RNTPressableRow';
const React = require('react');

const {
Platform,
SectionList,
StyleSheet,
Text,
TouchableHighlight,
Image,
View,
} = require('react-native');
const {Platform, SectionList, StyleSheet, Text, View} = require('react-native');

import {RNTesterThemeContext} from './RNTesterTheme';

Expand All @@ -30,32 +22,12 @@ const ExampleModuleRow = ({
onShowUnderlay,
onHideUnderlay,
item,
toggleBookmark,
handlePress,
}) => {
const theme = React.useContext(RNTesterThemeContext);
const platform = item.module.platform;
const onIos = !platform || platform === 'ios';
const onAndroid = !platform || platform === 'android';
const rightAddOn = (
<TouchableHighlight
style={styles.imageViewStyle}
onPress={() =>
toggleBookmark({
exampleType: item.exampleType,
key: item.key,
})
}>
<Image
style={styles.imageStyle}
source={
item.isBookmarked
? require('../assets/bookmark-outline-blue.png')
: require('../assets/bookmark-outline-gray.png')
}
/>
</TouchableHighlight>
);
return (
<RNTPressableRow
title={item.module.title}
Expand All @@ -64,7 +36,6 @@ const ExampleModuleRow = ({
onPressIn={onShowUnderlay}
onPressOut={onHideUnderlay}
accessibilityLabel={item.module.title + ' ' + item.module.description}
rightAddOn={rightAddOn}
bottomAddOn={
<View style={styles.bottomRowStyle}>
<Text style={{color: theme.SecondaryLabelColor, width: 65}}>
Expand Down Expand Up @@ -119,7 +90,7 @@ const renderSectionHeader = ({section}: {section: any, ...}) => (
);

const RNTesterModuleList: React$AbstractComponent<any, void> = React.memo(
({sections, toggleBookmark, handleModuleCardPress}) => {
({sections, handleModuleCardPress}) => {
const filter = ({example, filterRegex, category}: any) =>
filterRegex.test(example.module.title) &&
(!category || example.category === category);
Expand All @@ -133,7 +104,6 @@ const RNTesterModuleList: React$AbstractComponent<any, void> = React.memo(
section={section}
onShowUnderlay={separators.highlight}
onHideUnderlay={separators.unhighlight}
toggleBookmark={toggleBookmark}
handlePress={handleModuleCardPress}
/>
);
Expand Down
47 changes: 0 additions & 47 deletions packages/rn-tester/js/components/RNTesterNavbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,6 @@ import {Text, View, StyleSheet, Image, Pressable} from 'react-native';

import {RNTesterThemeContext} from './RNTesterTheme';

const BookmarkTab = ({
handleNavBarPress,
isBookmarkActive,
theme,
}: {
handleNavBarPress: (data: {screen: string}) => void,
isBookmarkActive: boolean,
theme: RNTesterTheme,
}) => (
<View style={styles.centerBox}>
<View
style={[
styles.centralBoxCutout,
{backgroundColor: theme.BackgroundColor},
]}
/>
<View style={styles.floatContainer}>
<Pressable
testID="bookmarks-tab"
onPress={() => handleNavBarPress({screen: 'bookmarks'})}>
<View
style={[styles.floatingButton, {backgroundColor: theme.BorderColor}]}>
<Image
style={styles.bookmarkIcon}
source={
isBookmarkActive
? require('../assets/bottom-nav-bookmark-fill.png')
: require('../assets/bottom-nav-bookmark-outline.png')
}
/>
</View>
</Pressable>
</View>
</View>
);

/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
* LTI update could not be added via codemod */
const NavbarButton = ({
Expand Down Expand Up @@ -138,7 +102,6 @@ const RNTesterNavbar = ({

const isAPIActive = screen === 'apis' && !isExamplePageOpen;
const isComponentActive = screen === 'components' && !isExamplePageOpen;
const isBookmarkActive = screen === 'bookmarks' && !isExamplePageOpen;

return (
<View>
Expand All @@ -148,11 +111,6 @@ const RNTesterNavbar = ({
handleNavBarPress={handleNavBarPress}
theme={theme}
/>
<BookmarkTab
isBookmarkActive={isBookmarkActive}
handleNavBarPress={handleNavBarPress}
theme={theme}
/>
<APITab
isAPIActive={isAPIActive}
handleNavBarPress={handleNavBarPress}
Expand Down Expand Up @@ -190,11 +148,6 @@ const styles = StyleSheet.create({
shadowRadius: 10,
elevation: 5,
},
bookmarkIcon: {
width: 30,
height: 30,
margin: 10,
},
componentIcon: {
width: 20,
height: 20,
Expand Down
Loading

0 comments on commit 26b4145

Please sign in to comment.