Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace swap slider with swap button #12030

Merged
merged 6 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import ScreenView from '../../Base/ScreenView';
import Text from '../../Base/Text';
import Alert, { AlertType } from '../../Base/Alert';
import StyledButton from '../StyledButton';
import SliderButton from '../SliderButton';

import LoadingAnimation from './components/LoadingAnimation';
import TokenIcon from './components/TokenIcon';
Expand Down Expand Up @@ -444,6 +443,7 @@ function SwapsQuotesView({
const [trackedError, setTrackedError] = useState(false);
const [animateOnGasChange, setAnimateOnGasChange] = useState(false);
const [isAnimating, setIsAnimating] = useState(false);
const [isHandlingSwap, setIsHandlingSwap] = useState(false);
const [multiLayerL1ApprovalFeeTotal, setMultiLayerL1ApprovalFeeTotal] =
useState(null);

Expand All @@ -460,8 +460,6 @@ function SwapsQuotesView({
const [customGasEstimate, setCustomGasEstimate] = useState(null);
const [customGasLimit, setCustomGasLimit] = useState(null);

const [isSwiping, setIsSwiping] = useState(false);

// TODO: use this variable in the future when calculating savings
const [isSaving] = useState(false);
const [isInFetch, setIsInFetch] = useState(false);
Expand Down Expand Up @@ -1072,7 +1070,10 @@ function SwapsQuotesView({
);

const handleCompleteSwap = useCallback(async () => {
setIsHandlingSwap(true);

if (!selectedQuote) {
setIsHandlingSwap(false);
return;
}

Expand All @@ -1088,6 +1089,7 @@ function SwapsQuotesView({
);

if (isHardwareAddress) {
setIsHandlingSwap(false);
navigation.dangerouslyGetParent()?.pop();
return;
}
Expand All @@ -1100,6 +1102,7 @@ function SwapsQuotesView({
await handleSwapTransaction(approvalTransactionMetaId);
}

setIsHandlingSwap(false);
navigation.dangerouslyGetParent()?.pop();
}, [
selectedQuote,
Expand Down Expand Up @@ -1720,7 +1723,6 @@ function SwapsQuotesView({
contentContainerStyle={styles.screen}
style={styles.container}
keyboardShouldPersistTaps="handled"
scrollEnabled={!isSwiping}
>
<View style={styles.topBar}>
{(!hasEnoughTokenBalance || !hasEnoughEthBalance) && (
Expand Down Expand Up @@ -2155,24 +2157,9 @@ function SwapsQuotesView({
</QuotesSummary.Body>
</QuotesSummary>
)}
<SliderButton
incompleteText={
<Text style={styles.sliderButtonText}>
{`${strings('swaps.swipe_to')} `}
<Text reset bold>
{strings('swaps.swap')}
</Text>
</Text>
}
onSwipeChange={setIsSwiping}
completeText={
<Text style={styles.sliderButtonText}>
{strings('swaps.completed_swap')}
</Text>
}
disabled={unableToSwap || isAnimating}
onComplete={handleCompleteSwap}
/>
<StyledButton type="confirm" onPress={handleCompleteSwap} disabled={unableToSwap || isHandlingSwap || isAnimating}>
{strings('swaps.swap')}
</StyledButton>
<TouchableOpacity onPress={handleTermsPress} style={styles.termsButton}>
<Text link centered>
{strings('swaps.terms_of_service')}
Expand Down
2 changes: 1 addition & 1 deletion locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2777,7 +2777,7 @@
"tap_to_swap": "Tap to Swap",
"swipe_to_swap": "Swipe to swap",
"swipe_to": "Swipe to",
"swap": "swap",
"swap": "Swap",
"completed_swap": "Swap!",
"metamask_swap_fee": "MetaMask Swap fee",
"fee_text": {
Expand Down
Loading