Skip to content

Commit

Permalink
Merge pull request #685 from shoutem/release/4.9.0
Browse files Browse the repository at this point in the history
Release 5.9.0 - master
  • Loading branch information
sstimac authored Feb 22, 2022
2 parents 683d15e + 140a43a commit 1770fb2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
42 changes: 32 additions & 10 deletions components/InlineDropDownMenu/InlineDropDownMenu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { Animated, FlatList } from 'react-native';
import autoBindReact from 'auto-bind/react';
import { Animated, ScrollView } from 'react-native';
import _ from 'lodash';
import PropTypes from 'prop-types';
import { connectStyle } from '@shoutem/theme';
Expand All @@ -14,7 +14,7 @@ const AnimatedIcon = Animated.createAnimatedComponent(Icon);

const optionShape = PropTypes.shape({
title: PropTypes.string.isRequired,
key: PropTypes.string.isRequired,
key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
});

class InlineDropDownMenu extends PureComponent {
Expand All @@ -24,6 +24,10 @@ class InlineDropDownMenu extends PureComponent {
options: PropTypes.arrayOf(optionShape).isRequired,
onOptionSelected: PropTypes.func,
selectedOption: optionShape,
headingStyle: PropTypes.object,
containerStyle: PropTypes.object,
selectedOptionContainerStyle: PropTypes.object,
selectedOptionTextStyle: PropTypes.object,
};

constructor(props) {
Expand Down Expand Up @@ -69,6 +73,7 @@ class InlineDropDownMenu extends PureComponent {

return (
<InlineDropDownMenuItem
key={item.key}
item={item}
isSelected={isSelected}
index={index}
Expand All @@ -79,18 +84,32 @@ class InlineDropDownMenu extends PureComponent {
}

render() {
const { style, heading, selectedOption, options } = this.props;
const {
style,
heading,
selectedOption,
options,
headingStyle,
containerStyle,
selectedOptionContainerStyle,
selectedOptionTextStyle,
} = this.props;
const { collapsed } = this.state;

return (
<View>
<TouchableOpacity
style={style.container}
style={[style.container, containerStyle]}
onPress={this.handleToggleMenuPress}
>
<Caption styleName="muted md-gutter-bottom">{heading}</Caption>
<View styleName="space-between horizontal v-center">
<Text>{selectedOption?.title}</Text>
<Caption styleName="muted md-gutter-bottom" style={headingStyle}>
{heading}
</Caption>
<View
styleName="space-between horizontal v-center"
style={selectedOptionContainerStyle}
>
<Text style={selectedOptionTextStyle}>{selectedOption?.title}</Text>
<AnimatedIcon
name="drop-down"
styleName="md-gutter-left"
Expand All @@ -109,11 +128,14 @@ class InlineDropDownMenu extends PureComponent {
</View>
</TouchableOpacity>
{collapsed && (
<FlatList
<ScrollView
data={options}
renderItem={this.renderOption}
contentContainerStyle={style.list}
/>
>
{_.map(options, (item, index) =>
this.renderOption({ item, index }),
)}
</ScrollView>
)}
</View>
);
Expand Down
9 changes: 4 additions & 5 deletions components/InlineDropDownMenu/InlineDropDownMenuItem.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { PureComponent } from 'react';
import { Animated, Dimensions } from 'react-native';
import { Animated, Dimensions, Pressable } from 'react-native';
import autoBindReact from 'auto-bind/react';
import _ from 'lodash';
import PropTypes from 'prop-types';
import { connectStyle } from '@shoutem/theme';
import { Text } from '../Text';
import { TouchableOpacity } from '../TouchableOpacity';

const window = Dimensions.get('window');
const AnimatedTouchable = Animated.createAnimatedComponent(TouchableOpacity);
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);

class InlineDropDownMenuItem extends PureComponent {
static propTypes = {
Expand Down Expand Up @@ -54,7 +53,7 @@ class InlineDropDownMenuItem extends PureComponent {
const textStyle = isSelected ? 'muted' : '';

return (
<AnimatedTouchable
<AnimatedPressable
style={[
style.container,
{
Expand All @@ -72,7 +71,7 @@ class InlineDropDownMenuItem extends PureComponent {
onPress={this.handlePress}
>
<Text styleName={textStyle}>{resolvedText}</Text>
</AnimatedTouchable>
</AnimatedPressable>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class TextInput extends PureComponent {
selectionColor={selectionColor}
underlineColorAndroid={underlineColorAndroid}
style={{
...otherStyle,
...(hasBorder ? withBorder : withoutBorder),
...(errorMessage ? errorBorderColor : {}),
...otherStyle,
}}
/>
</Wiggle>
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.8.0",
"version": "4.9.0",
"description": "Styleable set of components for React Native applications",
"scripts": {
"lint": "eslint .",
Expand Down

0 comments on commit 1770fb2

Please sign in to comment.