From 65e1251f38a16b7f133bc807c81b700c98465f0d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 16 Apr 2024 16:58:16 +0700 Subject: [PATCH 1/6] feature: add props isSplit to button with dropdown --- .../ButtonWithDropdownMenu/index.tsx | 76 ++++++++++++------- .../ButtonWithDropdownMenu/types.ts | 3 + src/pages/workspace/WorkspaceMembersPage.tsx | 1 + .../categories/WorkspaceCategoriesPage.tsx | 1 + .../distanceRates/PolicyDistanceRatesPage.tsx | 1 + .../workspace/tags/WorkspaceTagsPage.tsx | 1 + .../workspace/taxes/WorkspaceTaxesPage.tsx | 1 + 7 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/components/ButtonWithDropdownMenu/index.tsx b/src/components/ButtonWithDropdownMenu/index.tsx index a4e6e2c87fec..7ee225ad9ace 100644 --- a/src/components/ButtonWithDropdownMenu/index.tsx +++ b/src/components/ButtonWithDropdownMenu/index.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useRef, useState} from 'react'; +import React, {useEffect, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import Button from '@components/Button'; import Icon from '@components/Icon'; @@ -10,10 +10,12 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import CONST from '@src/CONST'; import type {AnchorPosition} from '@src/styles'; +import type IconAsset from '@src/types/utils/IconAsset'; import type {ButtonWithDropdownMenuProps} from './types'; function ButtonWithDropdownMenu({ success = false, + isSplit = true, isLoading = false, isDisabled = false, pressOnEnter = false, @@ -40,7 +42,7 @@ function ButtonWithDropdownMenu({ const [isMenuVisible, setIsMenuVisible] = useState(false); const [popoverAnchorPosition, setPopoverAnchorPosition] = useState(null); const {windowWidth, windowHeight} = useWindowDimensions(); - const caretButton = useRef(null); + const caretButton = useRef(null); const selectedItem = options[selectedItemIndex] || options[0]; const innerStyleDropButton = StyleUtils.getDropDownButtonHeight(buttonSize); const isButtonSizeLarge = buttonSize === CONST.DROPDOWN_BUTTON_SIZE.LARGE; @@ -65,6 +67,18 @@ function ButtonWithDropdownMenu({ } }, [windowWidth, windowHeight, isMenuVisible, anchorAlignment.vertical]); + const iconRight = useMemo( + () => ( + + ), + [isButtonSizeLarge, success, theme.buttonSuccessText, theme.icon], + ); + return ( {shouldAlwaysShowDropdownMenu || options.length > 1 ? ( @@ -72,8 +86,10 @@ function ButtonWithDropdownMenu({ + + )} ) : (