From 8e16d3960e7e8ad2e34b14f1981c14758a00ade9 Mon Sep 17 00:00:00 2001 From: Javier Bueno Date: Thu, 21 Sep 2023 10:27:55 +0200 Subject: [PATCH 1/5] refactor: bottomsheet modal --- .../.storybook/storybook.requires.js | 1 + apps/wallet-mobile/src/components/index.ts | 1 + .../ConfirmTxScreen/ConfirmTxScreen.tsx | 50 ++++++++++++------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/apps/wallet-mobile/.storybook/storybook.requires.js b/apps/wallet-mobile/.storybook/storybook.requires.js index 746352407c..f1fc7e7b43 100644 --- a/apps/wallet-mobile/.storybook/storybook.requires.js +++ b/apps/wallet-mobile/.storybook/storybook.requires.js @@ -69,6 +69,7 @@ const getStories = () => { "./src/components/AmountItem/AmountItem.stories.tsx": require("../src/components/AmountItem/AmountItem.stories.tsx"), "./src/components/Analytics/Analytics.stories.tsx": require("../src/components/Analytics/Analytics.stories.tsx"), "./src/components/BlueCheckbox/BlueCheckbox.stories.tsx": require("../src/components/BlueCheckbox/BlueCheckbox.stories.tsx"), + "./src/components/BottomSheet/BottomSheet.stories.tsx": require("../src/components/BottomSheet/BottomSheet.stories.tsx"), "./src/components/BottomSheetModal/BottomSheetModal.stories.tsx": require("../src/components/BottomSheetModal/BottomSheetModal.stories.tsx"), "./src/components/Boundary/Boundary.stories.tsx": require("../src/components/Boundary/Boundary.stories.tsx"), "./src/components/Button/Button.stories.tsx": require("../src/components/Button/Button.stories.tsx"), diff --git a/apps/wallet-mobile/src/components/index.ts b/apps/wallet-mobile/src/components/index.ts index 762c9dd573..d4ed6ba8c4 100644 --- a/apps/wallet-mobile/src/components/index.ts +++ b/apps/wallet-mobile/src/components/index.ts @@ -1,5 +1,6 @@ export * from './Analytics' export * from './Banner' +export * from './BottomSheet' export * from './BottomSheetModal' export * from './Boundary' export * from './BulletPointItem' diff --git a/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/ConfirmTxScreen.tsx b/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/ConfirmTxScreen.tsx index d7fc085395..373189636d 100644 --- a/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/ConfirmTxScreen.tsx +++ b/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/ConfirmTxScreen.tsx @@ -3,8 +3,7 @@ import React from 'react' import {StyleSheet, View, ViewProps} from 'react-native' import {SafeAreaView} from 'react-native-safe-area-context' -import {Button} from '../../../../components' -import {BottomSheetModal} from '../../../../components/BottomSheetModal' +import {BottomSheet, BottomSheetRef, Button, Spacer} from '../../../../components' import {LoadingOverlay} from '../../../../components/LoadingOverlay' import {useWalletNavigation} from '../../../../navigation' import {useSelectedWallet} from '../../../../SelectedWallet' @@ -17,7 +16,15 @@ import {ConfirmTx} from './ConfirmTx' import {TransactionSummary} from './TransactionSummary' export const ConfirmTxScreen = () => { - const [confirmationModal, setConfirmationModal] = React.useState(false) + const bottomSheetRef = React.useRef(null) + + const openBottomSheet = () => { + bottomSheetRef.current?.openBottomSheet() + } + + const closeBottomSheet = () => { + bottomSheetRef.current?.closeBottomSheet() + } const strings = useStrings() const wallet = useSelectedWallet() @@ -62,27 +69,29 @@ export const ConfirmTxScreen = () => { authWithOs() return } - setConfirmationModal(true) + openBottomSheet() }} /> - { - setConfirmationModal(false) - }} - contentContainerStyle={{justifyContent: 'space-between'}} + isExtendable={false} > - resetToTxHistory()} - onCancel={() => setConfirmationModal(false)} - /> - + + resetToTxHistory()} + onCancel={closeBottomSheet} + /> + + + + @@ -102,4 +111,9 @@ const styles = StyleSheet.create({ actions: { paddingVertical: 16, }, + modalContent: { + flex: 1, + alignSelf: 'stretch', + paddingHorizontal: 16, + }, }) From 6bdea81ae2e827ca2aaf526b799ac7ec0f53cba0 Mon Sep 17 00:00:00 2001 From: Javier Bueno Date: Thu, 21 Sep 2023 10:32:19 +0200 Subject: [PATCH 2/5] refactor: bottomsheet modal --- .../BottomSheet/BottomSheet.stories.tsx | 114 ++++++++++++++ .../components/BottomSheet/BottomSheet.tsx | 144 ++++++++++++++++++ .../src/components/BottomSheet/index.ts | 1 + 3 files changed, 259 insertions(+) create mode 100644 apps/wallet-mobile/src/components/BottomSheet/BottomSheet.stories.tsx create mode 100644 apps/wallet-mobile/src/components/BottomSheet/BottomSheet.tsx create mode 100644 apps/wallet-mobile/src/components/BottomSheet/index.ts diff --git a/apps/wallet-mobile/src/components/BottomSheet/BottomSheet.stories.tsx b/apps/wallet-mobile/src/components/BottomSheet/BottomSheet.stories.tsx new file mode 100644 index 0000000000..e285acda3f --- /dev/null +++ b/apps/wallet-mobile/src/components/BottomSheet/BottomSheet.stories.tsx @@ -0,0 +1,114 @@ +import {storiesOf} from '@storybook/react-native' +import React from 'react' +import {Button, ScrollView, StyleSheet, Text, TextInput, View} from 'react-native' + +import {Spacer} from '../Spacer' +import {BottomSheet, BottomSheetRef} from './BottomSheet' + +storiesOf('BottomSheet', module) + .add('Default', () => ) + .add('Scroll + input (Keyboard) + extendable', () => ) + +const ComponentDefault = () => { + const bottomSheetRef = React.useRef(null) + + const openBottomSheet = () => { + bottomSheetRef.current?.openBottomSheet() + } + + const closeBottomSheet = () => { + bottomSheetRef.current?.closeBottomSheet() + } + + const handleClick = () => { + if (bottomSheetRef.current?.isOpen) closeBottomSheet() + else openBottomSheet() + } + + return ( + +