mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
ADD: onScrollToIndexFailed for Wallet Carousel
This commit is contained in:
parent
0a7d027544
commit
1204032b20
@ -353,6 +353,17 @@ const WalletsCarousel = forwardRef((props, ref) => {
|
||||
},
|
||||
}));
|
||||
|
||||
const onScrollToIndexFailed = error => {
|
||||
console.log('onScrollToIndexFailed');
|
||||
console.log(error);
|
||||
flatListRef.current.scrollToOffset({ offset: error.averageItemLength * error.index, animated: true });
|
||||
setTimeout(() => {
|
||||
if (props.data.length !== 0 && flatListRef.current !== null) {
|
||||
flatListRef.scrollToIndex({ index: error.index, animated: true });
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
const { width } = useWindowDimensions();
|
||||
const sliderHeight = 190;
|
||||
const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82;
|
||||
@ -360,7 +371,7 @@ const WalletsCarousel = forwardRef((props, ref) => {
|
||||
<FlatList
|
||||
ref={flatListRef}
|
||||
renderItem={renderItem}
|
||||
extraData={renderItem}
|
||||
extraData={props.data}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
showsVerticalScrollIndicator={false}
|
||||
pagingEnabled
|
||||
@ -373,6 +384,7 @@ const WalletsCarousel = forwardRef((props, ref) => {
|
||||
initialNumToRender={10}
|
||||
ListHeaderComponent={ListHeaderComponent}
|
||||
style={props.horizontal ? { height: sliderHeight + 9 } : {}}
|
||||
onScrollToIndexFailed={onScrollToIndexFailed}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
@ -383,6 +395,7 @@ WalletsCarousel.propTypes = {
|
||||
selectedWallet: PropTypes.string,
|
||||
onPress: PropTypes.func.isRequired,
|
||||
handleLongPress: PropTypes.func.isRequired,
|
||||
data: PropTypes.array,
|
||||
};
|
||||
|
||||
export default WalletsCarousel;
|
||||
|
2
index.js
2
index.js
@ -5,7 +5,7 @@ import App from './App';
|
||||
import { BlueStorageProvider } from './blue_modules/storage-context';
|
||||
import { enableScreens } from 'react-native-screens';
|
||||
const A = require('./blue_modules/analytics');
|
||||
enableScreens(false)
|
||||
enableScreens(false);
|
||||
if (!Error.captureStackTrace) {
|
||||
// captureStackTrace is only available when debugging
|
||||
Error.captureStackTrace = () => {};
|
||||
|
Loading…
Reference in New Issue
Block a user