diff --git a/src/screens/ContactsScreen.tsx b/src/screens/ContactsScreen.tsx index 7650e182..eae145a3 100644 --- a/src/screens/ContactsScreen.tsx +++ b/src/screens/ContactsScreen.tsx @@ -80,6 +80,7 @@ export const ContactsScreen: FC = observer(function Contact const renderTabBar = (props: any) => ( = observer(fu const renderTabBar = (props: any) => ( = observer(function Wal const renderTabBar = (props: any) => ( = observer( const newMintUrl = scannedMintUrl || defaultMintUrl log.trace('newMintUrl', newMintUrl) - - // if(newMintUrl.includes('.onion')) { - // if(!userSettingsStore.isTorDaemonOn) { - // setInfo('Please enable Tor daemon in Privacy settings before connecting to the mint using .onion address.') - // return - // } - // } if (mintsStore.alreadyExists(newMintUrl)) { const msg = translate('walletScreen.mintExists') @@ -367,144 +361,39 @@ export const WalletScreen: FC = observer( const gotoProfile = function () { navigation.navigate('ContactsNavigator', {screen: 'Profile', params: {}, initial: false}) } - - /* Mints pager */ - - const width = spacing.screenWidth - const scrollOffsetAnimatedValue = React.useRef(new Animated.Value(0)).current - const positionAnimatedValue = React.useRef(new Animated.Value(0)).current - const inputRange = [0, groupedMints.length] - const scrollX = Animated.add( - scrollOffsetAnimatedValue, - positionAnimatedValue - ).interpolate({ - inputRange, - outputRange: [0, groupedMints.length * width], - }) - - const onPageScroll = React.useMemo( - () => - Animated.event( - [ - { - nativeEvent: { - offset: scrollOffsetAnimatedValue, - position: positionAnimatedValue, - }, - }, - ], - { - useNativeDriver: false, - } - ), - - // eslint-disable-next-line react-hooks/exhaustive-deps - [] - ) - - - const onPageSelected = (e: any) => { - if(groupedMints.length === 0) { - return - } - - const currentUnit = groupedMints[e.nativeEvent.position]?.unit - log.trace('[onPageSelected] currentUnit', currentUnit) - - setCurrentUnit(currentUnit) - - const preferredUnit = userSettingsStore.preferredUnit - - if(currentUnit !== preferredUnit) { // prevents db write on first load - userSettingsStore.setPreferredUnit(currentUnit) - } - } const handleError = function (e: AppError) { setIsLoading(false) setError(e) } - const balances = proofsStore.getBalances() - const screenBg = useThemeColor('background') - const mainButtonIcon = useThemeColor('button') - const mainButtonColor = useThemeColor('card') + // Tab view by unit + const [routes] = useState( + groupedMints.map((mintUnit) => ({ + key: mintUnit.unit, + title: getCurrency(mintUnit.unit).code, + })) + ) - return ( - -
} - /*leftIcon='faListUl' - leftIconColor={colors.palette.primary100} - onLeftPress={gotoTranHistory}*/ - TitleActionComponent={!isInternetReachable ? ( - - ) : ( - groupedMints.length > 1 ? ( - - ) : undefined - )} - RightActionComponent={ - <> - {paymentRequestsStore.countNotExpired > 0 && ( - gotoPaymentRequests()} - > - - - - )} - - } - /> - {groupedMints.length === 0 && ( - <> - - - - - - )} - - {groupedMints.map((mints) => ( - + const renderScene = function ({ route }: { route: { key: string } }) { + const unitMints = groupedMints.find((mintUnit) => mintUnit.unit === route.key); + + if (unitMints) { + return ( + balance.unit === mints.unit)!} + unitBalance={balances.unitBalances.find(balance => balance.unit === unitMints.unit)!} /> - {transactionsStore.recentByUnit(mints.unit).length > 0 && mints.mints.length < 4 && ( + {transactionsStore.recentByUnit(unitMints.unit).length > 0 && unitMints.mints.length < 4 && ( { return ( = observer( /> )} - - ))} - + + ) + } + return null; + } + + const tabWidth = moderateScale(80) + + const renderTabBar = (props: any) => ( + + + + + + ) + + + const [index, setIndex] = useState(0) + const headerBg = useThemeColor('header') + const activeTabIndicator = colors.palette.accent400 + const balances = proofsStore.getBalances() + const screenBg = useThemeColor('background') + const mainButtonIcon = useThemeColor('button') + const mainButtonColor = useThemeColor('card') + + return ( + +
} + TitleActionComponent={!isInternetReachable ? ( + + ) : ( undefined ) + } + RightActionComponent={ + <> + {paymentRequestsStore.countNotExpired > 0 && ( + gotoPaymentRequests()} + > + + + + )} + + } + /> + {groupedMints.length === 0 ? ( + <> + + + + + + ) : ( + + )}