using in app action modal

This commit is contained in:
noumantahir 2023-01-05 21:33:20 +05:00
parent 6c660e7217
commit 7f1b2b852f

View File

@ -20,6 +20,9 @@ import styles from './transferStyles';
import { OptionsModal } from '../../../components/atoms'; import { OptionsModal } from '../../../components/atoms';
import transferTypes from '../../../constants/transferTypes'; import transferTypes from '../../../constants/transferTypes';
import { getEngineActionJSON } from '../../../providers/hive-engine/hiveEngineActions'; import { getEngineActionJSON } from '../../../providers/hive-engine/hiveEngineActions';
import { useAppDispatch } from '../../../hooks';
import showLoginAlert from '../../../utils/showLoginAlert';
import { showActionModal } from '../../../redux/actions/uiAction';
const TransferView = ({ const TransferView = ({
currentAccountName, currentAccountName,
@ -35,6 +38,9 @@ const TransferView = ({
selectedAccount, selectedAccount,
fetchBalance, fetchBalance,
}) => { }) => {
const dispatch = useAppDispatch();
const [from, setFrom] = useState(currentAccountName); const [from, setFrom] = useState(currentAccountName);
const [destination, setDestination] = useState( const [destination, setDestination] = useState(
transferType === 'transfer_to_vesting' || transferType === 'transfer_to_vesting' ||
@ -66,8 +72,6 @@ const TransferView = ({
const [hsTransfer, setHsTransfer] = useState(false); const [hsTransfer, setHsTransfer] = useState(false);
const [isTransfering, setIsTransfering] = useState(false); const [isTransfering, setIsTransfering] = useState(false);
const confirm = useRef(null);
const isEngineToken = useMemo(()=>transferType.endsWith('_engine'), [transferType]); const isEngineToken = useMemo(()=>transferType.endsWith('_engine'), [transferType]);
const _handleTransferAction = () => { const _handleTransferAction = () => {
@ -147,17 +151,34 @@ const TransferView = ({
} }
} }
const _onNextPress = () => {
dispatch(showActionModal({
title:intl.formatMessage({ id: 'transfer.information' }),
buttons:[
{
text: intl.formatMessage({ id: 'alert.cancel' }),
onPress: ()=>{}
},
{
text: intl.formatMessage({ id: 'alert.confirm' }),
onPress:_handleTransferAction
}
]
}))
}
const nextBtnDisabled = !((isEngineToken ? amount > 0 : amount >= 0.001) && isUsernameValid); const nextBtnDisabled = !((isEngineToken ? amount > 0 : amount >= 0.001) && isUsernameValid);
return ( return (
<Fragment> <View style={styles.container}>
<BasicHeader <BasicHeader
title={intl.formatMessage({ id: `transfer.${transferType}` })} title={intl.formatMessage({ id: `transfer.${transferType}` })}
backIconName="close" backIconName="close"
/> />
<KeyboardAwareScrollView <KeyboardAwareScrollView
keyboardShouldPersistTaps keyboardShouldPersistTaps={'always'}
contentContainerStyle={[styles.grow, styles.keyboardAwareScrollContainer]} contentContainerStyle={[styles.grow, styles.keyboardAwareScrollContainer]}
> >
<View style={styles.container}> <View style={styles.container}>
@ -199,7 +220,7 @@ const TransferView = ({
<MainButton <MainButton
style={styles.button} style={styles.button}
isDisable={nextBtnDisabled} isDisable={nextBtnDisabled}
onPress={() => confirm.current.show()} onPress={_onNextPress}
isLoading={isTransfering} isLoading={isTransfering}
> >
<Text style={styles.buttonText}>{intl.formatMessage({ id: 'transfer.next' })}</Text> <Text style={styles.buttonText}>{intl.formatMessage({ id: 'transfer.next' })}</Text>
@ -208,19 +229,6 @@ const TransferView = ({
</View> </View>
</KeyboardAwareScrollView> </KeyboardAwareScrollView>
<OptionsModal
ref={confirm}
options={[
intl.formatMessage({ id: 'alert.confirm' }),
intl.formatMessage({ id: 'alert.cancel' }),
]}
title={intl.formatMessage({ id: 'transfer.information' })}
cancelButtonIndex={1}
destructiveButtonIndex={0}
onPress={(index) => {
index === 0 ? _handleTransferAction() : null;
}}
/>
{path && ( {path && (
<Modal <Modal
isOpen={hsTransfer} isOpen={hsTransfer}
@ -232,7 +240,7 @@ const TransferView = ({
<WebView source={{ uri: `${hsOptions.base_url}${path}` }} /> <WebView source={{ uri: `${hsOptions.base_url}${path}` }} />
</Modal> </Modal>
)} )}
</Fragment> </View>
); );
}; };