diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 73fc60e60..e606152ed 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -30,7 +30,7 @@ "@bogoslavskiy/react-native-steezy": "^1.0.4", "@craftzdog/react-native-buffer": "^6.0.5", "@expo/react-native-action-sheet": "^4.0.1", - "@gorhom/bottom-sheet": "^4.4.7", + "@gorhom/bottom-sheet": "^4.6.0", "@rainbow-me/animated-charts": "https://github.com/tonkeeper/react-native-animated-charts#65f723604f3abc8a05ecfa2918fe9b0b42fd8363", "@react-native-async-storage/async-storage": "^1.15.5", "@react-native-community/clipboard": "^1.5.1", diff --git a/packages/mobile/patches/@gorhom+bottom-sheet+4.6.0.patch b/packages/mobile/patches/@gorhom+bottom-sheet+4.6.0.patch new file mode 100644 index 000000000..987b883f2 --- /dev/null +++ b/packages/mobile/patches/@gorhom+bottom-sheet+4.6.0.patch @@ -0,0 +1,130 @@ +diff --git a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx +index f20e3dc..0a0e283 100644 +--- a/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx ++++ b/node_modules/@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx +@@ -692,9 +692,9 @@ const BottomSheetComponent = forwardRef( + method: animateToPosition.name, + params: { + currentPosition: animatedPosition.value, +- position, ++ nextPosition: position, + velocity, +- animatedContainerHeight: animatedContainerHeight.value, ++ source, + }, + }); + +@@ -742,6 +742,47 @@ const BottomSheetComponent = forwardRef( + }, + [handleOnAnimate, _providedAnimationConfigs] + ); ++ /** ++ * Set to position without animation. ++ * ++ * @param targetPosition position to be set. ++ */ ++ const setToPosition = useWorkletCallback(function setToPosition( ++ targetPosition: number ++ ) { ++ if ( ++ targetPosition === animatedPosition.value || ++ targetPosition === undefined || ++ (animatedAnimationState.value === ANIMATION_STATE.RUNNING && ++ targetPosition === animatedNextPosition.value) ++ ) { ++ return; ++ } ++ ++ runOnJS(print)({ ++ component: BottomSheet.name, ++ method: setToPosition.name, ++ params: { ++ currentPosition: animatedPosition.value, ++ targetPosition, ++ }, ++ }); ++ ++ /** ++ * store next position ++ */ ++ animatedNextPosition.value = targetPosition; ++ animatedNextPositionIndex.value = ++ animatedSnapPoints.value.indexOf(targetPosition); ++ ++ stopAnimation(); ++ ++ /** ++ * set position. ++ */ ++ animatedPosition.value = targetPosition; ++ }, ++ []); + //#endregion + + //#region public methods +@@ -1320,16 +1361,8 @@ const BottomSheetComponent = forwardRef( + animatedNextPositionIndex.value === -1 && + _previousContainerHeight !== containerHeight + ) { +- animationSource = ANIMATION_SOURCE.CONTAINER_RESIZE; +- animationConfig = { +- duration: 0, +- }; +- animateToPosition( +- containerHeight, +- animationSource, +- 0, +- animationConfig +- ); ++ setToPosition(containerHeight); ++ return; + } + + if ( +@@ -1370,13 +1403,11 @@ const BottomSheetComponent = forwardRef( + + /** + * if snap points changes because of the container height change, +- * then we skip the snap animation by setting the duration to 0. ++ * then we set the new position without animation. + */ + if (containerHeight !== _previousContainerHeight) { +- animationSource = ANIMATION_SOURCE.CONTAINER_RESIZE; +- animationConfig = { +- duration: 0, +- }; ++ setToPosition(nextPosition); ++ return; + } + } + animateToPosition(nextPosition, animationSource, 0, animationConfig); +@@ -1515,6 +1546,7 @@ const BottomSheetComponent = forwardRef( + }), + ({ + _animatedIndex, ++ _animatedPosition, + _animationState, + _contentGestureState, + _handleGestureState, +@@ -1526,6 +1558,21 @@ const BottomSheetComponent = forwardRef( + return; + } + ++ /** ++ * exit the method if index value is not synced with ++ * position value. ++ * ++ * [read more](https://github.com/gorhom/react-native-bottom-sheet/issues/1356) ++ */ ++ if ( ++ animatedNextPosition.value !== INITIAL_VALUE && ++ animatedNextPositionIndex.value !== INITIAL_VALUE && ++ (_animatedPosition !== animatedNextPosition.value || ++ _animatedIndex !== animatedNextPositionIndex.value) ++ ) { ++ return; ++ } ++ + /** + * exit the method if animated index value + * has fraction, e.g. 1.99, 0.52 diff --git a/packages/uikit/src/components/Button.tsx b/packages/uikit/src/components/Button.tsx index b62222597..f06c28e0a 100644 --- a/packages/uikit/src/components/Button.tsx +++ b/packages/uikit/src/components/Button.tsx @@ -13,7 +13,7 @@ import { Theme, useTheme } from '../styles'; import { Loader } from './Loader'; import { Text } from './Text'; import { ns } from '../utils'; -import { IconNames, Icon, IconColors } from '@tonkeeper/uikit'; +import { IconNames, Icon, IconColors } from './Icon'; export type ButtonColors = 'green' | 'primary' | 'secondary' | 'tertiary'; export type ButtonSizes = 'large' | 'medium' | 'small' | 'header' | 'icon'; diff --git a/yarn.lock b/yarn.lock index d7021bbe0..2ee1691cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1932,10 +1932,10 @@ resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== -"@gorhom/bottom-sheet@^4.4.7": - version "4.4.7" - resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-4.4.7.tgz#fc80b3f0b7ebab056ce226f3aa3a89b2db8660dd" - integrity sha512-ukTuTqDQi2heo68hAJsBpUQeEkdqP9REBcn47OpuvPKhdPuO1RBOOADjqXJNCnZZRcY+HqbnGPMSLFVc31zylQ== +"@gorhom/bottom-sheet@^4.6.0": + version "4.6.0" + resolved "https://registry.yarnpkg.com/@gorhom/bottom-sheet/-/bottom-sheet-4.6.0.tgz#16bebbe4f5925447ece0d727830cf1776d5620f8" + integrity sha512-XgNflkhATUqTIiMDGuLaQZAtjUzcrhGOEJGHT+7Tou1ctTMb958YRGGnU9KFo5TkD6YCZcfWfxHPi9F0FF+DjA== dependencies: "@gorhom/portal" "1.0.14" invariant "^2.2.4"