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

Commit

Permalink
Change UI implementation of ChainSelector
Browse files Browse the repository at this point in the history
This is a workaround for an Android issue which prevents
visible overflowed elements to receive taps.

See facebook/react-native#21455
  • Loading branch information
Pablo Enrici authored and Martin Carrera committed May 30, 2019
1 parent 6dae034 commit 8b61483
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/components/nav-drawer/ChainSelector.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { StyleSheet, TouchableOpacity } from 'react-native'
import withChainSelectorState from 'metronome-wallet-ui-logic/src/hocs/withChainSelectorState'
import PropTypes from 'prop-types'
import theme from 'metronome-wallet-ui-logic/src/theme'
import React from 'react'

import { DisplayValue, View, Text } from '../common'
import CoinIcon from '../icons/CoinIcon'
import Caret from '../icons/CaretIcon'

const BORDER_RADIUS = 12
const ITEM_HEIGHT = 60

const Item = props => (
<TouchableOpacity activeOpacity={0.75} onPress={props.onPress}>
<View
style={[props.isFirst && styles.btnFirst, props.isLast && styles.btnLast]}
style={[
styles.btn,
props.isFirst && styles.btnFirst,
props.isLast && styles.btnLast
]}
align="center"
row
bg={props.isActive ? 'translucentPrimary' : 'darkShade'}
Expand Down Expand Up @@ -96,7 +104,20 @@ class ChainSelector extends React.Component {
if ((this.props.chains || []).length < 2) return null

return (
<View mt={-3.5} mb={2} ml={2} mr={2} style={styles.container}>
<View
style={[
styles.container,
{
marginBottom: this.state.isOpen
? ((this.props.chains || []).length - 1) * ITEM_HEIGHT * -1 +
theme.spacing(2)
: theme.spacing(2)
}
]}
mt={-3.5}
ml={2}
mr={2}
>
<Text ml={1} mb={1} size="xSmall" ls={1} opacity={0.8}>
CHAIN
</Text>
Expand Down Expand Up @@ -136,13 +157,13 @@ class ChainSelector extends React.Component {
}
}

const BORDER_RADIUS = 12

const styles = StyleSheet.create({
container: {
position: 'relative',
zIndex: 1
},
btn: {
height: ITEM_HEIGHT
},
btnFirst: {
borderTopRightRadius: BORDER_RADIUS,
borderTopLeftRadius: BORDER_RADIUS
Expand All @@ -153,9 +174,9 @@ const styles = StyleSheet.create({
},
dropdownContainer: {
borderRadius: BORDER_RADIUS,
position: 'absolute',
width: '100%',
top: 22
marginTop: ITEM_HEIGHT * -1,
elevation: 16,
width: '100%'
}
})

Expand Down

0 comments on commit 8b61483

Please sign in to comment.