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

feat(HW-889): Add contact button #2188

Merged
merged 3 commits into from
Nov 5, 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
162 changes: 0 additions & 162 deletions src/screens/HomeStack/TransactionStack/transaction-address.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './transaction-address';
export * from './transaction-address-add-contact';
export * from './transaction-address-contact-list';
export * from './transaction-address-input';
export * from './transaction-address-wallet-list';
export * from './transaction-address.types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {useCallback} from 'react';

import {View} from 'react-native';
import prompt from 'react-native-prompt-android';

import {Color} from '@app/colors';
import {
Icon,
IconButton,
IconsName,
Spacer,
Text,
TextVariant,
} from '@app/components/ui';
import {createTheme} from '@app/helpers';
import {I18N, getText} from '@app/i18n';
import {Contact, ContactType} from '@app/models/contact';
import {sendNotification} from '@app/services';

import {TransactionAddressAddContactProps} from './transaction-address.types';

export const TransactionAddressAddContact = ({
address,
}: TransactionAddressAddContactProps) => {
const onPress = useCallback(() => {
prompt(
getText(I18N.transactionFinishAddContact),
getText(I18N.transactionFinishContactMessage, {
address,
}),
value => {
Contact.create(address, {
name: value,
type: ContactType.address,
visible: true,
});
sendNotification(I18N.transactionFinishContactAdded);
},
{
defaultValue: '',
placeholder: getText(I18N.transactionFinishContactMessagePlaceholder),
},
);
}, [address]);
return (
<View style={styles.container}>
<IconButton style={styles.iconButton} onPress={onPress}>
<Icon i24 name={IconsName.plus_mid} color={Color.graphicBase2} />
</IconButton>
<Spacer width={12} />
<Text variant={TextVariant.t11} i18n={I18N.settingsAddressBookAdd} />
</View>
);
};

const styles = createTheme({
container: {
marginTop: 16,
flexDirection: 'row',
alignItems: 'center',
},
iconButton: {
width: 42,
height: 42,
borderRadius: 12,
backgroundColor: Color.bg8,
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {ListContact} from '@app/components/list-contact';
import {Spacer, Text, TextVariant} from '@app/components/ui';
import {withActionsContactItem} from '@app/hocs';
import {I18N} from '@app/i18n';

import {TransactionAddressContactListProps} from './transaction-address.types';

const ListOfContacts = withActionsContactItem(ListContact, {
nextScreen: 'transactionContactEdit',
});

export const TransactionAddressContactList = ({
contacts,
onPress,
}: TransactionAddressContactListProps) => {
return (
<>
<Spacer height={12} />
<Text variant={TextVariant.t6} i18n={I18N.transactionMyContacts} />
<ListOfContacts
// @ts-ignore
data={contacts}
onPressAddress={onPress}
/>
</>
);
};
Loading