From d569e5d2688d7e6aee078445786f7aee7471de15 Mon Sep 17 00:00:00 2001 From: ZackLeonardo Date: Tue, 10 Apr 2018 11:39:32 +0800 Subject: [PATCH 1/3] display swiped buttons with row/column orientation. --- src/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 10bc457b..2488fc1b 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,7 @@ const SwipeoutBtn = createReactClass({ text: PropTypes.node, type: PropTypes.string, underlayColor: PropTypes.string, + orientation: PropTypes.oneOf(['row', 'column']), }, getDefaultProps: function() { @@ -41,6 +42,7 @@ const SwipeoutBtn = createReactClass({ text: 'Click me', type: '', width: 0, + orientation: 'row', }; }, @@ -171,8 +173,8 @@ const Swipeout = createReactClass({ let buttonWidth = this.props.buttonWidth || (width/5); this.setState({ btnWidth: buttonWidth, - btnsLeftWidth: this.props.left ? buttonWidth*this.props.left.length : 0, - btnsRightWidth: this.props.right ? buttonWidth*this.props.right.length : 0, + btnsLeftWidth: this.props.left ? (this.props.orientation == 'row' ? buttonWidth*this.props.left.length : (width/5) ): 0, + btnsRightWidth: this.props.right ? (this.props.orientation == 'row' ? buttonWidth*this.props.right.length : (width/5) ) : 0, swiping: true, timeStart: (new Date()).getTime(), }); @@ -410,6 +412,7 @@ const Swipeout = createReactClass({ _renderButtons: function(buttons, isVisible, style) { if (buttons && isVisible) { + this.props.orientation == "column" ? style.push({flexDirection: "column"}) : null; return( { buttons.map(this._renderButton) } ); @@ -420,14 +423,14 @@ const Swipeout = createReactClass({ } }, - _renderButton: function(btn, i) { + _renderButton: function(btn, i, btns) { return ( 0 ? this.state.contentHeight/btns.length : this.state.contentHeight} key={i} onPress={() => this._autoClose(btn)} text={btn.text} From c7c5cb3a5202dd7b9f5318b4a42f1e8ac0dfc560 Mon Sep 17 00:00:00 2001 From: ZackLeonardo Date: Tue, 10 Apr 2018 11:45:49 +0800 Subject: [PATCH 2/3] update readme.md with orientation props added. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8d86ea93..39115f4d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ scroll | func | Yes | | prevent parent scroll style | style | Yes | | style of the container sensitivity | number | Yes | 50 | change the sensitivity of gesture buttonWidth | number | Yes | | each button width +orientation | 'row' or 'column' | Yes | 'row' | swipeout buttons display orientation ##### Button props From 55b1a35598fc2fc97b50b8c26d80f46773c8f3e3 Mon Sep 17 00:00:00 2001 From: ZackLeonardo Date: Tue, 10 Apr 2018 13:07:52 +0800 Subject: [PATCH 3/3] Swipeout unset orientation which will be undefined, make it as row. --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 2488fc1b..c5538fe9 100644 --- a/src/index.js +++ b/src/index.js @@ -173,8 +173,8 @@ const Swipeout = createReactClass({ let buttonWidth = this.props.buttonWidth || (width/5); this.setState({ btnWidth: buttonWidth, - btnsLeftWidth: this.props.left ? (this.props.orientation == 'row' ? buttonWidth*this.props.left.length : (width/5) ): 0, - btnsRightWidth: this.props.right ? (this.props.orientation == 'row' ? buttonWidth*this.props.right.length : (width/5) ) : 0, + btnsLeftWidth: this.props.left ? (this.props.orientation == 'column' ? (width/5) : buttonWidth*this.props.left.length ): 0, + btnsRightWidth: this.props.right ? (this.props.orientation == 'column' ? (width/5) : buttonWidth*this.props.right.length ) : 0, swiping: true, timeStart: (new Date()).getTime(), });