Merge pull request #960 from esteemapp/bugfix/points

Fixed point dropdown style
This commit is contained in:
uğur erdal 2019-07-19 23:16:37 +03:00 committed by GitHub
commit 82d176f99a
3 changed files with 40 additions and 9 deletions

View File

@ -17,9 +17,22 @@ import styles from './dropdownButtonStyles';
* *
*/ */
const renderDropdownRow = (rowData, rowID, highlighted, rowTextStyle, noHighlight) => ( const renderDropdownRow = (
rowData,
rowID,
highlighted,
rowTextStyle,
noHighlight,
dropdownRowWrapper,
) => (
<TouchableHighlight style={styles.rowWrapper} underlayColor="#E9F2FC"> <TouchableHighlight style={styles.rowWrapper} underlayColor="#E9F2FC">
<View style={[styles.dropdownRow, !noHighlight && highlighted && styles.highlightedRow]}> <View
style={[
styles.dropdownRow,
dropdownRowWrapper,
!noHighlight && highlighted && styles.highlightedRow,
]}
>
<Text <Text
style={[ style={[
rowTextStyle || styles.rowText, rowTextStyle || styles.rowText,
@ -50,9 +63,12 @@ const DropdownButtonView = ({
style, style,
noHighlight, noHighlight,
isLoading, isLoading,
dropdownRef,
dropdownRowWrapper,
}) => ( }) => (
<View style={[styles.container, dropdownButtonStyle]}> <View style={[styles.container, dropdownButtonStyle]}>
<ModalDropdown <ModalDropdown
ref={dropdownRef}
style={[!style ? styles.button : style]} style={[!style ? styles.button : style]}
textStyle={[textStyle || styles.buttonText]} textStyle={[textStyle || styles.buttonText]}
dropdownStyle={[styles.dropdown, dropdownStyle, { height: 35 * (options.length + 1) }]} dropdownStyle={[styles.dropdown, dropdownStyle, { height: 35 * (options.length + 1) }]}
@ -64,7 +80,14 @@ const DropdownButtonView = ({
defaultValue={defaultText} defaultValue={defaultText}
renderSeparator={() => null} renderSeparator={() => null}
renderRow={(rowData, rowID, highlighted) => renderRow={(rowData, rowID, highlighted) =>
renderDropdownRow(rowData, rowID, highlighted, rowTextStyle, noHighlight) renderDropdownRow(
rowData,
rowID,
highlighted,
rowTextStyle,
noHighlight,
dropdownRowWrapper,
)
} }
> >
{isHasChildIcon && !isLoading ? ( {isHasChildIcon && !isLoading ? (

View File

@ -15,15 +15,13 @@ export default EStyleSheet.create({
alignSelf: 'center', alignSelf: 'center',
flex: 1, flex: 1,
}, },
dropdownWrapper: {
flex: 1,
},
dropdownRowText: { dropdownRowText: {
fontSize: 14, fontSize: 14,
color: '$primaryDarkGray', color: '$primaryDarkGray',
textAlign: 'center',
}, },
dropdownStyle: { dropdownRowStyle: {
minWidth: '$deviceWidth * 0.7', marginLeft: 0,
}, },
dropdownButtonStyle: { dropdownButtonStyle: {
justifyContent: 'center', justifyContent: 'center',

View File

@ -31,6 +31,8 @@ class PointsView extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {}; this.state = {};
this.dropdownRef = React.createRef();
} }
// Component Functions // Component Functions
@ -72,6 +74,10 @@ class PointsView extends Component {
return <Text style={styles.subText}>{intl.formatMessage({ id: 'points.no_activity' })}</Text>; return <Text style={styles.subText}>{intl.formatMessage({ id: 'points.no_activity' })}</Text>;
}; };
_showDropdown = () => {
this.dropdownRef.current.show();
};
render() { render() {
const { const {
claimPoints, claimPoints,
@ -89,8 +95,12 @@ class PointsView extends Component {
<LineBreak height={12} /> <LineBreak height={12} />
<ScrollView style={styles.scrollContainer} refreshControl={this.refreshControl()}> <ScrollView style={styles.scrollContainer} refreshControl={this.refreshControl()}>
<View style={styles.pointsWrapper}> <View style={styles.pointsWrapper}>
<Text style={styles.pointText}>{get(userPoints, 'points')}</Text> <Text onPress={this._showDropdown} style={styles.pointText}>
{get(userPoints, 'points')}
</Text>
<DropdownButton <DropdownButton
dropdownRowWrapper={styles.dropdownRowStyle}
dropdownRef={this.dropdownRef}
isHasChildIcon isHasChildIcon
iconName="arrow-drop-down" iconName="arrow-drop-down"
options={['Transfer', 'Promote']} options={['Transfer', 'Promote']}