Skip to content

Commit

Permalink
Merge pull request #517 from shoutem/release/4.0.1
Browse files Browse the repository at this point in the history
Release/4.0.1
  • Loading branch information
majaklajic authored Sep 3, 2020
2 parents 4fbd1b7 + cbc5ef8 commit d81e74a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
20 changes: 17 additions & 3 deletions components/DropDownMenu/DropDownMenu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import _ from 'lodash';

Expand All @@ -17,9 +18,22 @@ class DropDownMenu extends PureComponent {
* @see DropDownModal.propTypes
*/
static propTypes = {
/**
* Icon displayed on dropdown menu button
*/
iconName: PropTypes.string,
/**
* Whether the text should be displayed next to dropdown icon or not
*/
showSelectedOption: PropTypes.bool,
...dropDownMenuPropTypes,
};

static defaultProps = {
iconName: "drop-down",
showSelectedOption: true,
};

constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -51,14 +65,14 @@ class DropDownMenu extends PureComponent {
}

renderSelectedOption() {
const { style, titleProperty } = this.props;
const { iconName, showSelectedOption, style, titleProperty } = this.props;

const selectedOption = this.getSelectedOption();
return selectedOption ? (
<View style={style.horizontalContainer}>
<Button onPress={this.collapse} style={style.selectedOption}>
<Text>{selectedOption[titleProperty]}</Text>
<Icon name="drop-down" />
{showSelectedOption && <Text>{selectedOption[titleProperty]}</Text>}
<Icon name={iconName} />
</Button>
</View>
) : null;
Expand Down
4 changes: 3 additions & 1 deletion components/DropDownMenu/DropDownModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,15 @@ class DropDownModal extends PureComponent {
style,
titleProperty,
renderOption,
selectedOption,
} = this.props;

const optionItem = renderOption(option, titleProperty);
const selectedItem = selectedOption.id === option.id || false
const onPress = () => this.selectOption(option);

return (
<TouchableOpacity onPress={onPress} style={style.modalItem} onLayout={this.onOptionLayout}>
<TouchableOpacity onPress={onPress} style={selectedItem ? style.selectedModalItem : style.modalItem} onLayout={this.onOptionLayout}>
{optionItem}
</TouchableOpacity>
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shoutem/ui",
"version": "4.0.0",
"version": "4.0.1",
"description": "Styleable set of components for React Native applications",
"dependencies": {
"@shoutem/animation": "~0.12.4",
Expand Down
12 changes: 12 additions & 0 deletions theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,18 @@ export default (variables = defaultThemeVariables) => ({
...variables.subtitle,
},
},
selectedModalItem: {
'shoutem.ui.Text': {
textAlign: 'center',
flex: 1,
width: window.width,
paddingHorizontal: 20,
paddingVertical: 23,
alignSelf: 'stretch',
...variables.subtitle,
fontWeight: '500'
},
},

visibleOptions: 8,
},
Expand Down

0 comments on commit d81e74a

Please sign in to comment.