-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(ramp): add activation keys labels and DS components #9119
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
194404b
Replaced sdk settings with DS components
brianacnguyen 1fb07b8
refactor(ramp): use columnGap instead of negative margin
wachunei c94a319
test(ramp): update snapshots
wachunei f04f31e
refactor: use ternary in reset region button
wachunei 79006a8
feat(ramp): add labels to activation keys
wachunei 619b19c
test(ramp): update reducer test
wachunei 89914af
feat(ramp): add settings views
wachunei 9f8fdc5
refactor(ramp): imports
wachunei ca01399
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei 4522550
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei 93026fd
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei d8d98d9
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei 027e0a2
Merge branch 'main' into feature/ramp-activation-keys-labels
desi 1e39f4e
Merge branch 'main' into feature/ramp-activation-keys-labels
desi 64b67b9
Merge branch 'main' into feature/ramp-activation-keys-labels
desi 442af86
Merge branch 'main' into feature/ramp-activation-keys-labels
desi e96da0a
Merge branch 'main' into feature/ramp-activation-keys-labels
desi 3dfe6b2
Merge branch 'main' into feature/ramp-activation-keys-labels
desi d6e1dcc
Merge branch 'main' into feature/ramp-activation-keys-labels
desi 597e5b8
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei 441c051
fix(ramp): typo
wachunei 8429797
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei 0ed4954
test(ramp): update test with labels
wachunei d652e32
Merge branch 'main' into feature/ramp-activation-keys-labels
wachunei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
app/components/UI/Ramp/Views/Settings/ActivationKeyForm.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| // Third party dependencies | ||
| import React, { useCallback, useEffect, useState } from 'react'; | ||
| import { useNavigation } from '@react-navigation/native'; | ||
|
|
||
| // External dependencies | ||
| import Row from '../../components/Row'; | ||
| import ScreenLayout from '../../components/ScreenLayout'; | ||
| import Text, { | ||
| TextVariant, | ||
| } from '../../../../../component-library/components/Texts/Text'; | ||
| import TextField from '../../../../../component-library/components/Form/TextField'; | ||
| import Label from '../../../../../component-library/components/Form/Label'; | ||
| import Button, { | ||
| ButtonVariants, | ||
| ButtonSize, | ||
| } from '../../../../../component-library/components/Buttons/Button'; | ||
|
|
||
| import { getNavigationOptionsTitle } from '../../../Navbar'; | ||
| import { | ||
| createNavigationDetails, | ||
| useParams, | ||
| } from '../../../../../util/navigation/navUtils'; | ||
| import { useTheme } from '../../../../../util/theme'; | ||
| import Routes from '../../../../../constants/navigation/Routes'; | ||
| import { strings } from '../../../../../../locales/i18n'; | ||
| import { regex } from '../../../../../util/regex'; | ||
|
|
||
| // Internal dependencies | ||
| import styles from './Settings.styles'; | ||
|
|
||
| interface ActivationKeyFormParams { | ||
| onSubmit: (key: string, label: string, active: boolean) => void; | ||
| key: string; | ||
| active: boolean; | ||
| label: string; | ||
| } | ||
|
|
||
| export const createActivationKeyFormNavDetails = | ||
| createNavigationDetails<ActivationKeyFormParams>( | ||
| Routes.RAMP.ACTIVATION_KEY_FORM, | ||
| ); | ||
|
|
||
| function ActivationKeyForm() { | ||
| const navigation = useNavigation(); | ||
| const { | ||
| key, | ||
| label: initialLabel, | ||
| active, | ||
| onSubmit, | ||
| } = useParams<ActivationKeyFormParams>(); | ||
| const [activationKey, setActivationKey] = useState(key ?? ''); | ||
| const [label, setLabel] = useState(initialLabel ?? ''); | ||
| const { colors } = useTheme(); | ||
| const style = styles(); | ||
|
|
||
| useEffect(() => { | ||
| navigation.setOptions( | ||
| getNavigationOptionsTitle( | ||
| key | ||
| ? strings('app_settings.fiat_on_ramp.edit_activation_key') | ||
| : strings('app_settings.fiat_on_ramp.add_activation_key'), | ||
| navigation, | ||
| false, | ||
| colors, | ||
| ), | ||
| ); | ||
| }, [colors, key, navigation]); | ||
|
|
||
| const handleSubmit = useCallback(() => { | ||
| if (!regex.activationKey.test(activationKey)) { | ||
| return; | ||
| } | ||
| onSubmit(activationKey, label, active); | ||
| navigation.goBack(); | ||
| }, [activationKey, navigation, onSubmit, active, label]); | ||
|
|
||
| const handleCancel = useCallback(() => { | ||
| navigation.goBack(); | ||
| }, [navigation]); | ||
|
|
||
| return ( | ||
| <ScreenLayout> | ||
| <ScreenLayout.Body> | ||
| <ScreenLayout.Content> | ||
| <Text variant={TextVariant.BodyLGMedium}> | ||
| {key | ||
| ? strings('app_settings.fiat_on_ramp.edit_activation_key') | ||
| : strings('app_settings.fiat_on_ramp.add_activation_key')} | ||
| </Text> | ||
|
|
||
| <Row> | ||
| <Label>{strings('app_settings.fiat_on_ramp.label')}</Label> | ||
| <TextField | ||
| autoCapitalize={'none'} | ||
| onChangeText={setLabel} | ||
| placeholder={strings('app_settings.fiat_on_ramp.add_label')} | ||
| numberOfLines={1} | ||
| value={label} | ||
| returnKeyType={'done'} | ||
| onSubmitEditing={handleSubmit} | ||
| autoFocus | ||
| /> | ||
| </Row> | ||
| <Row> | ||
| <Label>{strings('app_settings.fiat_on_ramp.key')}</Label> | ||
| <TextField | ||
| autoCapitalize={'none'} | ||
| autoCorrect={false} | ||
| onChangeText={setActivationKey} | ||
| placeholder={strings( | ||
| 'app_settings.fiat_on_ramp.paste_or_type_activation_key', | ||
| )} | ||
| spellCheck={false} | ||
| numberOfLines={1} | ||
| value={activationKey} | ||
| returnKeyType={'done'} | ||
| onSubmitEditing={handleSubmit} | ||
| isReadonly={Boolean(key)} | ||
| /> | ||
| </Row> | ||
|
|
||
| <Row style={style.buttons}> | ||
| <Button | ||
| variant={ButtonVariants.Secondary} | ||
| size={ButtonSize.Lg} | ||
| style={style.button} | ||
| onPress={handleCancel} | ||
| label={strings('app_settings.fiat_on_ramp.cancel')} | ||
| /> | ||
| <Button | ||
| variant={ButtonVariants.Primary} | ||
| size={ButtonSize.Lg} | ||
| style={style.button} | ||
| onPress={handleSubmit} | ||
| label={ | ||
| key | ||
| ? strings('app_settings.fiat_on_ramp.update') | ||
| : strings('app_settings.fiat_on_ramp.add') | ||
| } | ||
| isDisabled={!regex.activationKey.test(activationKey)} | ||
| /> | ||
| </Row> | ||
| </ScreenLayout.Content> | ||
| </ScreenLayout.Body> | ||
| </ScreenLayout> | ||
| ); | ||
| } | ||
|
|
||
| export default ActivationKeyForm; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.