-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from rastajpa/send-to-options
[RN-496 & RN-510] Select Inputs & Multiple Recipients
- Loading branch information
Showing
19 changed files
with
1,641 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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 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 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,56 @@ | ||
import React, {memo, useState} from 'react'; | ||
import styled from 'styled-components/native'; | ||
import {ActiveOpacity, Column} from '../styled/Containers'; | ||
import {RowContainer} from '../styled/Containers'; | ||
import {H5, ListItemSubText} from '../styled/Text'; | ||
import haptic from '../haptic-feedback/haptic'; | ||
import Checkbox from '../checkbox/Checkbox'; | ||
import {Utxo} from '../../store/wallet/wallet.models'; | ||
|
||
interface Props { | ||
item: Utxo; | ||
unitCode?: string; | ||
emit: (item: Utxo, index: number) => void; | ||
index: number; | ||
} | ||
|
||
const CheckBoxContainer = styled.View` | ||
flex-direction: column; | ||
justify-content: center; | ||
`; | ||
|
||
const InputColumn = styled(Column)` | ||
margin-left: 16px; | ||
`; | ||
|
||
const InputSelectionRow = ({item, unitCode, emit, index}: Props) => { | ||
const {amount, address, checked: initialCheckValue} = item; | ||
|
||
const [checked, setChecked] = useState(!!initialCheckValue); | ||
const toggle = (): void => { | ||
setChecked(!checked); | ||
haptic('impactLight'); | ||
emit({...item, ...{checked: !checked}}, index); | ||
}; | ||
|
||
return ( | ||
<RowContainer | ||
activeOpacity={ActiveOpacity} | ||
onPress={toggle} | ||
style={{paddingLeft: 0, paddingRight: 0}}> | ||
<CheckBoxContainer> | ||
<Checkbox checked={checked} onPress={toggle} /> | ||
</CheckBoxContainer> | ||
<InputColumn> | ||
<H5> | ||
{amount} {unitCode?.toUpperCase()}{' '} | ||
</H5> | ||
<ListItemSubText numberOfLines={1} ellipsizeMode={'middle'}> | ||
{address} | ||
</ListItemSubText> | ||
</InputColumn> | ||
</RowContainer> | ||
); | ||
}; | ||
|
||
export default memo(InputSelectionRow); |
This file contains 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 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,79 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components/native'; | ||
import {BaseText, H7} from '../../../components/styled/Text'; | ||
import {LightBlack, NeutralSlate} from '../../../styles/colors'; | ||
import { | ||
ActiveOpacity, | ||
Column, | ||
Row, | ||
} from '../../../components/styled/Containers'; | ||
import {TxDetailsSendingTo} from '../../../store/wallet/wallet.models'; | ||
import {CurrencyImage} from '../../../components/currency-image/CurrencyImage'; | ||
import ContactIcon from '../../tabs/contacts/components/ContactIcon'; | ||
|
||
interface AddressCardComponentProps { | ||
recipient: TxDetailsSendingTo; | ||
} | ||
|
||
const ListCard = styled.TouchableOpacity` | ||
background-color: ${({theme: {dark}}) => (dark ? LightBlack : NeutralSlate)}; | ||
border-radius: 12px; | ||
margin: 6px 0; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 15px; | ||
height: 75px; | ||
`; | ||
|
||
const RecipientAmount = styled(BaseText)` | ||
font-style: normal; | ||
font-weight: 500; | ||
font-size: 14px; | ||
line-height: 19px; | ||
`; | ||
|
||
const ContactImageContainer = styled.View` | ||
height: 20px; | ||
width: 20px; | ||
justify-content: center; | ||
align-self: center; | ||
border-radius: 8px; | ||
margin-right: 8px; | ||
`; | ||
|
||
const AddressCard: React.FC<AddressCardComponentProps> = ({recipient}) => { | ||
return ( | ||
<ListCard activeOpacity={ActiveOpacity} style={{height: 59, margin: 0}}> | ||
<Row style={{alignItems: 'center', justifyContent: 'space-between'}}> | ||
<Row style={{alignItems: 'center', justifyContent: 'flex-start'}}> | ||
<ContactImageContainer> | ||
{recipient.recipientType === 'contact' ? ( | ||
<ContactIcon | ||
name={recipient.recipientName || recipient.recipientAddress} | ||
coin={recipient.recipientCoin!} | ||
size={30} | ||
/> | ||
) : ( | ||
<CurrencyImage img={recipient.img} size={30} /> | ||
)} | ||
</ContactImageContainer> | ||
<H7 | ||
style={{marginLeft: 8}} | ||
numberOfLines={1} | ||
ellipsizeMode={'middle'}> | ||
{recipient.recipientAddress} | ||
</H7> | ||
</Row> | ||
<Column style={{alignItems: 'flex-end'}}> | ||
<RecipientAmount>{recipient.recipientAmountStr}</RecipientAmount> | ||
{recipient.recipientAltAmountStr ? ( | ||
<H7>{recipient.recipientAltAmountStr}</H7> | ||
) : null} | ||
</Column> | ||
</Row> | ||
</ListCard> | ||
); | ||
}; | ||
|
||
export default AddressCard; |
This file contains 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,47 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components/native'; | ||
import {gestureHandlerRootHOC} from 'react-native-gesture-handler'; | ||
import {Black, White} from '../../../styles/colors'; | ||
import SheetModal from '../../../components/modal/base/sheet/SheetModal'; | ||
import Amount from '../screens/Amount'; | ||
|
||
const AmountContainer = styled.View` | ||
flex: 1; | ||
background-color: ${({theme: {dark}}) => (dark ? Black : White)}; | ||
`; | ||
|
||
interface AmountModalProps { | ||
isVisible: boolean; | ||
onDismiss: (amount?: number) => void; | ||
opts: { | ||
context?: string; | ||
hideSendMax?: boolean; | ||
currencyAbbreviation?: string; | ||
}; | ||
} | ||
|
||
const AmountModalWrapper = gestureHandlerRootHOC(props => { | ||
return <AmountContainer>{props.children}</AmountContainer>; | ||
}); | ||
|
||
const AmountModal: React.FC<AmountModalProps> = ({ | ||
isVisible, | ||
onDismiss, | ||
opts, | ||
}) => { | ||
return ( | ||
<SheetModal isVisible={isVisible} onBackdropPress={onDismiss}> | ||
<AmountModalWrapper> | ||
<Amount | ||
useAsModal={true} | ||
onDismiss={onDismiss} | ||
hideSendMaxProp={opts.hideSendMax} | ||
contextProp={opts.context} | ||
currencyAbbreviationProp={opts.currencyAbbreviation} | ||
/> | ||
</AmountModalWrapper> | ||
</SheetModal> | ||
); | ||
}; | ||
|
||
export default AmountModal; |
This file contains 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
Oops, something went wrong.