From e0cc3fab1527afeca38629d485f39368e81eaeb3 Mon Sep 17 00:00:00 2001 From: JavidHaji-zada Date: Wed, 6 Dec 2023 12:12:07 +0400 Subject: [PATCH 1/4] navigation pop to top after sending funds --- src/screens/SendFunds/screens/SendFundsStatus/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/SendFunds/screens/SendFundsStatus/index.tsx b/src/screens/SendFunds/screens/SendFundsStatus/index.tsx index 7b9b53fd..bbcec5f9 100644 --- a/src/screens/SendFunds/screens/SendFundsStatus/index.tsx +++ b/src/screens/SendFunds/screens/SendFundsStatus/index.tsx @@ -59,7 +59,7 @@ export const SendFundsStatus = () => { }; const navigateToHome = () => { - navigation.replace('HomeScreen'); + navigation.popToTop(); reducer({ type: 'RESET_DATA' }); }; return ( From 9d77366f2e320e408959aa40568ca6d90f0a6c9a Mon Sep 17 00:00:00 2001 From: JavidHaji-zada Date: Wed, 6 Dec 2023 16:48:38 +0400 Subject: [PATCH 2/4] not round up wallet usd balance --- src/components/modular/WalletCard/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/modular/WalletCard/index.tsx b/src/components/modular/WalletCard/index.tsx index ab0662a2..0c8058c1 100644 --- a/src/components/modular/WalletCard/index.tsx +++ b/src/components/modular/WalletCard/index.tsx @@ -86,7 +86,10 @@ export const WalletCard = (props: WalletCardProps) => { fontFamily="Inter_500Medium" > $ - {NumberUtils.formatNumber(usdBalance, usdBalance > 0 ? 2 : 0)} + {NumberUtils.limitDecimalCount( + usdBalance, + usdBalance > 0 ? 2 : 0 + )} From 614ed0ff34b1e581cad7465cf7337b16171caab7 Mon Sep 17 00:00:00 2001 From: JavidHaji-zada Date: Wed, 6 Dec 2023 16:55:35 +0400 Subject: [PATCH 3/4] fix onRefresh behaviour --- src/components/modular/AnimatedTabs/index.tsx | 18 ++---------------- .../ExplorerAccount.Transactions.tsx | 19 +++++++++++++++++-- .../WalletAssets/index.tsx | 12 ++++++++++-- .../WalletTransactionsAndAssets/index.tsx | 6 ++++-- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/components/modular/AnimatedTabs/index.tsx b/src/components/modular/AnimatedTabs/index.tsx index 8867915d..1d55d32a 100644 --- a/src/components/modular/AnimatedTabs/index.tsx +++ b/src/components/modular/AnimatedTabs/index.tsx @@ -1,11 +1,5 @@ import React, { useEffect, useRef, useState } from 'react'; -import { - View, - ScrollView, - Dimensions, - ViewStyle, - RefreshControl -} from 'react-native'; +import { View, ScrollView, Dimensions, ViewStyle } from 'react-native'; import Animated, { useAnimatedStyle, useSharedValue, @@ -24,12 +18,10 @@ type AnimatedTab = { interface AnimatedTabsProps { tabs: AnimatedTab[]; containerStyle?: ViewStyle; - onRefresh?: () => unknown; - isRefreshing?: boolean; } export const AnimatedTabs = (props: AnimatedTabsProps) => { - const { tabs, containerStyle, onRefresh, isRefreshing } = props; + const { tabs, containerStyle } = props; const tabCount = tabs.length; const scrollView = useRef(null); const [currentIndex, setCurrentIndex] = useState(0); @@ -118,12 +110,6 @@ export const AnimatedTabs = (props: AnimatedTabsProps) => { setCurrentIndex(scrollOffsetX > 0 ? 1 : 0); }} contentContainerStyle={{ flexGrow: 1 }} - refreshControl={ - - } > {tabs.map(renderTabView)} diff --git a/src/components/templates/ExplorerAccount/ExplorerAccount.Transactions.tsx b/src/components/templates/ExplorerAccount/ExplorerAccount.Transactions.tsx index e3bc2e38..c70deb5c 100644 --- a/src/components/templates/ExplorerAccount/ExplorerAccount.Transactions.tsx +++ b/src/components/templates/ExplorerAccount/ExplorerAccount.Transactions.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { ListRenderItemInfo, + RefreshControl, SectionList, SectionListData, StyleSheet @@ -19,7 +20,9 @@ interface ExplorerAccountViewTransactionsProps { transactions: Transaction[]; loading?: boolean; showTransactionDetailsOnPress?: boolean; + isRefreshing?: boolean; onEndReached?: () => unknown; + onRefresh?: () => unknown; } interface TransactionSection { @@ -32,8 +35,14 @@ const DAY_FORMAT = 'MMM DD YYYY'; export const AccountTransactions = ( props: ExplorerAccountViewTransactionsProps ): JSX.Element => { - const { transactions, loading, showTransactionDetailsOnPress, onEndReached } = - props; + const { + transactions, + loading, + showTransactionDetailsOnPress, + isRefreshing, + onRefresh, + onEndReached + } = props; const { t } = useTranslation(); const sectionizedTransactions: TransactionSection[] = React.useMemo(() => { @@ -113,6 +122,12 @@ export const AccountTransactions = ( showsVerticalScrollIndicator={false} testID="Transactions_List" ListFooterComponent={() => (loading ? : <>)} + refreshControl={ + + } /> ); diff --git a/src/components/templates/WalletTransactionsAndAssets/WalletAssets/index.tsx b/src/components/templates/WalletTransactionsAndAssets/WalletAssets/index.tsx index e59b8728..efb1f4ed 100644 --- a/src/components/templates/WalletTransactionsAndAssets/WalletAssets/index.tsx +++ b/src/components/templates/WalletTransactionsAndAssets/WalletAssets/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { FlatList, View } from 'react-native'; +import { FlatList, View, RefreshControl } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { useTranslation } from 'react-i18next'; import { LocalizedRenderEmpty } from '@components/templates/LocalizedRenderEmpty'; @@ -14,10 +14,12 @@ interface WalletAssetsProps { loading: boolean; error: boolean; account: ExplorerAccount; + isRefreshing?: boolean; + onRefresh?: () => unknown; } export const WalletAssets = (props: WalletAssetsProps): JSX.Element => { - const { tokens, loading, account, error } = props; + const { tokens, loading, account, error, isRefreshing, onRefresh } = props; const navigation = useNavigation(); const { t } = useTranslation(); @@ -64,6 +66,12 @@ export const WalletAssets = (props: WalletAssetsProps): JSX.Element => { } contentContainerStyle={{ paddingBottom: '20%' }} showsVerticalScrollIndicator={false} + refreshControl={ + + } /> )} diff --git a/src/components/templates/WalletTransactionsAndAssets/index.tsx b/src/components/templates/WalletTransactionsAndAssets/index.tsx index 4d681130..44217f30 100644 --- a/src/components/templates/WalletTransactionsAndAssets/index.tsx +++ b/src/components/templates/WalletTransactionsAndAssets/index.tsx @@ -37,8 +37,6 @@ export const WalletTransactionsAndAssets = ( return ( ) }, @@ -57,7 +57,9 @@ export const WalletTransactionsAndAssets = ( ) } From 33ed3077e609bbd9bdb47a1f0b8c45403541dd1a Mon Sep 17 00:00:00 2001 From: JavidHaji-zada Date: Wed, 6 Dec 2023 17:04:03 +0400 Subject: [PATCH 4/4] add testing info in security settings --- src/contexts/Passcode/index.tsx | 4 +- .../screens/SecuritySettings/index.tsx | 75 ++++++++++++++++++- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/src/contexts/Passcode/index.tsx b/src/contexts/Passcode/index.tsx index 27bfce73..4cc806ef 100644 --- a/src/contexts/Passcode/index.tsx +++ b/src/contexts/Passcode/index.tsx @@ -6,7 +6,7 @@ import React, { useEffect, useState } from 'react'; -import { View } from 'react-native'; +import { Alert, View } from 'react-native'; import * as LocalAuthentication from 'expo-local-authentication'; import { useTranslation } from 'react-i18next'; import { Toast, ToastPosition, ToastType } from '@components/modular/Toast'; @@ -89,6 +89,8 @@ export const PasscodeProvider: FC<{ children: React.ReactNode }> = ({ if (result.success) { await PasscodeUtils.setFaceIDStatusInDB(true); setIsFaceIDEnabled(true); + } else { + Alert.alert(result.error, result.success || ''); } } else { // show error otherwise diff --git a/src/screens/Settings/screens/SecuritySettings/index.tsx b/src/screens/Settings/screens/SecuritySettings/index.tsx index bebb94cf..5a08849e 100644 --- a/src/screens/Settings/screens/SecuritySettings/index.tsx +++ b/src/screens/Settings/screens/SecuritySettings/index.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { StyleSheet, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import * as LocalAuthentication from 'expo-local-authentication'; @@ -12,12 +12,49 @@ import { COLORS } from '@constants/colors'; import { SettingsTabNavigationProp } from '@appTypes'; import { useSupportedBiometrics } from '@hooks'; import usePasscode from '@contexts/Passcode'; +import { Cache, CacheKey } from '@lib/cache'; export const SecuritySettingsScreen = () => { const { t } = useTranslation(); const supportedBiometrics = useSupportedBiometrics(); - const { toggleBiometricAuthentication, isFaceIDEnabled } = usePasscode(); + const { + toggleBiometricAuthentication, + isFaceIDEnabled, + isPasscodeEnabled, + savedPasscode + } = usePasscode(); const navigation = useNavigation(); + const [hasHardware, setHasHardware] = useState(false); + const [isEnrolled, setIsEnrolled] = useState(false); + const [isSetupSecurityInProgress, setIsSetupSecurityInProgress] = + useState(false); + const [ + isBiometricAuthenticationInProgress, + setIsBiometricAuthenticationInProgress + ] = useState(false); + + const checkHardware = async () => { + // check if device has biometric hardware + const hasHardware = await LocalAuthentication.hasHardwareAsync(); + // device has registered biometrics data, either fingerprint or face id + const isEnrolled = await LocalAuthentication.isEnrolledAsync(); + const isSetupSecurityInProgress = await Cache.getItem( + CacheKey.isSetupSecurityInProgress + ); + const isBiometricAuthenticationInProgress = await Cache.getItem( + CacheKey.isBiometricAuthenticationInProgress + ); + setHasHardware(hasHardware); + setIsEnrolled(isEnrolled); + setIsSetupSecurityInProgress(Boolean(isSetupSecurityInProgress)); + setIsBiometricAuthenticationInProgress( + Boolean(isBiometricAuthenticationInProgress) + ); + }; + + useEffect(() => { + checkHardware(); + }, []); const navigateToChangePasscode = useCallback(() => { navigation.navigate('ChangePasscode'); @@ -76,6 +113,40 @@ export const SecuritySettingsScreen = () => { )} + + + Face id enabled + {String(isFaceIDEnabled)} + + + Passcode enabled + {String(isPasscodeEnabled)} + + + Saved passcode + {savedPasscode?.length} + + + Biometrics + {supportedBiometrics.join(',')} + + + Has hardware + {String(hasHardware)} + + + Is enrolled + {String(isEnrolled)} + + + Biometric auth in progress + {String(isBiometricAuthenticationInProgress)} + + + Setup security progress + {String(isSetupSecurityInProgress)} + + ); };