Skip to content

Commit

Permalink
Add educational tooltips for search filter and update bottom navigati…
Browse files Browse the repository at this point in the history
…on tooltip logic
  • Loading branch information
ishpaul777 committed Dec 12, 2024
1 parent c8b461d commit 07d8869
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 15 deletions.
33 changes: 27 additions & 6 deletions src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import React, {useMemo, useState} from 'react';
import {InteractionManager, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
Expand All @@ -8,6 +9,8 @@ import ConfirmModal from '@components/ConfirmModal';
import DecisionModal from '@components/DecisionModal';
import * as Expensicons from '@components/Icon/Expensicons';
import {usePersonalDetails} from '@components/OnyxProvider';
import {useProductTrainingContext} from '@components/ProductTrainingContext';
import EducationalTooltip from '@components/Tooltip/EducationalTooltip';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
Expand Down Expand Up @@ -55,6 +58,11 @@ function SearchPageHeader({queryJSON}: SearchPageHeaderProps) {
const [isDeleteExpensesConfirmModalVisible, setIsDeleteExpensesConfirmModalVisible] = useState(false);
const [isOfflineModalVisible, setIsOfflineModalVisible] = useState(false);
const [isDownloadErrorModalVisible, setIsDownloadErrorModalVisible] = useState(false);
const isFocused = useIsFocused();
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SEARCH_FILTER_BUTTON_TOOLTIP,
isFocused,
);

const {status, hash} = queryJSON;

Expand Down Expand Up @@ -348,12 +356,25 @@ function SearchPageHeader({queryJSON}: SearchPageHeaderProps) {
shouldUseStyleUtilityForAnchorPosition
/>
) : (
<Button
innerStyles={!isCannedQuery && [styles.searchRouterInputResults, styles.borderNone]}
text={translate('search.filtersHeader')}
icon={Expensicons.Filters}
onPress={onFiltersButtonPress}
/>
<EducationalTooltip
shouldRender={shouldShowProductTrainingTooltip}
anchorAlignment={{
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
}}
shiftHorizontal={variables.gbrTooltipShiftHorizontal}
wrapperStyle={styles.quickActionTooltipWrapper}
shouldUseOverlay
renderTooltipContent={renderProductTrainingTooltip}
onHideTooltip={hideProductTrainingTooltip}
>
<Button
innerStyles={!isCannedQuery && [styles.searchRouterInputResults, styles.borderNone]}
text={translate('search.filtersHeader')}
icon={Expensicons.Filters}
onPress={onFiltersButtonPress}
/>
</EducationalTooltip>
)}
</SearchPageHeaderInput>
<ConfirmModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function BottomTabBar({selectedTab}: BottomTabBarProps) {
const isFocused = useBottomTabIsFocused();
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.BOTTOM_NAV_INBOX_TOOLTIP,
selectedTab === SCREENS.HOME && isFocused,
selectedTab !== SCREENS.HOME && isFocused,
);

useEffect(() => {
Expand Down
9 changes: 6 additions & 3 deletions src/pages/Search/SearchTypeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ function SearchTypeMenu({queryJSON, searchName}: SearchTypeMenuProps) {
const {singleExecution} = useSingleExecution();
const {translate} = useLocalize();
const [savedSearches] = useOnyx(ONYXKEYS.SAVED_SEARCHES);
const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.RENAME_SAVED_SEARCH);
const {isOffline} = useNetwork();
const shouldShowSavedSearchesMenuItemTitle = Object.values(savedSearches ?? {}).filter((s) => s.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || isOffline).length > 0;
const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.RENAME_SAVED_SEARCH,
shouldShowSavedSearchesMenuItemTitle,
);
const {showDeleteModal, DeleteConfirmModal} = useDeleteSavedSearch();
const [session] = useOnyx(ONYXKEYS.SESSION);

const personalDetails = usePersonalDetails();
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const taxRates = getAllTaxRates();
const {isOffline} = useNetwork();

const typeMenuItems: SearchTypeMenuItem[] = [
{
Expand Down Expand Up @@ -245,7 +249,6 @@ function SearchTypeMenu({queryJSON, searchName}: SearchTypeMenuProps) {
/>
);
}
const shouldShowSavedSearchesMenuItemTitle = Object.values(savedSearches ?? {}).filter((s) => s.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || isOffline).length > 0;

return (
<ScrollView
Expand Down
30 changes: 25 additions & 5 deletions src/pages/Search/SearchTypeMenuNarrow.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import React, {useCallback, useMemo, useRef, useState} from 'react';
import {Animated, View} from 'react-native';
import type {TextStyle, ViewStyle} from 'react-native';
Expand All @@ -9,9 +10,11 @@ import {usePersonalDetails} from '@components/OnyxProvider';
import PopoverMenu from '@components/PopoverMenu';
import type {PopoverMenuItem} from '@components/PopoverMenu';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import {useProductTrainingContext} from '@components/ProductTrainingContext';
import type {SearchQueryJSON} from '@components/Search/types';
import Text from '@components/Text';
import ThreeDotsMenu from '@components/ThreeDotsMenu';
import EducationalTooltip from '@components/Tooltip/EducationalTooltip';
import useDeleteSavedSearch from '@hooks/useDeleteSavedSearch';
import useLocalize from '@hooks/useLocalize';
import useSingleExecution from '@hooks/useSingleExecution';
Expand Down Expand Up @@ -75,7 +78,12 @@ function SearchTypeMenuNarrow({typeMenuItems, activeItemIndex, queryJSON, title,
SearchActions.updateAdvancedFilters(values);
Navigation.navigate(ROUTES.SEARCH_ADVANCED_FILTERS);
};

const isFocused = useIsFocused();
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SEARCH_FILTER_BUTTON_TOOLTIP,
isFocused,
);
console.log('shouldShowProductTrainingTooltip', shouldShowProductTrainingTooltip, isFocused);

Check failure on line 86 in src/pages/Search/SearchTypeMenuNarrow.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected console statement
const currentSavedSearch = savedSearchesMenuItems.find((item) => Number(item.hash) === hash);

const popoverMenuItems = useMemo(() => {
Expand Down Expand Up @@ -200,10 +208,22 @@ function SearchTypeMenuNarrow({typeMenuItems, activeItemIndex, queryJSON, title,
</Animated.View>
)}
</PressableWithFeedback>
<Button
icon={Expensicons.Filters}
onPress={onPress}
/>
<EducationalTooltip
shouldRender={shouldShowProductTrainingTooltip}
anchorAlignment={{
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
}}
wrapperStyle={styles.quickActionTooltipWrapper}
shouldUseOverlay
renderTooltipContent={renderProductTrainingTooltip}
onHideTooltip={hideProductTrainingTooltip}
>
<Button
icon={Expensicons.Filters}
onPress={onPress}
/>
</EducationalTooltip>
<PopoverMenu
menuItems={allMenuItems as PopoverMenuItem[]}
isVisible={isPopoverVisible}
Expand Down

0 comments on commit 07d8869

Please sign in to comment.