Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Fix recipient input in send flow
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrogerlux authored and LFBarreto committed Mar 16, 2022
1 parent 3c06a9a commit b644d94
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 42 deletions.
53 changes: 53 additions & 0 deletions src/components/RecipientInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Flex } from "@ledgerhq/native-ui";
import { PasteMedium } from "@ledgerhq/native-ui/assets/icons";
import React, { ForwardedRef } from "react";
import { useTranslation } from "react-i18next";
import { TextInput as BaseTextInput } from "react-native";
import { TouchableOpacity } from "react-native-gesture-handler";
import styled from "styled-components/native";

import TextInput, { Props as TextInputProps } from "./TextInput";

const PasteButton = styled(TouchableOpacity).attrs(() => ({
activeOpacity: 0.6,
}))`
background-color: ${p => p.theme.colors.neutral.c100};
display: flex;
align-items: center;
justify-content: center;
width: 38px;
height: 38px;
border-radius: 38px;
border-width: 0;
`;

const PasteIcon = styled(PasteMedium).attrs(p => ({
color: p.theme.colors.neutral.c00,
size: 20,
}))``;

type Props = TextInputProps & {
ref?: ForwardedRef<BaseTextInput>;
onPaste?: () => void;
};

const RecipientInput = ({ ref, onPaste, ...props }: Props) => {
const { t } = useTranslation();

return (
<TextInput
ref={ref}
placeholder={t("transfer.recipient.input")}
renderRight={
<Flex alignItems="center" justifyContent="center" pr={2}>
<PasteButton onPress={onPaste}>
<PasteIcon />
</PasteButton>
</Flex>
}
{...props}
/>
);
};

export default RecipientInput;
3 changes: 3 additions & 0 deletions src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,9 @@
}
},
"transfer": {
"recipient": {
"input": "Enter address"
},
"send": {
"title": "Send"
},
Expand Down
49 changes: 7 additions & 42 deletions src/screens/SendFunds/02-SelectRecipient.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import RetryButton from "../../components/RetryButton";
import CancelButton from "../../components/CancelButton";
import GenericErrorBottomModal from "../../components/GenericErrorBottomModal";
import NavigationScrollView from "../../components/NavigationScrollView";
import RecipientInput from "../../components/RecipientInput";

const withoutHiddenError = error =>
error instanceof RecipientRequired ? null : error;
Expand Down Expand Up @@ -202,39 +203,17 @@ export default function SendSelectRecipient({ navigation, route }: Props) {
]}
/>
</View>
<TouchableOpacity
style={styles.pasteContainer}
onPress={async () => {
const text = await Clipboard.getString();
onChangeText(text);
}}
>
<Paste size={16} color={colors.live} />
<LText style={styles.pasteTitle} semiBold color="live">
<Trans i18nKey="common.paste" />
</LText>
</TouchableOpacity>
<View style={styles.inputWrapper}>
{/* make this a recipient component */}
<TextInput
placeholder={t("send.recipient.input")}
placeholderTextColor={colors.fog}
style={[
styles.addressInput,
{ color: colors.darkBlue },
error && { color: colors.alert },
warning && { color: colors.orange },
]}
<RecipientInput
onPaste={async () => {
const text = await Clipboard.getString();
onChangeText(text);
}}
onFocus={onRecipientFieldFocus}
onChangeText={onChangeText}
onInputCleared={clear}
value={transaction.recipient}
ref={input}
scrollEnabled={false}
multiline
blurOnSubmit
autoCapitalize="none"
clearButtonMode="always"
/>
</View>
{(error || warning) && (
Expand Down Expand Up @@ -300,15 +279,6 @@ const styles = StyleSheet.create({
paddingVertical: 16,
backgroundColor: "transparent",
},
pasteContainer: {
alignItems: "center",
flexDirection: "row",
marginBottom: 8,
marginTop: 32,
},
pasteTitle: {
marginLeft: 8,
},
infoBox: {
marginBottom: 24,
},
Expand All @@ -323,12 +293,6 @@ const styles = StyleSheet.create({
borderBottomWidth: 1,
marginHorizontal: 8,
},
addressInput: {
flex: 1,
...getFontStyle({ semiBold: true }),
fontSize: 20,
paddingVertical: 16,
},
warningBox: {
marginTop: 8,
...Platform.select({
Expand All @@ -338,6 +302,7 @@ const styles = StyleSheet.create({
}),
},
inputWrapper: {
marginTop: 32,
flexDirection: "row",
alignItems: "center",
},
Expand Down

0 comments on commit b644d94

Please sign in to comment.