import AccountButton from '@components/AccountButton' import ComponentInstance from '@components/Instance' import CustomText from '@components/Text' import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useEffect, useRef } from 'react' import { useTranslation } from 'react-i18next' import { KeyboardAvoidingView, Platform, StyleSheet, View } from 'react-native' import { ScrollView } from 'react-native-gesture-handler' import { useSelector } from 'react-redux' const TabMeSwitch: React.FC = () => { const { t } = useTranslation('screenTabs') const { colors } = useTheme() const instances = useSelector(getInstances, () => true) const instanceActive = useSelector(getInstanceActive, () => true) const scrollViewRef = useRef(null) useEffect(() => { setTimeout( () => scrollViewRef.current?.scrollToEnd({ animated: true }), 150 ) }, [scrollViewRef.current]) return ( {t('me.switch.new')} {t('me.switch.existing')} {instances.length ? instances .slice() .sort((a, b) => `${a.uri}${a.account.acct}`.localeCompare( `${b.uri}${b.account.acct}` ) ) .map((instance, index) => { const localAccount = instances[instanceActive!] return ( ) }) : null} ) } export default TabMeSwitch