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

[5.3] Skip to amount to buy when region is selected #4442

Merged
merged 38 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
76515a4
5.2.0
metamaskbot May 16, 2022
3dad3f1
Format changelog
Cal-L May 16, 2022
5381c67
Fix check for empty tokens list (#4345)
wachunei May 16, 2022
a155f0d
Fix homepage scripts and env import (#4344)
Fatxx May 16, 2022
5737d9c
Make reveal SRP blur view dynamic (#4315)
Cal-L May 16, 2022
cd244bf
Update changelog
Cal-L May 17, 2022
3becfde
Bugfix/fix subtitle mapping (#4349)
rickycodes May 17, 2022
6c43e4b
Update changelog
Cal-L May 17, 2022
047fc0c
Update build numbers
Cal-L May 17, 2022
13ab998
[5.2.0][FIX] Alignment of check icon with option on select component …
tommasini May 23, 2022
3ca296c
[5.2.0][FIX] Secret Recovery Phrase text alignment (#4369)
tommasini May 23, 2022
37442a4
[5.2.0][FIX] M3 - Warning on legit address (#4376)
tommasini May 23, 2022
bd64bd0
Fixes double tab opening when using `metamask://dapp/` deep link sche…
andreahaku May 23, 2022
494f328
Fix order id retrieve in checkout (#4366)
wachunei May 23, 2022
8a22652
Fix overriding network and account for orders being processed (#4364)
wachunei May 23, 2022
8cb3f1d
Error handling when no crypto currencies available on selected region…
alaahd May 23, 2022
e809f0a
bug patch - tx-details to display provider link and integrate the or…
VikChawla May 23, 2022
ebccb9a
Refactor "Transaction" to "Order" when referring to fiat order (#4375)
wachunei May 23, 2022
8727fc0
Add On-Ramp Aggregator Analytics (#4362)
wachunei May 23, 2022
addd65a
Bump build number
May 23, 2022
f038c72
[FIX] Add margin and check to AssetActionButton text (#4381)
May 24, 2022
fc971dc
Additional fixes for double tab opened with metamask://dapp/ schema (…
andreahaku May 25, 2022
3525dfe
Remove canOpenUrl from onramp linking (#4391)
wachunei May 25, 2022
d324963
Fix provider support string (#4387)
wachunei May 25, 2022
c18c22b
Bump build number
May 25, 2022
4aace57
Fix wrong analytics event (#4408)
wachunei May 26, 2022
ef3ac7b
Remove Harmony from supported networks (#4409)
wachunei May 26, 2022
7ba7892
removes `metamask://dapp/` schema support until stable on Android (#4…
andreahaku May 26, 2022
58b78c9
Bump build number
andreahaku May 26, 2022
e2e5480
Update CHANGELOG
May 31, 2022
2da37c2
Skip to amount to buy when region is selected
wachunei Jun 3, 2022
bfc6e6b
Redirect to Region screen when current region is unsupported
wachunei Jun 3, 2022
978202b
Merge branch 'main' into feature/onramp-skip-screens
wachunei Jun 8, 2022
bd0fa68
Merge branch 'main' into feature/onramp-skip-screens
wachunei Jun 13, 2022
0eb7b01
Merge branch 'main' into feature/onramp-skip-screens
wachunei Jun 13, 2022
4aa3ca2
Merge branch 'main' into feature/onramp-skip-screens
wachunei Jun 13, 2022
5974c84
Merge branch 'main' into feature/onramp-skip-screens
wachunei Jun 14, 2022
2ca8d89
Merge branch 'main' into feature/onramp-skip-screens
wachunei Jun 14, 2022
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
5 changes: 5 additions & 0 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ const FiatOnRampAggregator = () => (
component={Region}
options={{ animationEnabled: false }}
/>
<Stack.Screen
wachunei marked this conversation as resolved.
Show resolved Hide resolved
name={Routes.FIAT_ON_RAMP_AGGREGATOR.AMOUNT_TO_BUY_HAS_STARTED}
component={AmountToBuy}
options={{ animationEnabled: false }}
/>
</Stack.Navigator>
</FiatOnRampSDKProvider>
);
Expand Down
45 changes: 42 additions & 3 deletions app/components/UI/FiatOnRampAggregator/Views/AmountToBuy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Animated, {
useSharedValue,
withTiming,
} from 'react-native-reanimated';
import { useNavigation } from '@react-navigation/native';
import { useNavigation, useRoute } from '@react-navigation/native';
import { useFiatOnRampSDK, useSDKMethod } from '../sdk';

import useModalHandler from '../../../Base/hooks/useModalHandler';
Expand Down Expand Up @@ -49,6 +49,7 @@ import { Colors } from '../../../../util/theme/models';
import { CryptoCurrency } from '@consensys/on-ramp-sdk';
import Routes from '../../../../constants/navigation/Routes';
import useAnalytics from '../hooks/useAnalytics';
import { Region } from '../types';

// TODO: Convert into typescript and correctly type
const Text = BaseText as any;
Expand Down Expand Up @@ -93,6 +94,7 @@ const createStyles = (colors: Colors) =>

const AmountToBuy = () => {
const navigation = useNavigation();
const { params } = useRoute();
const { colors } = useTheme();
const styles = createStyles(colors);
const trackEvent = useAnalytics();
Expand Down Expand Up @@ -217,6 +219,38 @@ const AmountToBuy = () => {
* * Defaults and validation of selected values
*/

useEffect(() => {
if (
selectedRegion &&
!isFetchingCountries &&
!errorCountries &&
countries
) {
const allRegions: Region[] = countries.reduce(
(acc: Region[], region: Region) => [
...acc,
region,
...((region.states as Region[]) || []),
],
[],
);
const selectedRegionFromAPI =
allRegions.find((region) => region.id === selectedRegion.id) ?? null;

if (!selectedRegionFromAPI || selectedRegionFromAPI.unsupported) {
navigation.reset({
routes: [{ name: Routes.FIAT_ON_RAMP_AGGREGATOR.REGION }],
});
}
}
}, [
countries,
errorCountries,
isFetchingCountries,
navigation,
selectedRegion,
]);

const filteredPaymentMethods = useMemo(() => {
if (paymentMethods) {
return paymentMethods.filter((paymentMethod) =>
Expand Down Expand Up @@ -400,12 +434,17 @@ const AmountToBuy = () => {
navigation.setOptions(
getFiatOnRampAggNavbar(
navigation,
{ title: strings('fiat_on_ramp_aggregator.amount_to_buy') },
{
title: strings('fiat_on_ramp_aggregator.amount_to_buy'),
// @ts-expect-error navigation params error
showBack: params?.showBack,
},
colors,
handleCancelPress,
),
);
}, [navigation, colors, handleCancelPress]);
// @ts-expect-error navigation params error
}, [navigation, colors, handleCancelPress, params?.showBack]);

/**
* * Keypad style, handlers and effects
Expand Down
31 changes: 24 additions & 7 deletions app/components/UI/FiatOnRampAggregator/Views/GetStarted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ const styles = StyleSheet.create({

const GetStarted: React.FC = () => {
const navigation = useNavigation();
const { getStarted, setGetStarted, sdkError, selectedChainId } =
useFiatOnRampSDK();
const {
getStarted,
setGetStarted,
sdkError,
selectedChainId,
selectedRegion,
} = useFiatOnRampSDK();
const trackEvent = useAnalytics();

const { colors } = useTheme();
Expand Down Expand Up @@ -88,12 +93,24 @@ const GetStarted: React.FC = () => {

useEffect(() => {
if (getStarted) {
navigation.reset({
index: 0,
routes: [{ name: Routes.FIAT_ON_RAMP_AGGREGATOR.REGION_HAS_STARTED }],
});
if (selectedRegion) {
wachunei marked this conversation as resolved.
Show resolved Hide resolved
wachunei marked this conversation as resolved.
Show resolved Hide resolved
navigation.reset({
index: 0,
routes: [
{
name: Routes.FIAT_ON_RAMP_AGGREGATOR.AMOUNT_TO_BUY_HAS_STARTED,
params: { showBack: false },
},
],
});
} else {
navigation.reset({
index: 0,
routes: [{ name: Routes.FIAT_ON_RAMP_AGGREGATOR.REGION_HAS_STARTED }],
});
}
}
}, [getStarted, navigation]);
}, [getStarted, navigation, selectedRegion]);

if (sdkError) {
return (
Expand Down
1 change: 1 addition & 0 deletions app/constants/navigation/Routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Routes = {
GET_STARTED: 'GetStarted',
PAYMENT_METHOD: 'PaymentMethod',
AMOUNT_TO_BUY: 'AmountToBuy',
AMOUNT_TO_BUY_HAS_STARTED: 'AmountToBuyHasStarted',
GET_QUOTES: 'GetQuotes',
CHECKOUT: 'Checkout',
REGION: 'Region',
Expand Down