diff --git a/suite-native/accounts/package.json b/suite-native/accounts/package.json index 160af400fc0..a4b22205d47 100644 --- a/suite-native/accounts/package.json +++ b/suite-native/accounts/package.json @@ -24,6 +24,7 @@ "@suite-common/wallet-utils": "workspace:*", "@suite-native/atoms": "workspace:*", "@suite-native/ethereum-tokens": "workspace:*", + "@suite-native/feature-flags": "workspace:*", "@suite-native/fiat-rates": "workspace:*", "@suite-native/formatters": "workspace:*", "@suite-native/forms": "workspace:*", diff --git a/suite-native/accounts/src/components/AddAccountsButton.tsx b/suite-native/accounts/src/components/AddAccountsButton.tsx index f29a9214f63..3655cffe0be 100644 --- a/suite-native/accounts/src/components/AddAccountsButton.tsx +++ b/suite-native/accounts/src/components/AddAccountsButton.tsx @@ -10,28 +10,40 @@ import { StackNavigationProps, } from '@suite-native/navigation'; import { IconButton } from '@suite-native/atoms'; -import { selectIsPortfolioTrackerDevice } from '@suite-common/wallet-core'; +import { selectDeviceDiscovery, selectIsPortfolioTrackerDevice } from '@suite-common/wallet-core'; + +import { useIsAddCoinAccountEnabled } from '../useIsAddCoinAccountEnabled'; export const AddAccountButton = () => { - const isSelectedDevicePortfolioTracker = useSelector(selectIsPortfolioTrackerDevice); const navigation = useNavigation>(); + const isSelectedDevicePortfolioTracker = useSelector(selectIsPortfolioTrackerDevice); + const discovery = useSelector(selectDeviceDiscovery); + + const { isAddCoinAccountEnabled } = useIsAddCoinAccountEnabled(); + + const shouldShowAddAccountButton = + isSelectedDevicePortfolioTracker || (isAddCoinAccountEnabled && !discovery); + const navigateToImportScreen = () => { navigation.navigate(RootStackRoutes.AccountsImport, { screen: AccountsImportStackRoutes.SelectNetwork, }); }; - const navigateToAddCoinAccount = () => - navigation.navigate(RootStackRoutes.AddCoinAccountStack, { - screen: AddCoinAccountStackRoutes.AddCoinAccount, - params: { - flowType: 'accounts', - }, - }); + const navigateToAddCoinAccount = () => { + if (isAddCoinAccountEnabled) { + navigation.navigate(RootStackRoutes.AddCoinAccountStack, { + screen: AddCoinAccountStackRoutes.AddCoinAccount, + params: { + flowType: 'accounts', + }, + }); + } + }; - return ( + return shouldShowAddAccountButton ? ( { colorScheme="tertiaryElevation0" size="medium" /> - ); + ) : null; }; diff --git a/suite-native/accounts/src/components/SearchableAccountsListScreenHeader.tsx b/suite-native/accounts/src/components/SearchableAccountsListScreenHeader.tsx index 8b39b46afa4..e6b8851880d 100644 --- a/suite-native/accounts/src/components/SearchableAccountsListScreenHeader.tsx +++ b/suite-native/accounts/src/components/SearchableAccountsListScreenHeader.tsx @@ -6,15 +6,10 @@ import Animated, { withDelay, withTiming, } from 'react-native-reanimated'; -import { useSelector } from 'react-redux'; import { ScreenSubHeader } from '@suite-native/navigation'; import { Box, IconButton } from '@suite-native/atoms'; import { prepareNativeStyle, useNativeStyles } from '@trezor/styles'; -import { - selectAreAllDevicesDisconnectedOrAccountless, - selectDeviceDiscovery, -} from '@suite-common/wallet-core'; import { AccountsSearchForm, SEARCH_INPUT_ANIMATION_DURATION } from './AccountsSearchForm'; import { AddAccountButton } from './AddAccountsButton'; @@ -39,10 +34,6 @@ export const SearchableAccountsListScreenHeader = ({ const isFirstRender = useSharedValue(true); const { applyStyle } = useNativeStyles(); - const discovery = useSelector(selectDeviceDiscovery); - const areAllDevicesDisconnectedOrAccountless = useSelector( - selectAreAllDevicesDisconnectedOrAccountless, - ); const [isSearchActive, setIsSearchActive] = useState(false); const handleHideFilter = () => { @@ -86,10 +77,7 @@ export const SearchableAccountsListScreenHeader = ({ > - } + rightIcon={} leftIcon={ { + const [isAddCoinAccountEnabled] = useFeatureFlag(FeatureFlag.IsAddCoinAccountEnabled); + const [isDeviceConnectEnabled] = useFeatureFlag(FeatureFlag.IsDeviceConnectEnabled); + + return { isAddCoinAccountEnabled: isDeviceConnectEnabled && isAddCoinAccountEnabled }; +}; diff --git a/suite-native/accounts/tsconfig.json b/suite-native/accounts/tsconfig.json index 6a1218e0f2c..ce52efb3ca2 100644 --- a/suite-native/accounts/tsconfig.json +++ b/suite-native/accounts/tsconfig.json @@ -29,6 +29,7 @@ }, { "path": "../atoms" }, { "path": "../ethereum-tokens" }, + { "path": "../feature-flags" }, { "path": "../fiat-rates" }, { "path": "../formatters" }, { "path": "../forms" }, diff --git a/suite-native/feature-flags/src/featureFlagsSlice.ts b/suite-native/feature-flags/src/featureFlagsSlice.ts index cf4ea6874b9..b0f290bd4e5 100644 --- a/suite-native/feature-flags/src/featureFlagsSlice.ts +++ b/suite-native/feature-flags/src/featureFlagsSlice.ts @@ -5,6 +5,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; export const FeatureFlag = { IsDeviceConnectEnabled: 'isDeviceConnectEnabled', IsPassphraseEnabled: 'isPassphraseEnabled', + IsAddCoinAccountEnabled: 'isAddCoinAccountEnabled', } as const; export type FeatureFlag = (typeof FeatureFlag)[keyof typeof FeatureFlag]; @@ -17,11 +18,13 @@ export type FeatureFlagsRootState = { export const featureFlagsInitialState: FeatureFlagsState = { [FeatureFlag.IsDeviceConnectEnabled]: Platform.OS === 'android', [FeatureFlag.IsPassphraseEnabled]: false, + [FeatureFlag.IsAddCoinAccountEnabled]: false, }; export const featureFlagsPersistedKeys: Array = [ FeatureFlag.IsDeviceConnectEnabled, FeatureFlag.IsPassphraseEnabled, + FeatureFlag.IsAddCoinAccountEnabled, ]; export const featureFlagsSlice = createSlice({ diff --git a/suite-native/module-dev-utils/src/components/FeatureFlags.tsx b/suite-native/module-dev-utils/src/components/FeatureFlags.tsx index c9c64d46b17..1857ee565a0 100644 --- a/suite-native/module-dev-utils/src/components/FeatureFlags.tsx +++ b/suite-native/module-dev-utils/src/components/FeatureFlags.tsx @@ -4,6 +4,7 @@ import { FeatureFlag as FeatureFlagEnum, useFeatureFlag } from '@suite-native/fe const featureFlagsTitleMap = { [FeatureFlagEnum.IsDeviceConnectEnabled]: 'Connect device', [FeatureFlagEnum.IsPassphraseEnabled]: 'Passphrase', + [FeatureFlagEnum.IsAddCoinAccountEnabled]: 'Add account', } as const satisfies Record; const FeatureFlag = ({ featureFlag }: { featureFlag: FeatureFlagEnum }) => { diff --git a/yarn.lock b/yarn.lock index 74c82d156d7..0e0a3716e73 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7765,6 +7765,7 @@ __metadata: "@suite-common/wallet-utils": "workspace:*" "@suite-native/atoms": "workspace:*" "@suite-native/ethereum-tokens": "workspace:*" + "@suite-native/feature-flags": "workspace:*" "@suite-native/fiat-rates": "workspace:*" "@suite-native/formatters": "workspace:*" "@suite-native/forms": "workspace:*"