2022-09-25 18:08:27 -04:00
|
|
|
import React, { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
2020-05-28 11:44:15 +03:00
|
|
|
import {
|
|
|
|
View,
|
|
|
|
TouchableOpacity,
|
|
|
|
Text,
|
|
|
|
StyleSheet,
|
|
|
|
SectionList,
|
|
|
|
Platform,
|
2020-09-07 20:46:37 +03:00
|
|
|
Image,
|
2020-09-08 12:06:41 -04:00
|
|
|
Dimensions,
|
2020-10-08 16:03:57 -04:00
|
|
|
useWindowDimensions,
|
2021-02-26 19:23:59 -05:00
|
|
|
findNodeHandle,
|
2021-03-18 22:30:01 -04:00
|
|
|
I18nManager,
|
2024-02-15 18:35:21 -04:00
|
|
|
InteractionManager,
|
2020-05-28 11:44:15 +03:00
|
|
|
} from 'react-native';
|
2021-08-16 12:10:04 -04:00
|
|
|
import { BlueHeaderDefaultMain } from '../../BlueComponents';
|
2020-10-15 19:25:24 +03:00
|
|
|
import WalletsCarousel from '../../components/WalletsCarousel';
|
2018-09-01 00:28:19 +01:00
|
|
|
import { Icon } from 'react-native-elements';
|
2020-05-20 14:04:28 -04:00
|
|
|
import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
|
2020-05-28 11:44:15 +03:00
|
|
|
import ActionSheet from '../ActionSheet';
|
2020-07-20 16:38:46 +03:00
|
|
|
import loc from '../../loc';
|
2020-09-07 20:46:37 +03:00
|
|
|
import { FContainer, FButton } from '../../components/FloatButtons';
|
2024-03-24 10:52:10 -04:00
|
|
|
import { useFocusEffect, useIsFocused, useRoute } from '@react-navigation/native';
|
2020-10-24 13:20:59 -04:00
|
|
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
2023-02-25 12:20:46 -04:00
|
|
|
import { isDesktop, isTablet } from '../../blue_modules/environment';
|
2021-02-28 12:50:14 -05:00
|
|
|
import BlueClipboard from '../../blue_modules/clipboard';
|
2021-03-11 08:43:21 -05:00
|
|
|
import navigationStyle from '../../components/navigationStyle';
|
2021-08-16 12:10:04 -04:00
|
|
|
import { TransactionListItem } from '../../components/TransactionListItem';
|
2023-10-17 09:35:10 -04:00
|
|
|
import { scanQrHelper } from '../../helpers/scan-qr';
|
2023-10-23 21:28:44 -04:00
|
|
|
import { useTheme } from '../../components/themes';
|
2023-12-29 07:52:12 -04:00
|
|
|
import triggerHapticFeedback, { HapticFeedbackTypes } from '../../blue_modules/hapticFeedback';
|
2024-03-13 17:44:53 -04:00
|
|
|
import presentAlert from '../../components/Alert';
|
2024-03-24 10:52:10 -04:00
|
|
|
import { useExtendedNavigation } from '../../hooks/useExtendedNavigation';
|
2020-12-26 19:10:54 -05:00
|
|
|
|
2020-07-01 12:56:52 +01:00
|
|
|
const A = require('../../blue_modules/analytics');
|
2020-12-14 23:11:05 -05:00
|
|
|
const fs = require('../../blue_modules/fs');
|
2021-08-19 08:57:23 -04:00
|
|
|
const WalletsListSections = { CAROUSEL: 'CAROUSEL', TRANSACTIONS: 'TRANSACTIONS' };
|
2018-10-09 00:25:36 -04:00
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const WalletsList = () => {
|
|
|
|
const walletsCarousel = useRef();
|
2021-07-18 11:54:43 -04:00
|
|
|
const currentWalletIndex = useRef(0);
|
2024-02-15 11:13:20 -04:00
|
|
|
const {
|
|
|
|
wallets,
|
|
|
|
getTransactions,
|
|
|
|
getBalance,
|
|
|
|
refreshAllWalletTransactions,
|
|
|
|
setSelectedWalletID,
|
|
|
|
isElectrumDisabled,
|
|
|
|
setReloadTransactionsMenuActionFunction,
|
|
|
|
} = useContext(BlueStorageContext);
|
2020-10-08 16:03:57 -04:00
|
|
|
const { width } = useWindowDimensions();
|
2023-10-20 13:47:37 -04:00
|
|
|
const { colors, scanImage } = useTheme();
|
2024-03-24 10:52:10 -04:00
|
|
|
const { navigate, setOptions } = useExtendedNavigation();
|
2021-07-04 00:21:31 -04:00
|
|
|
const isFocused = useIsFocused();
|
2020-10-08 16:03:57 -04:00
|
|
|
const routeName = useRoute().name;
|
2020-10-24 13:20:59 -04:00
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
2020-10-08 16:03:57 -04:00
|
|
|
const [isLargeScreen, setIsLargeScreen] = useState(
|
2021-09-16 23:49:33 -04:00
|
|
|
Platform.OS === 'android' ? isTablet() : (width >= Dimensions.get('screen').width / 2 && isTablet()) || isDesktop,
|
2020-10-08 16:03:57 -04:00
|
|
|
);
|
2020-10-24 13:20:59 -04:00
|
|
|
const dataSource = getTransactions(null, 10);
|
2021-02-07 22:34:19 -05:00
|
|
|
const walletsCount = useRef(wallets.length);
|
2021-02-26 19:23:59 -05:00
|
|
|
const walletActionButtonsRef = useRef();
|
2020-10-08 16:03:57 -04:00
|
|
|
|
|
|
|
const stylesHook = StyleSheet.create({
|
|
|
|
walletsListWrapper: {
|
|
|
|
backgroundColor: colors.brandingColor,
|
|
|
|
},
|
|
|
|
listHeaderBack: {
|
|
|
|
backgroundColor: colors.background,
|
|
|
|
},
|
|
|
|
listHeaderText: {
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
},
|
|
|
|
});
|
2020-10-06 06:28:06 -04:00
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
useFocusEffect(
|
|
|
|
useCallback(() => {
|
2020-10-24 13:20:59 -04:00
|
|
|
verifyBalance();
|
2023-11-20 16:02:47 -04:00
|
|
|
setSelectedWalletID(undefined);
|
2024-02-15 18:35:21 -04:00
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
|
setReloadTransactionsMenuActionFunction(() => onRefresh);
|
|
|
|
});
|
2024-02-15 11:13:20 -04:00
|
|
|
return () => {
|
|
|
|
setReloadTransactionsMenuActionFunction(() => {});
|
|
|
|
};
|
2020-10-08 16:03:57 -04:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, []),
|
|
|
|
);
|
2018-01-30 22:42:38 +00:00
|
|
|
|
2020-10-24 13:20:59 -04:00
|
|
|
useEffect(() => {
|
2021-09-23 16:05:10 +03:00
|
|
|
// new wallet added
|
|
|
|
if (wallets.length > walletsCount.current) {
|
2021-06-16 02:05:04 -04:00
|
|
|
walletsCarousel.current?.scrollToItem({ item: wallets[walletsCount.current] });
|
2021-02-07 22:54:04 -05:00
|
|
|
}
|
2023-10-24 20:37:23 -04:00
|
|
|
|
2021-09-23 16:05:10 +03:00
|
|
|
walletsCount.current = wallets.length;
|
|
|
|
}, [wallets]);
|
2020-10-24 13:20:59 -04:00
|
|
|
|
|
|
|
const verifyBalance = () => {
|
|
|
|
if (getBalance() !== 0) {
|
|
|
|
A(A.ENUM.GOT_NONZERO_BALANCE);
|
|
|
|
} else {
|
|
|
|
A(A.ENUM.GOT_ZERO_BALANCE);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-09-25 18:08:27 -04:00
|
|
|
useLayoutEffect(() => {
|
2020-10-11 03:07:22 -04:00
|
|
|
setOptions({
|
2023-11-05 14:07:10 -04:00
|
|
|
navigationBarColor: colors.navigationBarColor,
|
2021-05-29 01:57:40 -04:00
|
|
|
headerShown: !isDesktop,
|
2020-10-11 03:07:22 -04:00
|
|
|
headerStyle: {
|
2021-09-14 01:36:00 -04:00
|
|
|
backgroundColor: colors.customHeader,
|
2020-10-11 03:07:22 -04:00
|
|
|
},
|
2023-07-25 14:50:04 +01:00
|
|
|
// eslint-disable-next-line react/no-unstable-nested-components
|
2021-03-18 22:30:01 -04:00
|
|
|
headerRight: () =>
|
|
|
|
I18nManager.isRTL ? null : (
|
2023-04-01 20:16:00 -04:00
|
|
|
<TouchableOpacity
|
|
|
|
accessibilityRole="button"
|
|
|
|
accessibilityLabel={loc._.more}
|
|
|
|
testID="SettingsButton"
|
|
|
|
style={styles.headerTouch}
|
|
|
|
onPress={navigateToSettings}
|
|
|
|
>
|
2022-06-19 17:17:33 +01:00
|
|
|
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} />
|
2021-03-18 22:30:01 -04:00
|
|
|
</TouchableOpacity>
|
|
|
|
),
|
2023-07-25 14:50:04 +01:00
|
|
|
// eslint-disable-next-line react/no-unstable-nested-components
|
2021-03-18 22:30:01 -04:00
|
|
|
headerLeft: () =>
|
|
|
|
I18nManager.isRTL ? (
|
2023-04-01 20:16:00 -04:00
|
|
|
<TouchableOpacity
|
|
|
|
accessibilityRole="button"
|
|
|
|
accessibilityLabel={loc._.more}
|
|
|
|
testID="SettingsButton"
|
|
|
|
style={styles.headerTouch}
|
|
|
|
onPress={navigateToSettings}
|
|
|
|
>
|
2022-06-19 17:17:33 +01:00
|
|
|
<Icon size={22} name="more-horiz" type="material" color={colors.foregroundColor} />
|
2021-03-18 22:30:01 -04:00
|
|
|
</TouchableOpacity>
|
|
|
|
) : null,
|
2020-10-11 03:07:22 -04:00
|
|
|
});
|
2024-01-22 22:05:40 -04:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [colors]);
|
|
|
|
|
|
|
|
const navigateToSettings = () => {
|
|
|
|
navigate('Settings');
|
|
|
|
};
|
2020-10-11 03:07:22 -04:00
|
|
|
|
2018-07-02 12:09:34 +01:00
|
|
|
/**
|
2020-11-13 15:14:49 +00:00
|
|
|
* Forcefully fetches TXs and balance for ALL wallets.
|
2018-12-25 19:07:43 +00:00
|
|
|
* Triggered manually by user on pull-to-refresh.
|
2018-07-02 12:09:34 +01:00
|
|
|
*/
|
2021-08-10 07:35:47 -07:00
|
|
|
const refreshTransactions = async (showLoadingIndicator = true, showUpdateStatusIndicator = false) => {
|
2021-08-24 00:33:32 -04:00
|
|
|
if (isElectrumDisabled) return setIsLoading(false);
|
2020-11-21 19:42:39 -05:00
|
|
|
setIsLoading(showLoadingIndicator);
|
2021-11-09 14:08:47 +03:00
|
|
|
refreshAllWalletTransactions(false, showUpdateStatusIndicator).finally(() => setIsLoading(false));
|
2020-10-08 16:03:57 -04:00
|
|
|
};
|
2018-06-24 23:22:46 +01:00
|
|
|
|
2020-11-21 19:42:39 -05:00
|
|
|
useEffect(() => {
|
2021-01-27 19:30:42 -05:00
|
|
|
refreshTransactions(false, true);
|
2020-11-13 15:14:49 +00:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2020-11-21 19:42:39 -05:00
|
|
|
}, []); // call refreshTransactions() only once, when screen mounts
|
2020-11-13 15:14:49 +00:00
|
|
|
|
2023-04-12 10:58:00 -05:00
|
|
|
const handleClick = item => {
|
|
|
|
if (item?.getID) {
|
|
|
|
const walletID = item.getID();
|
2021-07-18 11:54:43 -04:00
|
|
|
navigate('WalletTransactions', {
|
|
|
|
walletID,
|
2023-04-12 10:58:00 -05:00
|
|
|
walletType: item.type,
|
2021-07-18 11:54:43 -04:00
|
|
|
});
|
2023-04-12 10:58:00 -05:00
|
|
|
} else {
|
2020-10-24 13:20:59 -04:00
|
|
|
navigate('AddWalletRoot');
|
2018-06-24 23:22:46 +01:00
|
|
|
}
|
2020-05-17 08:17:08 -04:00
|
|
|
};
|
2018-06-24 23:22:46 +01:00
|
|
|
|
2021-06-16 02:05:04 -04:00
|
|
|
const onSnapToItem = e => {
|
2021-07-05 13:56:11 -04:00
|
|
|
if (!isFocused) return;
|
|
|
|
|
|
|
|
const contentOffset = e.nativeEvent.contentOffset;
|
|
|
|
const index = Math.ceil(contentOffset.x / width);
|
2021-07-18 11:54:43 -04:00
|
|
|
|
|
|
|
if (currentWalletIndex.current !== index) {
|
|
|
|
console.log('onSnapToItem', wallets.length === index ? 'NewWallet/Importing card' : index);
|
|
|
|
if (wallets[index] && (wallets[index].timeToRefreshBalance() || wallets[index].timeToRefreshTransaction())) {
|
|
|
|
console.log(wallets[index].getLabel(), 'thinks its time to refresh either balance or transactions. refetching both');
|
|
|
|
refreshAllWalletTransactions(index, false).finally(() => setIsLoading(false));
|
|
|
|
}
|
|
|
|
currentWalletIndex.current = index;
|
|
|
|
} else {
|
|
|
|
console.log('onSnapToItem did not change. Most likely momentum stopped at the same index it started.');
|
2020-11-13 15:14:49 +00:00
|
|
|
}
|
2020-10-08 16:03:57 -04:00
|
|
|
};
|
2018-09-18 03:24:42 -04:00
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderListHeaderComponent = () => {
|
2018-10-09 00:25:36 -04:00
|
|
|
return (
|
2020-10-08 16:03:57 -04:00
|
|
|
<View style={[styles.listHeaderBack, stylesHook.listHeaderBack]}>
|
2020-11-10 22:59:24 -05:00
|
|
|
<Text textBreakStrategy="simple" style={[styles.listHeaderText, stylesHook.listHeaderText]}>
|
|
|
|
{`${loc.transactions.list_title}${' '}`}
|
|
|
|
</Text>
|
2018-10-09 00:25:36 -04:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const handleLongPress = () => {
|
2021-09-23 16:05:10 +03:00
|
|
|
if (wallets.length > 1) {
|
2020-10-08 16:03:57 -04:00
|
|
|
navigate('ReorderWallets');
|
2018-12-18 01:05:03 -05:00
|
|
|
} else {
|
2023-12-29 07:52:12 -04:00
|
|
|
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
|
2018-12-11 22:52:46 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderTransactionListsRow = data => {
|
2020-03-26 21:15:00 +01:00
|
|
|
return (
|
2020-05-24 12:17:26 +03:00
|
|
|
<View style={styles.transaction}>
|
2021-12-17 05:41:18 -05:00
|
|
|
<TransactionListItem item={data.item} itemPriceUnit={data.item.walletPreferredBalanceUnit} walletID={data.item.walletID} />
|
2020-03-26 21:15:00 +01:00
|
|
|
</View>
|
|
|
|
);
|
2019-02-16 20:22:14 -05:00
|
|
|
};
|
2019-12-27 18:53:34 -06:00
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderWalletsCarousel = () => {
|
2020-05-16 21:41:38 -04:00
|
|
|
return (
|
|
|
|
<WalletsCarousel
|
2024-01-22 22:05:40 -04:00
|
|
|
data={wallets.concat(false)}
|
|
|
|
extraData={[wallets]}
|
2020-10-08 16:03:57 -04:00
|
|
|
onPress={handleClick}
|
|
|
|
handleLongPress={handleLongPress}
|
2021-06-16 02:05:04 -04:00
|
|
|
onMomentumScrollEnd={onSnapToItem}
|
2020-10-08 16:03:57 -04:00
|
|
|
ref={walletsCarousel}
|
2020-05-21 11:36:46 -04:00
|
|
|
testID="WalletsList"
|
2021-06-15 23:21:28 -04:00
|
|
|
horizontal
|
2021-07-04 00:21:31 -04:00
|
|
|
scrollEnabled={isFocused}
|
2020-05-16 21:41:38 -04:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderSectionItem = item => {
|
2020-05-16 21:41:38 -04:00
|
|
|
switch (item.section.key) {
|
|
|
|
case WalletsListSections.CAROUSEL:
|
2020-10-08 16:03:57 -04:00
|
|
|
return isLargeScreen ? null : renderWalletsCarousel();
|
2020-05-16 21:41:38 -04:00
|
|
|
case WalletsListSections.TRANSACTIONS:
|
2020-10-08 16:03:57 -04:00
|
|
|
return renderTransactionListsRow(item);
|
2020-05-16 21:41:38 -04:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderSectionHeader = section => {
|
|
|
|
switch (section.section.key) {
|
2020-05-16 21:41:38 -04:00
|
|
|
case WalletsListSections.CAROUSEL:
|
2024-01-22 22:05:40 -04:00
|
|
|
return isLargeScreen ? null : (
|
|
|
|
<BlueHeaderDefaultMain leftText={loc.wallets.list_title} onNewWalletPress={() => navigate('AddWalletRoot')} />
|
|
|
|
);
|
2020-05-16 21:41:38 -04:00
|
|
|
case WalletsListSections.TRANSACTIONS:
|
2020-10-08 16:03:57 -04:00
|
|
|
return renderListHeaderComponent();
|
2020-05-16 21:41:38 -04:00
|
|
|
default:
|
|
|
|
return null;
|
2018-01-30 22:42:38 +00:00
|
|
|
}
|
2020-05-16 21:41:38 -04:00
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderSectionFooter = section => {
|
|
|
|
switch (section.section.key) {
|
2020-05-17 08:17:08 -04:00
|
|
|
case WalletsListSections.TRANSACTIONS:
|
2020-10-08 16:03:57 -04:00
|
|
|
if (dataSource.length === 0 && !isLoading) {
|
2020-05-17 08:17:08 -04:00
|
|
|
return (
|
2021-03-02 16:38:02 +03:00
|
|
|
<View style={styles.footerRoot} testID="NoTransactionsMessage">
|
2020-07-20 16:38:46 +03:00
|
|
|
<Text style={styles.footerEmpty}>{loc.wallets.list_empty_txs1}</Text>
|
|
|
|
<Text style={styles.footerStart}>{loc.wallets.list_empty_txs2}</Text>
|
2020-05-17 08:17:08 -04:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const renderScanButton = () => {
|
2021-09-23 16:05:10 +03:00
|
|
|
if (wallets.length > 0) {
|
2020-05-21 20:21:08 -04:00
|
|
|
return (
|
2023-11-11 07:33:50 -04:00
|
|
|
<FContainer ref={walletActionButtonsRef.current}>
|
2020-09-07 20:46:37 +03:00
|
|
|
<FButton
|
2020-10-08 16:03:57 -04:00
|
|
|
onPress={onScanButtonPressed}
|
2023-02-25 12:24:06 -04:00
|
|
|
onLongPress={sendButtonLongPress}
|
2020-10-08 16:03:57 -04:00
|
|
|
icon={<Image resizeMode="stretch" source={scanImage} />}
|
2020-09-07 20:46:37 +03:00
|
|
|
text={loc.send.details_scan}
|
|
|
|
/>
|
|
|
|
</FContainer>
|
2020-05-21 20:21:08 -04:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2020-05-21 13:24:12 +02:00
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const sectionListKeyExtractor = (item, index) => {
|
2020-05-16 21:41:38 -04:00
|
|
|
return `${item}${index}}`;
|
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const onScanButtonPressed = () => {
|
2024-01-08 23:40:02 -04:00
|
|
|
scanQrHelper(navigate, routeName).then(onBarScanned);
|
2020-05-20 14:04:28 -04:00
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const onBarScanned = value => {
|
2021-03-20 13:00:01 +00:00
|
|
|
if (!value) return;
|
2020-05-20 14:04:28 -04:00
|
|
|
DeeplinkSchemaMatch.navigationRouteFor({ url: value }, completionValue => {
|
2023-12-29 07:52:12 -04:00
|
|
|
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
|
2020-10-08 16:03:57 -04:00
|
|
|
navigate(...completionValue);
|
2020-05-20 14:04:28 -04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-11-15 23:10:21 -05:00
|
|
|
const copyFromClipboard = async () => {
|
2023-03-29 20:46:11 -04:00
|
|
|
onBarScanned(await BlueClipboard().getClipboardContent());
|
2020-05-28 11:44:15 +03:00
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const sendButtonLongPress = async () => {
|
2023-03-29 20:46:11 -04:00
|
|
|
const isClipboardEmpty = (await BlueClipboard().getClipboardContent()).trim().length === 0;
|
2024-03-13 17:44:53 -04:00
|
|
|
|
|
|
|
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
|
|
|
|
if (!isClipboardEmpty) {
|
|
|
|
options.push(loc.wallets.list_long_clipboard);
|
2020-05-28 11:44:15 +03:00
|
|
|
}
|
2024-03-13 17:44:53 -04:00
|
|
|
|
|
|
|
ActionSheet.showActionSheetWithOptions(
|
|
|
|
{
|
|
|
|
title: loc.send.header,
|
|
|
|
options,
|
|
|
|
cancelButtonIndex: 0,
|
|
|
|
anchor: findNodeHandle(walletActionButtonsRef.current),
|
|
|
|
},
|
|
|
|
buttonIndex => {
|
|
|
|
switch (buttonIndex) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
fs.showImagePickerAndReadImage()
|
|
|
|
.then(onBarScanned)
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
|
|
|
|
presentAlert({ title: loc.errors.error, message: error.message });
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 2:
|
2024-03-13 18:03:02 -04:00
|
|
|
scanQrHelper(navigate, routeName, true).then(data => onBarScanned(data));
|
2024-03-13 17:44:53 -04:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!isClipboardEmpty) {
|
|
|
|
copyFromClipboard();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
2020-05-28 11:44:15 +03:00
|
|
|
};
|
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
const onLayout = _e => {
|
2021-09-16 23:49:33 -04:00
|
|
|
setIsLargeScreen(Platform.OS === 'android' ? isTablet() : (width >= Dimensions.get('screen').width / 2 && isTablet()) || isDesktop);
|
2020-09-08 12:06:41 -04:00
|
|
|
};
|
|
|
|
|
2021-01-27 19:30:42 -05:00
|
|
|
const onRefresh = () => {
|
|
|
|
refreshTransactions(true, false);
|
|
|
|
};
|
2024-02-16 10:42:21 -04:00
|
|
|
// Optimized for Mac option doesn't like RN Refresh component. Menu Elements now handles it for macOS
|
2024-02-16 10:13:52 -04:00
|
|
|
const refreshProps = isDesktop || isElectrumDisabled ? {} : { refreshing: isLoading, onRefresh };
|
2024-02-15 11:13:20 -04:00
|
|
|
|
2020-10-08 16:03:57 -04:00
|
|
|
return (
|
2021-01-04 20:44:28 -05:00
|
|
|
<View style={styles.root} onLayout={onLayout}>
|
|
|
|
<View style={[styles.walletsListWrapper, stylesHook.walletsListWrapper]}>
|
|
|
|
<SectionList
|
2023-04-03 09:02:25 -04:00
|
|
|
removeClippedSubviews
|
2021-08-19 15:56:59 -04:00
|
|
|
contentInsetAdjustmentBehavior="automatic"
|
|
|
|
automaticallyAdjustContentInsets
|
2024-02-15 11:13:20 -04:00
|
|
|
{...refreshProps}
|
2021-01-04 20:44:28 -05:00
|
|
|
renderItem={renderSectionItem}
|
|
|
|
keyExtractor={sectionListKeyExtractor}
|
|
|
|
renderSectionHeader={renderSectionHeader}
|
|
|
|
initialNumToRender={20}
|
|
|
|
contentInset={styles.scrollContent}
|
|
|
|
renderSectionFooter={renderSectionFooter}
|
|
|
|
sections={[
|
|
|
|
{ key: WalletsListSections.CAROUSEL, data: [WalletsListSections.CAROUSEL] },
|
|
|
|
{ key: WalletsListSections.TRANSACTIONS, data: dataSource },
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
{renderScanButton()}
|
|
|
|
</View>
|
|
|
|
</View>
|
2020-10-08 16:03:57 -04:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default WalletsList;
|
2021-09-14 01:36:00 -04:00
|
|
|
WalletsList.navigationOptions = navigationStyle({}, opts => ({ ...opts, headerTitle: '', headerBackTitle: loc.wallets.list_title }));
|
2019-12-27 18:53:34 -06:00
|
|
|
|
2020-07-06 17:04:44 +01:00
|
|
|
const styles = StyleSheet.create({
|
2021-01-04 20:44:28 -05:00
|
|
|
root: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
2020-07-06 17:04:44 +01:00
|
|
|
scrollContent: {
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
bottom: 60,
|
|
|
|
right: 0,
|
|
|
|
},
|
|
|
|
walletsListWrapper: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
headerTouch: {
|
|
|
|
height: 48,
|
|
|
|
paddingVertical: 10,
|
|
|
|
},
|
2020-07-16 18:41:20 +01:00
|
|
|
listHeaderBack: {
|
2020-08-20 18:50:38 -04:00
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center',
|
|
|
|
marginHorizontal: 16,
|
2020-07-16 18:41:20 +01:00
|
|
|
},
|
2020-07-06 17:04:44 +01:00
|
|
|
listHeaderText: {
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 24,
|
2021-08-19 15:27:57 +02:00
|
|
|
marginVertical: 16,
|
2020-07-06 17:04:44 +01:00
|
|
|
},
|
|
|
|
footerRoot: {
|
|
|
|
top: 80,
|
|
|
|
height: 160,
|
|
|
|
marginBottom: 80,
|
|
|
|
},
|
|
|
|
footerEmpty: {
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
footerStart: {
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
fontWeight: '600',
|
|
|
|
},
|
|
|
|
transaction: {
|
2020-10-13 17:37:58 +02:00
|
|
|
marginHorizontal: 0,
|
2020-07-06 17:04:44 +01:00
|
|
|
},
|
|
|
|
});
|