From 3a323cf2018f256258035db2ad2c70fc368f74fc Mon Sep 17 00:00:00 2001 From: izadmehr Date: Sun, 4 Dec 2016 11:20:12 +0330 Subject: [PATCH 01/10] Update SmartScrollView.js migrate to react native 0.39 fix error: attempted to set an invalid frame to inner scrollview --- SmartScrollView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index fc42423..95f9819 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -250,7 +250,7 @@ class SmartScrollView extends Component { const styles = StyleSheet.create({ flex1: { - flex: 1 + flexGrow: 1 } }); From ecae4943b40011d3aa1081317566e6bb638c8ffb Mon Sep 17 00:00:00 2001 From: izadmehr Date: Tue, 20 Dec 2016 13:41:20 +0330 Subject: [PATCH 02/10] move to textInout which will be under keyboard in iOS when textInput selected which will be under the keyboard, if it's the first user select, it' will remain under keyboard and scrollTo will not work. The problem aries from the fact that keyboard height is undefined until open in the iOS. --- SmartScrollView.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index 95f9819..a85bd7b 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -129,7 +129,11 @@ class SmartScrollView extends Component { this[ref].measureLayout(num, (X,Y,W,H) => { const py = Y - scrollPosition; - if ( py + H > scrollWindowHeight ){ + if (!scrollWindowHeight) { + setTimeout(() => { + this._focusNode(ref); + }, 100); + } else if ( py + H > scrollWindowHeight ){ const nextScrollPosition = (Y + H) - scrollWindowHeight + scrollPadding; this._smartScroll.scrollTo({y: nextScrollPosition}); From f77bacfa9295499a5a9545094ab54885b6383c20 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Tue, 20 Dec 2016 15:13:40 +0330 Subject: [PATCH 03/10] Scrolling when keyboard is open in iOS --- SmartScrollView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index a85bd7b..f468019 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -254,7 +254,8 @@ class SmartScrollView extends Component { const styles = StyleSheet.create({ flex1: { - flexGrow: 1 + flexGrow: 1, + flexBasis:1 } }); From f6a5b3a394c2d18c7cb625dca72842a7a6790109 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Wed, 21 Dec 2016 13:25:19 +0330 Subject: [PATCH 04/10] bug fixed: scrolling in the iOS when keyboard is open --- SmartScrollView.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index f468019..1e4806b 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -224,14 +224,12 @@ class SmartScrollView extends Component { style = {scrollContainerStyle} onLayout={(e) => this._layout = e.nativeEvent.layout} > - + this._smartScroll=component } automaticallyAdjustContentInsets = { false } scrollsToTop = { false } - style = { styles.flex1 } + style = {this.state.keyBoardUp ? { height: this.state.scrollWindowHeight } : {}} onScroll = { (event) => { this._updateScrollPosition(event) onScroll(event) From f14578139b8522bb62b3cab3c30658bf6cae41df Mon Sep 17 00:00:00 2001 From: izadmehr Date: Tue, 27 Dec 2016 14:56:39 +0330 Subject: [PATCH 05/10] add keyboardDismissMode option to the ScrollView --- SmartScrollView.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index 1e4806b..f4efd06 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -241,6 +241,7 @@ class SmartScrollView extends Component { showsVerticalScrollIndicator = { showsVerticalScrollIndicator } keyboardShouldPersistTaps = { true } bounces = { false } + keyboardDismissMode = {keyboardDismissMode} > {content} @@ -266,6 +267,7 @@ SmartScrollView.propTypes = { contentInset: PropTypes.object, onScroll: PropTypes.func, onRefFocus: PropTypes.func, + keyboardDismissMode: PropTypes.string }; SmartScrollView.defaultProps = { @@ -275,7 +277,8 @@ SmartScrollView.defaultProps = { showsVerticalScrollIndicator: true, contentInset: {top: 0, left: 0, bottom: 0, right: 0}, onScroll: () => {}, - onRefFocus: () => {} + onRefFocus: () => {}, + keyboardDismissMode: 'none' }; export default SmartScrollView; From c9a5e41ab964a83a6864af1d80173aa21f167dc5 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Tue, 27 Dec 2016 15:14:02 +0330 Subject: [PATCH 06/10] take keyboardDismissMode from props --- SmartScrollView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index f4efd06..f94a2cd 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -161,7 +161,8 @@ class SmartScrollView extends Component { zoomScale, showsVerticalScrollIndicator, contentInset, - onScroll + onScroll, + keyboardDismissMode } = this.props; let inputIndex = 0; const smartClone = (element, i) => { From ef4d38c2bfbb7f3218e1df46057fea385b9cc4e5 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Sat, 25 Mar 2017 15:52:02 +0430 Subject: [PATCH 07/10] Update SmartScrollView.js keyboardShouldPersistTaps= {true} is deprecated, using keyboardShouldPersistTaps='always' instead --- SmartScrollView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index f94a2cd..b3ae3df 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -240,7 +240,7 @@ class SmartScrollView extends Component { contentInset = { contentInset } zoomScale = { zoomScale } showsVerticalScrollIndicator = { showsVerticalScrollIndicator } - keyboardShouldPersistTaps = { true } + keyboardShouldPersistTaps = 'always' bounces = { false } keyboardDismissMode = {keyboardDismissMode} > From abfe4941296d0614568835c856b4716867eddb76 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Sun, 26 Mar 2017 11:39:42 +0430 Subject: [PATCH 08/10] bug fixed: component not shown in react-native 0.42 remove flexGrow & flexBasis which is needed for react native 0.39 --- SmartScrollView.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index b3ae3df..6ed07d9 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -5,7 +5,6 @@ import React, { import ReactNative, { View, - StyleSheet, ScrollView, Keyboard, Dimensions, @@ -252,13 +251,6 @@ class SmartScrollView extends Component { } } -const styles = StyleSheet.create({ - flex1: { - flexGrow: 1, - flexBasis:1 - } -}); - SmartScrollView.propTypes = { forceFocusField: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), scrollContainerStyle: View.propTypes.style, @@ -272,7 +264,7 @@ SmartScrollView.propTypes = { }; SmartScrollView.defaultProps = { - scrollContainerStyle: styles.flex1, + scrollContainerStyle: {}, scrollPadding: 5, zoomScale: 1, showsVerticalScrollIndicator: true, From 327bd42f4ebd09da333ce2d5cae7d2cc4809f766 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Sun, 26 Mar 2017 12:12:58 +0430 Subject: [PATCH 09/10] bug fix: crash on closing modal that contain SmartScrollView --- SmartScrollView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index 6ed07d9..e884b93 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -122,7 +122,7 @@ class SmartScrollView extends Component { const num = ReactNative.findNodeHandle(this._smartScroll); const strippedBackRef = ref.slice('input_'.length); - setTimeout(() => { + this[ref] && setTimeout(() => { onRefFocus(strippedBackRef); this.setState({focusedField: strippedBackRef}) this[ref].measureLayout(num, (X,Y,W,H) => { From e578e784a1e42613bf8704045d4ae009316549d9 Mon Sep 17 00:00:00 2001 From: izadmehr Date: Sun, 7 May 2017 15:37:27 +0430 Subject: [PATCH 10/10] Read keyboardShouldPersistTaps from props --- SmartScrollView.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/SmartScrollView.js b/SmartScrollView.js index e884b93..cc7eaf9 100644 --- a/SmartScrollView.js +++ b/SmartScrollView.js @@ -161,7 +161,8 @@ class SmartScrollView extends Component { showsVerticalScrollIndicator, contentInset, onScroll, - keyboardDismissMode + keyboardDismissMode, + keyboardShouldPersistTaps } = this.props; let inputIndex = 0; const smartClone = (element, i) => { @@ -217,7 +218,6 @@ class SmartScrollView extends Component { } const content = recursivelyCheckAndAdd(scrollChildren, '0'); - return ( this._container=component } @@ -239,7 +239,7 @@ class SmartScrollView extends Component { contentInset = { contentInset } zoomScale = { zoomScale } showsVerticalScrollIndicator = { showsVerticalScrollIndicator } - keyboardShouldPersistTaps = 'always' + keyboardShouldPersistTaps = {keyboardShouldPersistTaps} bounces = { false } keyboardDismissMode = {keyboardDismissMode} > @@ -260,7 +260,8 @@ SmartScrollView.propTypes = { contentInset: PropTypes.object, onScroll: PropTypes.func, onRefFocus: PropTypes.func, - keyboardDismissMode: PropTypes.string + keyboardDismissMode: PropTypes.string, + keyboardShouldPersistTaps: PropTypes.string, }; SmartScrollView.defaultProps = { @@ -271,7 +272,8 @@ SmartScrollView.defaultProps = { contentInset: {top: 0, left: 0, bottom: 0, right: 0}, onScroll: () => {}, onRefFocus: () => {}, - keyboardDismissMode: 'none' + keyboardDismissMode: 'none', + keyboardShouldPersistTaps: 'always' }; export default SmartScrollView; @@ -292,3 +294,6 @@ export default SmartScrollView; // lastTap: currentTap // }) // } +/** + * Created by Meysam on 5/7/17. + */