Merge branch 'master' into 841
This commit is contained in:
commit
d28ed3f706
@ -37,8 +37,9 @@ import { Transaction, TWallet } from '../class/wallets/types';
|
||||
import { BlueSpacing10 } from './BlueSpacing';
|
||||
import { useLocale } from '@react-navigation/native';
|
||||
|
||||
// Horizontal carousel shows a small peek of the next card; adjust overlap to control that spacing.
|
||||
const CARD_OVERLAP = 24;
|
||||
export const WALLET_CAROUSEL_HEADER_WIDTH = 16;
|
||||
|
||||
export const getWalletCarouselItemWidth = (screenWidth: number) => Math.round(screenWidth * 0.82 > 375 ? 375 : screenWidth * 0.82);
|
||||
|
||||
interface NewWalletPanelProps {
|
||||
onPress: () => void;
|
||||
@ -74,7 +75,7 @@ const nStyles = StyleSheet.create({
|
||||
const NewWalletPanel: React.FC<NewWalletPanelProps> = ({ onPress }) => {
|
||||
const { colors } = useTheme();
|
||||
const { width } = useWindowDimensions();
|
||||
const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82;
|
||||
const itemWidth = getWalletCarouselItemWidth(width);
|
||||
const { isLarge } = useSizeClass();
|
||||
const nStylesHooks = StyleSheet.create({
|
||||
container: isLarge
|
||||
@ -283,7 +284,7 @@ export const WalletCarouselItem: React.FC<WalletCarouselItemProps> = React.memo(
|
||||
const { colors } = useTheme();
|
||||
const { walletTransactionUpdateStatus } = useStorage();
|
||||
const { width } = useWindowDimensions();
|
||||
const itemWidth = width * 0.82 > 375 ? 375 : width * 0.82;
|
||||
const itemWidth = getWalletCarouselItemWidth(width);
|
||||
const { sizeClass } = useSizeClass();
|
||||
const isCompact = sizeVariant === 'compact';
|
||||
const { direction } = useLocale();
|
||||
@ -517,7 +518,7 @@ type FlatListRefType = FlatList<any> & {
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
listHeaderSeparator: {
|
||||
width: 16,
|
||||
width: WALLET_CAROUSEL_HEADER_WIDTH,
|
||||
height: 20,
|
||||
},
|
||||
});
|
||||
@ -540,7 +541,14 @@ const WalletsCarousel = forwardRef<FlatListRefType, WalletsCarouselProps>((props
|
||||
} = props;
|
||||
|
||||
const { width } = useWindowDimensions();
|
||||
const itemWidth = React.useMemo(() => (width * 0.82 > 375 ? 375 : width * 0.82), [width]);
|
||||
const itemWidth = React.useMemo(() => getWalletCarouselItemWidth(width), [width]);
|
||||
const snapInterval = React.useMemo(() => itemWidth, [itemWidth]);
|
||||
const snapOffsets = React.useMemo(() => {
|
||||
if (!horizontal) return undefined;
|
||||
const cardsCount = data.length + (onNewWalletPress ? 1 : 0);
|
||||
// Keep every card aligned with the first card's resting position.
|
||||
return Array.from({ length: cardsCount }, (_, index) => index * snapInterval);
|
||||
}, [horizontal, data.length, onNewWalletPress, snapInterval]);
|
||||
const layoutTransition = useMemo(() => LinearTransition.duration(240).easing(Easing.inOut(Easing.quad)), []);
|
||||
const enteringTransition = useMemo(() => FadeIn.duration(180), []);
|
||||
const exitingTransition = useMemo(() => FadeOut.duration(150), []);
|
||||
@ -858,9 +866,11 @@ const WalletsCarousel = forwardRef<FlatListRefType, WalletsCarouselProps>((props
|
||||
extraData={[data, animateChanges, newWalletsMap.current, selectedWallet, lastAddedWalletId.current]}
|
||||
keyExtractor={keyExtractor}
|
||||
showsVerticalScrollIndicator={false}
|
||||
pagingEnabled={horizontal}
|
||||
pagingEnabled={false}
|
||||
disableIntervalMomentum={horizontal}
|
||||
snapToInterval={horizontal ? itemWidth - CARD_OVERLAP : undefined}
|
||||
snapToInterval={undefined}
|
||||
snapToOffsets={snapOffsets}
|
||||
snapToAlignment={horizontal ? 'start' : undefined}
|
||||
decelerationRate="fast"
|
||||
contentContainerStyle={cStyles.content}
|
||||
directionalLockEnabled
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@ -100,7 +100,7 @@
|
||||
"react-native-screens": "4.24.0",
|
||||
"react-native-secure-key-store": "github:BlueWallet/react-native-secure-key-store#2076b4849e88aa0a78e08bfbb4ce3923e0925cbc",
|
||||
"react-native-share": "12.2.6",
|
||||
"react-native-svg": "15.15.3",
|
||||
"react-native-svg": "15.15.4",
|
||||
"react-native-tcp-socket": "6.4.1",
|
||||
"react-native-watch-connectivity": "1.1.0",
|
||||
"react-native-worklets": "0.7.4",
|
||||
@ -16222,7 +16222,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-svg": {
|
||||
"version": "15.15.3",
|
||||
"version": "15.15.4",
|
||||
"resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-15.15.4.tgz",
|
||||
"integrity": "sha512-boT/vIRgj6zZKBpfTPJJiYWMbZE9duBMOwPK6kCSTgxsS947IFMOq9OgIFkpWZTB7t229H24pDRkh3W9ZK/J1A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-select": "^5.1.0",
|
||||
|
||||
@ -182,7 +182,7 @@
|
||||
"react-native-screens": "4.24.0",
|
||||
"react-native-secure-key-store": "github:BlueWallet/react-native-secure-key-store#2076b4849e88aa0a78e08bfbb4ce3923e0925cbc",
|
||||
"react-native-share": "12.2.6",
|
||||
"react-native-svg": "15.15.3",
|
||||
"react-native-svg": "15.15.4",
|
||||
"react-native-tcp-socket": "6.4.1",
|
||||
"react-native-watch-connectivity": "1.1.0",
|
||||
"react-native-worklets": "0.7.4",
|
||||
|
||||
@ -11,7 +11,7 @@ import presentAlert from '../../components/Alert';
|
||||
import { FButton, FContainer } from '../../components/FloatButtons';
|
||||
import { useTheme } from '../../components/themes';
|
||||
import { TransactionListItem } from '../../components/TransactionListItem';
|
||||
import WalletsCarousel from '../../components/WalletsCarousel';
|
||||
import WalletsCarousel, { getWalletCarouselItemWidth } from '../../components/WalletsCarousel';
|
||||
import { useSizeClass, SizeClass } from '../../blue_modules/sizeClass';
|
||||
import loc from '../../loc';
|
||||
import ActionSheet from '../ActionSheet';
|
||||
@ -237,10 +237,13 @@ const WalletsList: React.FC = () => {
|
||||
if (!isFocused) return;
|
||||
|
||||
const contentOffset = e.nativeEvent.contentOffset;
|
||||
const index = Math.ceil(contentOffset.x / width);
|
||||
const cardWidth = getWalletCarouselItemWidth(width);
|
||||
const snapStep = cardWidth; // keep in sync with WalletsCarousel snap interval
|
||||
const index = Math.max(0, Math.round(contentOffset.x / snapStep));
|
||||
|
||||
if (currentWalletIndex.current !== index) {
|
||||
console.debug('onSnapToItem', wallets.length === index ? 'NewWallet/Importing card' : index);
|
||||
triggerHapticFeedback(HapticFeedbackTypes.Selection);
|
||||
if (wallets[index] && (wallets[index].timeToRefreshBalance() || wallets[index].timeToRefreshTransaction())) {
|
||||
refreshWallets(index, false, false);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user