From 62b11b473fe014f27d1383cbaf94528ff55374f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=87=E4=B8=9C?= Date: Mon, 23 Sep 2019 20:05:19 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E5=8D=87=E7=BA=A7autolinker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 33ed093..9fcc49c 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,6 @@ sftp-config.json ### VisualStudioCode ### .vscode/* + +### idea ### +.idea \ No newline at end of file diff --git a/package.json b/package.json index 5216871..4f8189f 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test": "mocha --require @babel/register --require test/setup.js --recursive test/*.test.js" }, "dependencies": { - "autolinker": "^3.0.3", + "autolinker": "^3.11.0", "prop-types": "^15.7.2" }, "devDependencies": { From 6018a0744111d4ce287b8d26e58557f68d8cd1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=87=E4=B8=9C?= Date: Mon, 23 Sep 2019 20:05:46 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=B5=E8=AF=9D?= =?UTF-8?q?=E5=8F=B7=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/matchers.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/matchers.js b/src/matchers.js index 3b58eb5..f49345f 100644 --- a/src/matchers.js +++ b/src/matchers.js @@ -36,5 +36,27 @@ export default [ return this.latlng; } }, +}, + { + id: 'phone', + regex: /((\+\d{2}(-)?)?(((\d{2,3}(-)?)?(\d{11}))|((0\d{2,3}(-)?)?\d{7,8})))|\d{5}/g, + Match: class PhoneMatch extends Match { + constructor(cfg) { + super(cfg); + this.phone = cfg.phone; + } + + getType() { + return 'phone'; + } + + getNumber(){ + return this.phone + } + + getAnchorText() { + return this.phone; + } + }, }, ]; From 1325185a94788b77070dc9467c78a927544527b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=87=E4=B8=9C?= Date: Thu, 26 Sep 2019 14:03:12 +0800 Subject: [PATCH 03/22] support custom matcher --- src/index.js | 9 ++++++++- src/matchers.js | 24 +----------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/index.js b/src/index.js index 80f0740..31270b7 100644 --- a/src/index.js +++ b/src/index.js @@ -200,6 +200,7 @@ export default class Autolink extends PureComponent { twitter, url, webFallback, + matchers: customMatchers, ...other } = this.props; @@ -239,7 +240,7 @@ export default class Autolink extends PureComponent { }); // Custom matchers - matchers.forEach(({ id, regex, Match }) => { + [...matchers, ...customMatchers].forEach(({ id, regex, Match }) => { // eslint-disable-next-line react/destructuring-assignment if (this.props[id]) { text = text.replace(regex, (...args) => { @@ -309,6 +310,7 @@ Autolink.defaultProps = { twitter: false, url: true, webFallback: Platform.OS !== 'ios', // iOS requires LSApplicationQueriesSchemes for Linking.canOpenURL + matchers: [], }; Autolink.propTypes = { @@ -356,4 +358,9 @@ Autolink.propTypes = { }), ]), webFallback: PropTypes.bool, + matchers: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + regex: PropTypes.string, + match: PropTypes.object + })) }; diff --git a/src/matchers.js b/src/matchers.js index f49345f..1788c1a 100644 --- a/src/matchers.js +++ b/src/matchers.js @@ -36,27 +36,5 @@ export default [ return this.latlng; } }, -}, - { - id: 'phone', - regex: /((\+\d{2}(-)?)?(((\d{2,3}(-)?)?(\d{11}))|((0\d{2,3}(-)?)?\d{7,8})))|\d{5}/g, - Match: class PhoneMatch extends Match { - constructor(cfg) { - super(cfg); - this.phone = cfg.phone; - } - - getType() { - return 'phone'; - } - - getNumber(){ - return this.phone - } - - getAnchorText() { - return this.phone; - } - }, - }, +} ]; From 35ecd896731c632a717140bfcb63787ad75ff321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=87=E4=B8=9C?= Date: Thu, 26 Sep 2019 16:14:58 +0800 Subject: [PATCH 04/22] Fix: display wrong text when component rerender --- src/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 31270b7..8588045 100644 --- a/src/index.js +++ b/src/index.js @@ -49,6 +49,14 @@ export default class Autolink extends PureComponent { return fn(text, truncate, truncateChars); } + constructor(props){ + super(props); + // Creates a token with a random UID that should not be guessable or + // conflict with other parts of the string. + this.uid = Math.floor(Math.random() * 0x10000000000).toString(16); + this.tokenRegexp = new RegExp(`(@__ELEMENT-${this.uid}-\\d+__@)`, 'g'); + } + onPress(match, alertShown) { const { onPress, @@ -209,14 +217,9 @@ export default class Autolink extends PureComponent { mention = 'twitter'; } - // Creates a token with a random UID that should not be guessable or - // conflict with other parts of the string. - const uid = Math.floor(Math.random() * 0x10000000000).toString(16); - const tokenRegexp = new RegExp(`(@__ELEMENT-${uid}-\\d+__@)`, 'g'); - const generateToken = (() => { let counter = 0; - return () => `@__ELEMENT-${uid}-${counter++}__@`; // eslint-disable-line no-plusplus + return () => `@__ELEMENT-${this.uid}-${counter++}__@`; // eslint-disable-line no-plusplus })(); const matches = {}; @@ -265,7 +268,7 @@ export default class Autolink extends PureComponent { } const nodes = text - .split(tokenRegexp) + .split(this.tokenRegexp) .filter(part => !!part) .map((part, index) => { const match = matches[part]; From 93ced15547326318cc2703e9caf6a7e1e51028df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=87=E4=B8=9C?= Date: Thu, 10 Oct 2019 09:51:18 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E6=9B=B4=E6=96=B0UID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 8588045..585da93 100644 --- a/src/index.js +++ b/src/index.js @@ -53,7 +53,8 @@ export default class Autolink extends PureComponent { super(props); // Creates a token with a random UID that should not be guessable or // conflict with other parts of the string. - this.uid = Math.floor(Math.random() * 0x10000000000).toString(16); + // 注意UID 不要和自定义的matcher冲突 + this.uid = Math.floor(Math.random() * 0x1000).toString(16); this.tokenRegexp = new RegExp(`(@__ELEMENT-${this.uid}-\\d+__@)`, 'g'); } From 3de59c94f6d38801105f9de059a90899436f57bc Mon Sep 17 00:00:00 2001 From: Ma Shuai Date: Thu, 13 Feb 2020 11:39:56 +0800 Subject: [PATCH 06/22] Preferential use of regex --- src/index.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/index.js b/src/index.js index 585da93..5c448d9 100644 --- a/src/index.js +++ b/src/index.js @@ -226,23 +226,6 @@ export default class Autolink extends PureComponent { const matches = {}; try { - text = Autolinker.link(text || '', { - email, - hashtag, - mention, - phone, - urls: url, - stripPrefix, - stripTrailingSlash, - replaceFn: (match) => { - const token = generateToken(); - - matches[token] = match; - - return token; - }, - }); - // Custom matchers [...matchers, ...customMatchers].forEach(({ id, regex, Match }) => { // eslint-disable-next-line react/destructuring-assignment @@ -262,6 +245,23 @@ export default class Autolink extends PureComponent { }); } }); + + text = Autolinker.link(text || '', { + email, + hashtag, + mention, + phone, + urls: url, + stripPrefix, + stripTrailingSlash, + replaceFn: (match) => { + const token = generateToken(); + + matches[token] = match; + + return token; + }, + }); } catch (e) { console.warn(e); // eslint-disable-line no-console From 74097c0fa5bdcbd1cca13e833a1da463c93071fc Mon Sep 17 00:00:00 2001 From: gaopeilei Date: Fri, 23 Sep 2022 17:36:36 +0800 Subject: [PATCH 07/22] =?UTF-8?q?feat(UI):=20=E6=94=B6=E8=B5=B7=E5=B1=95?= =?UTF-8?q?=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1004999 --user=高培磊 【交互体验】详情页专项优化 https://www.tapd.cn/23787791/s/1458637 --- package.json | 2 +- src/CollapsibleText.tsx | 93 +++++++++++++++++++++++++++++++++++++ src/{index.js => index.tsx} | 33 +++++++++++-- 3 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 src/CollapsibleText.tsx rename src/{index.js => index.tsx} (90%) diff --git a/package.json b/package.json index 4f8189f..c95bae8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.8.1", "description": "Autolinking component for React Native", "author": "Josh Swan ", - "main": "src/index.js", + "main": "src/index.tsx", "license": "MIT", "repository": { "type": "git", diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx new file mode 100644 index 0000000..e08df05 --- /dev/null +++ b/src/CollapsibleText.tsx @@ -0,0 +1,93 @@ +import React, { + Component, +} from 'react'; +import PropTypes from 'prop-types'; +import { Icon } from 'core/common'; + +import {View, Image, StyleSheet, Animated, Text, TouchableOpacity} from 'react-native'; +export default class CollapsibleText extends Component { + static propTypes = { + style: Text.propTypes.style, + expandTextStyle:Text.propTypes.style, + numberOfLines: PropTypes.number + } + constructor(props){ + super(props); + this.state = { + /** 文本是否展开 */ + expanded:true, + numberOfLines:null, + /** 展开收起文字是否处于显示状态 */ + showExpandText:false, + /** 是否处于测量阶段 */ + measureFlag:true + } + this.numberOfLines = props.numberOfLines; + /** 文本是否需要展开收起功能:(实际文字内容是否超出numberOfLines限制) */ + this.needExpand = true; + this.measureFlag = true; + } + + + _onTextLayout(event){ + if(this.measureFlag){ + if(this.state.expanded){ + this.maxHeight = event.nativeEvent.layout.height; + this.setState({expanded:false,numberOfLines:this.numberOfLines}); + }else{ + this.mixHeight = event.nativeEvent.layout.height; + if(this.mixHeight == this.maxHeight){ + this.needExpand = false; + }else{ + this.needExpand = true; + this.setState({showExpandText:true}) + } + this.measureFlag = false; + } + } + + } + + _onPressExpand(){ + if(!this.state.expanded){ + this.setState({numberOfLines:null,expanded:true}) + }else{ + this.setState({numberOfLines:this.numberOfLines,expanded:false}) + } + } + + render() { + const { numberOfLines, onLayout, expandTextStyle, ...rest } = this.props; + const btnTitle = this.state.expanded ? '收起' : '全部'; + const iconName = this.state.expanded ? 'e605' : 'e606'; + let expandText = this.state.showExpandText?( + + + {btnTitle} + + + + ) : null; + return ( + + + {this.props.children} + + {expandText} + + ); + } +} + +const styles = StyleSheet.create({ + expandText: { + color:'#666', + marginTop:0, + } +}); diff --git a/src/index.js b/src/index.tsx similarity index 90% rename from src/index.js rename to src/index.tsx index 5c448d9..40c942d 100644 --- a/src/index.js +++ b/src/index.tsx @@ -18,6 +18,7 @@ import { } from 'react-native'; import * as Truncate from './truncate'; import matchers from './matchers'; +import CollapsibleText from './CollapsibleText'; const tagBuilder = new AnchorTagBuilder(); @@ -291,11 +292,31 @@ export default class Autolink extends PureComponent { } }); - return createElement(Text, { - ref: (component) => { this._root = component; }, // eslint-disable-line no-underscore-dangle - style, - ...other, - }, ...nodes); + return ( + this.props.collapsibleTruncate + ?( { this._root = ref; }} // eslint-disable-line no-underscore-dangle + style={style} + numberOfLines= { this.props.collapsibleTruncate } + {...other} + > + {nodes} + ) + : ( { this._root = ref; }} // eslint-disable-line no-underscore-dangle + style={style} + numberOfLines= { 2 } + {...other} + > + {nodes} + ) + ); + // return createElement(Text, { + // ref: (component) => { this._root = component; }, // eslint-disable-line no-underscore-dangle + // style, + // ...other, + // numberOfLines:1, + // }, ...nodes); } } @@ -315,9 +336,11 @@ Autolink.defaultProps = { url: true, webFallback: Platform.OS !== 'ios', // iOS requires LSApplicationQueriesSchemes for Linking.canOpenURL matchers: [], + collapsibleTruncate: 0, }; Autolink.propTypes = { + collapsibleTruncate: PropTypes.number, email: PropTypes.bool, hashtag: PropTypes.oneOf([ false, From 5b6e6cf5e322ad6ae678fd112b5169429bf0cb50 Mon Sep 17 00:00:00 2001 From: gaopeilei Date: Fri, 23 Sep 2022 18:33:10 +0800 Subject: [PATCH 08/22] =?UTF-8?q?feat(UI):=20=E6=94=B6=E8=B5=B7=E5=B1=95?= =?UTF-8?q?=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1004999 --user=高培磊 【交互体验】详情页专项优化 https://www.tapd.cn/23787791/s/1458637 --- src/CollapsibleText.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index e08df05..16b7bee 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -4,7 +4,7 @@ import React, { import PropTypes from 'prop-types'; import { Icon } from 'core/common'; -import {View, Image, StyleSheet, Animated, Text, TouchableOpacity} from 'react-native'; +import { View, Image, StyleSheet, Animated, Text, TouchableOpacity, ImageProps } from 'react-native'; export default class CollapsibleText extends Component { static propTypes = { style: Text.propTypes.style, @@ -28,6 +28,11 @@ export default class CollapsibleText extends Component { this.measureFlag = true; } + componentDidUpdate(prevProps: Readonly<{ }>, prevState: Readonly<{}>, snapshot?: any) { + if(prevProps.children!=this.props.children){ + this.measureFlag = true; + } + } _onTextLayout(event){ if(this.measureFlag){ @@ -38,6 +43,7 @@ export default class CollapsibleText extends Component { this.mixHeight = event.nativeEvent.layout.height; if(this.mixHeight == this.maxHeight){ this.needExpand = false; + this.setState({showExpandText:false}) }else{ this.needExpand = true; this.setState({showExpandText:true}) @@ -64,10 +70,10 @@ export default class CollapsibleText extends Component { - {btnTitle} - - + style={[this.props.style,styles.expandText,expandTextStyle]}> + {btnTitle} + + ) : null; return ( @@ -91,3 +97,4 @@ const styles = StyleSheet.create({ marginTop:0, } }); +1 From d8fe045b0563c5d27870af487bac5fbd5445dedb Mon Sep 17 00:00:00 2001 From: gaopeilei Date: Mon, 26 Sep 2022 13:55:19 +0800 Subject: [PATCH 09/22] =?UTF-8?q?feat(UI):=20=E6=94=B6=E8=B5=B7=E5=B1=95?= =?UTF-8?q?=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1004999 --user=高培磊 【交互体验】详情页专项优化 https://www.tapd.cn/23787791/s/1458637 --- src/CollapsibleText.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 16b7bee..51a1bd5 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -97,4 +97,3 @@ const styles = StyleSheet.create({ marginTop:0, } }); -1 From 816ee5e2024cabd3818dac388e6e7513d80fe22c Mon Sep 17 00:00:00 2001 From: gaopeilei Date: Tue, 25 Oct 2022 09:14:01 +0800 Subject: [PATCH 10/22] =?UTF-8?q?feat(UI):=20=E6=94=B6=E8=B5=B7=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E9=A2=9C=E8=89=B2=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1032263 --user=高培磊 详情页UI细节问题 https://www.tapd.cn/23787791/s/1551388 --- src/CollapsibleText.tsx | 2 +- src/index.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 51a1bd5..7af6a1a 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -93,7 +93,7 @@ export default class CollapsibleText extends Component { const styles = StyleSheet.create({ expandText: { - color:'#666', + color:'#1890FF', marginTop:0, } }); diff --git a/src/index.tsx b/src/index.tsx index 40c942d..5412968 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -24,7 +24,7 @@ const tagBuilder = new AnchorTagBuilder(); const styles = StyleSheet.create({ link: { - color: '#0E7AFE', + color: '#1890FF', }, }); @@ -211,6 +211,7 @@ export default class Autolink extends PureComponent { url, webFallback, matchers: customMatchers, + expandTextStyle, ...other } = this.props; @@ -297,6 +298,7 @@ export default class Autolink extends PureComponent { ?( { this._root = ref; }} // eslint-disable-line no-underscore-dangle style={style} + expandTextStyle={expandTextStyle} numberOfLines= { this.props.collapsibleTruncate } {...other} > @@ -389,5 +391,6 @@ Autolink.propTypes = { id: PropTypes.string, regex: PropTypes.string, match: PropTypes.object - })) + })), + expandTextStyle: Text.propTypes.style, }; From 487686227d3277aa7eab63f0d480db440c425f88 Mon Sep 17 00:00:00 2001 From: gaopeilei Date: Mon, 31 Oct 2022 11:52:34 +0800 Subject: [PATCH 11/22] =?UTF-8?q?chore(UI):=20=E6=94=B6=E8=B5=B7=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E6=96=87=E5=AD=97=E5=8F=98=E6=9B=B4=E5=90=8E=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CollapsibleText.tsx | 22 ++++++++++------------ src/index.tsx | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 7af6a1a..ca033a7 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -9,7 +9,8 @@ export default class CollapsibleText extends Component { static propTypes = { style: Text.propTypes.style, expandTextStyle:Text.propTypes.style, - numberOfLines: PropTypes.number + numberOfLines: PropTypes.number, + rawText: PropTypes.string } constructor(props){ super(props); @@ -25,30 +26,27 @@ export default class CollapsibleText extends Component { this.numberOfLines = props.numberOfLines; /** 文本是否需要展开收起功能:(实际文字内容是否超出numberOfLines限制) */ this.needExpand = true; - this.measureFlag = true; } - componentDidUpdate(prevProps: Readonly<{ }>, prevState: Readonly<{}>, snapshot?: any) { - if(prevProps.children!=this.props.children){ - this.measureFlag = true; - } - } + UNSAFE_componentWillReceiveProps(nextProps) { + if(nextProps.rawText!==this.props.rawText){ + this.setState({expanded:true, numberOfLines:null, showExpandText:false, measureFlag:true}); + }} _onTextLayout(event){ - if(this.measureFlag){ + if(this.state.measureFlag){ if(this.state.expanded){ this.maxHeight = event.nativeEvent.layout.height; this.setState({expanded:false,numberOfLines:this.numberOfLines}); }else{ this.mixHeight = event.nativeEvent.layout.height; - if(this.mixHeight == this.maxHeight){ + if (this.maxHeight - this.mixHeight <1){ this.needExpand = false; - this.setState({showExpandText:false}) + this.setState({showExpandText:false,measureFlag:false}) }else{ this.needExpand = true; - this.setState({showExpandText:true}) + this.setState({showExpandText:true,measureFlag:false}) } - this.measureFlag = false; } } diff --git a/src/index.tsx b/src/index.tsx index 5412968..4985950 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -204,6 +204,7 @@ export default class Autolink extends PureComponent { stripTrailingSlash, style, text, + text:rawText, truncate, truncateChars, truncateLocation, @@ -296,14 +297,15 @@ export default class Autolink extends PureComponent { return ( this.props.collapsibleTruncate ?( { this._root = ref; }} // eslint-disable-line no-underscore-dangle - style={style} - expandTextStyle={expandTextStyle} - numberOfLines= { this.props.collapsibleTruncate } - {...other} - > - {nodes} - ) + ref={(ref) => { this._root = ref; }} // eslint-disable-line no-underscore-dangle + style={style} + expandTextStyle={expandTextStyle} + numberOfLines= { this.props.collapsibleTruncate } + rawText={rawText} + {...other} + > + {nodes} + ) : ( { this._root = ref; }} // eslint-disable-line no-underscore-dangle style={style} From f884b8e59c702a393ec749f397fcbfcc6c3ba63e Mon Sep 17 00:00:00 2001 From: gaopeilei Date: Fri, 11 Nov 2022 15:47:17 +0800 Subject: [PATCH 12/22] =?UTF-8?q?fix(UI):=20=E5=8E=BB=E9=99=A4debug?= =?UTF-8?q?=E7=9A=84=E8=A1=8C=E6=95=B0=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1032712 --user=高培磊 【杭州摩科商用设备有限公司】【手机端】【沟通】【待办】工作流的待办详情页面,内容显示不全 https://www.tapd.cn/23787791/s/1567554 --- src/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 4985950..dbf0051 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -309,7 +309,6 @@ export default class Autolink extends PureComponent { : ( { this._root = ref; }} // eslint-disable-line no-underscore-dangle style={style} - numberOfLines= { 2 } {...other} > {nodes} From e86dc1af06f24ec126035f8a1da8868d30f74a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Fri, 29 Mar 2024 14:18:36 +0800 Subject: [PATCH 13/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E6=A8=AA?= =?UTF-8?q?=E5=B1=8F=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8F=AA=E6=9C=89=E4=B8=80=E8=A1=8C=E4=B9=9F?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E4=BA=86=E5=B1=95=E5=BC=80=E6=94=B6=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046186 --user=田学军 【测试】【移动端】【审批】横屏的时候,审批提示只有一行也展示了展开收起的功能 https://www.tapd.cn/23787791/s/1875081 --- src/CollapsibleText.tsx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index ca033a7..68c7a62 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -4,7 +4,17 @@ import React, { import PropTypes from 'prop-types'; import { Icon } from 'core/common'; -import { View, Image, StyleSheet, Animated, Text, TouchableOpacity, ImageProps } from 'react-native'; +import { + View, + Image, + StyleSheet, + Animated, + Text, + TouchableOpacity, + ImageProps, + Dimensions, + EmitterSubscription +} from 'react-native'; export default class CollapsibleText extends Component { static propTypes = { style: Text.propTypes.style, @@ -12,6 +22,9 @@ export default class CollapsibleText extends Component { numberOfLines: PropTypes.number, rawText: PropTypes.string } + + changEmitter: EmitterSubscription; + constructor(props){ super(props); this.state = { @@ -33,6 +46,18 @@ export default class CollapsibleText extends Component { this.setState({expanded:true, numberOfLines:null, showExpandText:false, measureFlag:true}); }} + componentDidMount() { + this.changEmitter = Dimensions.addEventListener('change', this._onOrientationChange); + } + + componentWillUnmount() { + this.changEmitter?.remove(); + } + + _onOrientationChange = (e) => { + this.setState({expanded:true, numberOfLines:null, showExpandText:false, measureFlag:true}); + }; + _onTextLayout(event){ if(this.state.measureFlag){ if(this.state.expanded){ From add49e5c4996f009237371f32a31350f83b3be8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Tue, 2 Apr 2024 14:53:54 +0800 Subject: [PATCH 14/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E5=AE=89?= =?UTF-8?q?=E5=8D=93=E5=A4=A7=E5=AD=97=E4=BD=93=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=8F=90=E7=A4=BA=E8=B6=85=E5=87=BA=E4=BA=94?= =?UTF-8?q?=E8=A1=8C=E5=90=8E=EF=BC=8C=E5=B1=95=E5=BC=80=E3=80=81=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=8C=89=E9=92=AE=E6=9C=AA=E5=B1=95=E7=A4=BA=E5=AE=8C?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046383 --user=田学军 【测试】【移动端】【审批】安卓大字体,显示审批提示超出五行后,展开、全部按钮未展示完整 https://www.tapd.cn/23787791/s/1876886 --- src/CollapsibleText.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 68c7a62..96c1d79 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -92,11 +92,13 @@ export default class CollapsibleText extends Component { let expandText = this.state.showExpandText?( - - {btnTitle} + + + {btnTitle} + - + ) : null; return ( From b6056008c0b158e0e13ddcb4d3ac16c433938cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Tue, 2 Apr 2024 15:06:08 +0800 Subject: [PATCH 15/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E5=AE=89?= =?UTF-8?q?=E5=8D=93=E5=A4=A7=E5=AD=97=E4=BD=93=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=8F=90=E7=A4=BA=E8=B6=85=E5=87=BA=E4=BA=94?= =?UTF-8?q?=E8=A1=8C=E5=90=8E=EF=BC=8C=E5=B1=95=E5=BC=80=E3=80=81=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=8C=89=E9=92=AE=E6=9C=AA=E5=B1=95=E7=A4=BA=E5=AE=8C?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046383 --user=田学军 【测试】【移动端】【审批】安卓大字体,显示审批提示超出五行后,展开、全部按钮未展示完整 https://www.tapd.cn/23787791/s/1876886 --- src/CollapsibleText.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 96c1d79..b7fbf41 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -19,6 +19,7 @@ export default class CollapsibleText extends Component { static propTypes = { style: Text.propTypes.style, expandTextStyle:Text.propTypes.style, + expandBorderStyle: View.propTypes.style, numberOfLines: PropTypes.number, rawText: PropTypes.string } @@ -86,13 +87,13 @@ export default class CollapsibleText extends Component { } render() { - const { numberOfLines, onLayout, expandTextStyle, ...rest } = this.props; + const { numberOfLines, onLayout, expandTextStyle, expandBorderStyle, ...rest } = this.props; const btnTitle = this.state.expanded ? '收起' : '全部'; const iconName = this.state.expanded ? 'e605' : 'e606'; let expandText = this.state.showExpandText?( - + {btnTitle} From 7bd8ccf51339b4aee03b1437bb88005fc0889fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Tue, 2 Apr 2024 15:19:52 +0800 Subject: [PATCH 16/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E5=AE=89?= =?UTF-8?q?=E5=8D=93=E5=A4=A7=E5=AD=97=E4=BD=93=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=8F=90=E7=A4=BA=E8=B6=85=E5=87=BA=E4=BA=94?= =?UTF-8?q?=E8=A1=8C=E5=90=8E=EF=BC=8C=E5=B1=95=E5=BC=80=E3=80=81=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E6=8C=89=E9=92=AE=E6=9C=AA=E5=B1=95=E7=A4=BA=E5=AE=8C?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046383 --user=田学军 【测试】【移动端】【审批】安卓大字体,显示审批提示超出五行后,展开、全部按钮未展示完整 https://www.tapd.cn/23787791/s/1876886 --- src/CollapsibleText.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index b7fbf41..6ed01d8 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -11,7 +11,7 @@ import { Animated, Text, TouchableOpacity, - ImageProps, + ViewStyle, Dimensions, EmitterSubscription } from 'react-native'; @@ -19,7 +19,7 @@ export default class CollapsibleText extends Component { static propTypes = { style: Text.propTypes.style, expandTextStyle:Text.propTypes.style, - expandBorderStyle: View.propTypes.style, + expandBorderStyle: ViewStyle, numberOfLines: PropTypes.number, rawText: PropTypes.string } From 56df8e1739029e7db2050222011182a6fba93170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Wed, 10 Apr 2024 14:48:28 +0800 Subject: [PATCH 17/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E5=AE=89?= =?UTF-8?q?=E5=8D=93=EF=BC=8C=E5=AE=A1=E6=89=B9=E6=84=8F=E8=A7=81=E6=A1=86?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E6=BB=91=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046649 --user=田学军 【测试】【移动端】【审批】安卓,审批意见框不可滑动 https://www.tapd.cn/23787791/s/1880802 --- src/CollapsibleText.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 6ed01d8..5a0ed88 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -104,13 +104,15 @@ export default class CollapsibleText extends Component { ) : null; return ( - - {this.props.children} - + + + {this.props.children} + + {expandText} ); From 249f0645edad7aa4b0e5e235d251c57aa8878628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Tue, 16 Apr 2024 14:58:05 +0800 Subject: [PATCH 18/22] =?UTF-8?q?Revert=20"fix(=E5=AE=A1=E6=89=B9):=20?= =?UTF-8?q?=E5=AE=89=E5=8D=93=EF=BC=8C=E5=AE=A1=E6=89=B9=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E6=A1=86=E4=B8=8D=E5=8F=AF=E6=BB=91=E5=8A=A8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 56df8e1739029e7db2050222011182a6fba93170. --- src/CollapsibleText.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 5a0ed88..6ed01d8 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -104,15 +104,13 @@ export default class CollapsibleText extends Component { ) : null; return ( - - - {this.props.children} - - + + {this.props.children} + {expandText} ); From fdd521bae4ba7bac2f074b2454595f4f6f9554cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Thu, 18 Apr 2024 09:15:11 +0800 Subject: [PATCH 19/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E6=8F=90=E7=A4=BA=E8=B6=85=E5=87=BA5=E8=A1=8C?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=85=88=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E5=86=8D=E6=A8=AA=E5=B1=8F=EF=BC=8C=E5=86=8D=E7=AB=96=E5=B1=8F?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=B1=95=E5=BC=80=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046645 --user=田学军 【测试】【移动端】【审批】(安卓)审批提示超出5行后,先点击展开再横屏,再竖屏,会导致展开按钮丢失 https://www.tapd.cn/23787791/s/1884848 --- src/CollapsibleText.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 6ed01d8..c58f59e 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -17,8 +17,8 @@ import { } from 'react-native'; export default class CollapsibleText extends Component { static propTypes = { - style: Text.propTypes.style, - expandTextStyle:Text.propTypes.style, + style: Text.propTypes?.style, + expandTextStyle:Text.propTypes?.style, expandBorderStyle: ViewStyle, numberOfLines: PropTypes.number, rawText: PropTypes.string @@ -66,7 +66,7 @@ export default class CollapsibleText extends Component { this.setState({expanded:false,numberOfLines:this.numberOfLines}); }else{ this.mixHeight = event.nativeEvent.layout.height; - if (this.maxHeight - this.mixHeight <1){ + if (Math.abs(this.maxHeight - this.mixHeight) <1){ this.needExpand = false; this.setState({showExpandText:false,measureFlag:false}) }else{ From 78399f3f506a45c26b01449ab263d5d56bf4a1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Fri, 19 Apr 2024 11:01:30 +0800 Subject: [PATCH 20/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E6=8F=90=E7=A4=BA=E8=B6=85=E5=87=BA5=E8=A1=8C?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=85=88=E7=82=B9=E5=87=BB=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E5=86=8D=E6=A8=AA=E5=B1=8F=EF=BC=8C=E5=86=8D=E7=AB=96=E5=B1=8F?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=B1=95=E5=BC=80=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1046645 --user=田学军 【测试】【移动端】【审批】(安卓)审批提示超出5行后,先点击展开再横屏,再竖屏,会导致展开按钮丢失 https://www.tapd.cn/23787791/s/1884848 --- src/CollapsibleText.tsx | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index c58f59e..a4df6f5 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -59,25 +59,6 @@ export default class CollapsibleText extends Component { this.setState({expanded:true, numberOfLines:null, showExpandText:false, measureFlag:true}); }; - _onTextLayout(event){ - if(this.state.measureFlag){ - if(this.state.expanded){ - this.maxHeight = event.nativeEvent.layout.height; - this.setState({expanded:false,numberOfLines:this.numberOfLines}); - }else{ - this.mixHeight = event.nativeEvent.layout.height; - if (Math.abs(this.maxHeight - this.mixHeight) <1){ - this.needExpand = false; - this.setState({showExpandText:false,measureFlag:false}) - }else{ - this.needExpand = true; - this.setState({showExpandText:true,measureFlag:false}) - } - } - } - - } - _onPressExpand(){ if(!this.state.expanded){ this.setState({numberOfLines:null,expanded:true}) @@ -86,6 +67,16 @@ export default class CollapsibleText extends Component { } } + onTextLayout = (event) => { + if (this.state.measureFlag) { + if (event?.nativeEvent?.lines?.length > this.numberOfLines) { + this.setState({ expanded:false, showExpandText: true, numberOfLines: this.numberOfLines, measureFlag: false}); + } else { + this.setState({ showExpandText: false, numberOfLines:this.numberOfLines}); + } + } + }; + render() { const { numberOfLines, onLayout, expandTextStyle, expandBorderStyle, ...rest } = this.props; const btnTitle = this.state.expanded ? '收起' : '全部'; @@ -106,7 +97,7 @@ export default class CollapsibleText extends Component { {this.props.children} From e16079f3d6540ea730f490c24decc7f64dc5a285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Tue, 18 Feb 2025 10:22:13 +0800 Subject: [PATCH 21/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E9=B8=BF?= =?UTF-8?q?=E8=92=99=E4=B8=8A=E5=BC=BA=E5=88=B6=E5=88=B7=E6=96=B0text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1053877 --user=田学军 【鸿蒙】【审批】审批提示超长时,旋转屏幕会导致展开收起按钮丢失 https://www.tapd.cn/23787791/s/2033964 --- src/CollapsibleText.tsx | 2 +- yarn.lock | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index a4df6f5..686c2ce 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -56,7 +56,7 @@ export default class CollapsibleText extends Component { } _onOrientationChange = (e) => { - this.setState({expanded:true, numberOfLines:null, showExpandText:false, measureFlag:true}); + this.setState({expanded:true, numberOfLines:this.state.numberOfLines ? null : this.numberOfLines, showExpandText:false, measureFlag:true}); }; _onPressExpand(){ diff --git a/yarn.lock b/yarn.lock index 46647e9..605a8fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -958,12 +958,12 @@ atob@^2.1.1: resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== -autolinker@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-3.0.3.tgz#0a5227c76581a49cd72fc02d8601502c35426948" - integrity sha512-/ieTlOF7IYbjeGShX5eY0ALHb/jZJRxcavpEn3PelSiRPDn7yfGN/6IMKmiYq57mwB1aT7g1GG9ck8s9UrSwpQ== +autolinker@^3.11.0: + version "3.16.2" + resolved "https://r.cnpmjs.org/autolinker/-/autolinker-3.16.2.tgz#6bb4f32432fc111b65659336863e653973bfbcc9" + integrity sha512-JiYl7j2Z19F9NdTmirENSUUIIL/9MytEWtmzhfmsKPCp9E+G35Y0UNCMoM9tFigxT59qSc8Ml2dlZXOCVTYwuA== dependencies: - tslib "^1.9.3" + tslib "^2.3.0" axobject-query@^2.0.2: version "2.0.2" @@ -5409,11 +5409,16 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" -tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== +tslib@^2.3.0: + version "2.6.2" + resolved "https://r.cnpmjs.org/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" From 11455b3a88f45a25eb9fa65fb46a20c03192b1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=AD=A6=E5=86=9B?= Date: Wed, 9 Apr 2025 16:52:25 +0800 Subject: [PATCH 22/22] =?UTF-8?q?fix(=E5=AE=A1=E6=89=B9):=20=E9=B8=BF?= =?UTF-8?q?=E8=92=99=E4=B8=8A=E5=BC=BA=E5=88=B6=E5=88=B7=E6=96=B0text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1053877 --user=田学军 【鸿蒙】【审批】审批提示超长时,旋转屏幕会导致展开收起按钮丢失 https://www.tapd.cn/23787791/s/2033964 --- src/CollapsibleText.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/CollapsibleText.tsx b/src/CollapsibleText.tsx index 686c2ce..73cc3c6 100644 --- a/src/CollapsibleText.tsx +++ b/src/CollapsibleText.tsx @@ -3,6 +3,7 @@ import React, { } from 'react'; import PropTypes from 'prop-types'; import { Icon } from 'core/common'; +import Util from 'core/util'; import { View, @@ -13,7 +14,8 @@ import { TouchableOpacity, ViewStyle, Dimensions, - EmitterSubscription + EmitterSubscription, + Platform } from 'react-native'; export default class CollapsibleText extends Component { static propTypes = { @@ -26,8 +28,13 @@ export default class CollapsibleText extends Component { changEmitter: EmitterSubscription; + textKey; + constructor(props){ super(props); + if (Platform.OS === 'harmony') { + this.textKey = 1; + } this.state = { /** 文本是否展开 */ expanded:true, @@ -55,9 +62,12 @@ export default class CollapsibleText extends Component { this.changEmitter?.remove(); } - _onOrientationChange = (e) => { - this.setState({expanded:true, numberOfLines:this.state.numberOfLines ? null : this.numberOfLines, showExpandText:false, measureFlag:true}); - }; + _onOrientationChange = Util.Debounce((e) => { + if (this.textKey > 0) { + this.textKey += 1; + } + this.setState({expanded:true, numberOfLines:null, showExpandText:false, measureFlag:true}); + }, 500); _onPressExpand(){ if(!this.state.expanded){ @@ -93,9 +103,11 @@ export default class CollapsibleText extends Component { ) : null; + const textProps = this.textKey > 0 ? { key: this.textKey } : {}; return (