Skip to content

Commit 66fbda5

Browse files
author
yongqian
committed
修复Toast出现时,阻止界面交互的问题
1 parent eda1a0f commit 66fbda5

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ react-native项目中通用的浮层组件
2727
contentTextStyle: {}
2828
})
2929
...
30-
RRCAlert.alert(title, content, buttons, callback);
30+
31+
cosnt buttons = [
32+
{ text: 'ok', style: { color: '#fd521d', fontWeight: 'bold' } }
33+
]
34+
const callback = (index)=>{
35+
console.log(`you click button with index ${index}`);
36+
}
37+
RRCAlert.alert('title', 'content', buttons, callback);
3138

3239
* **`setAlertOptions` options**
3340

src/RRCToast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class OverlayToast {
4343
const toastViewBackgroundColor = ToastOptions.toastViewStyle && ToastOptions.toastViewStyle.backgroundColor ? ToastOptions.toastViewStyle.backgroundColor : 'rgba(0,0,0,0.8)';
4444
const withIcon = ToastOptions.toastIcons && ToastOptions.toastIcons.length > 0 && type != null && type >= 0 && type < ToastOptions.toastIcons.length;
4545
const toastView = (
46-
<View style={{ width, height, left: 0, right: 0, top: 0, bottom: 0, backgroundColor: toastBackgroundColor, justifyContent: 'center', alignItems: 'center' }}>
46+
<View pointerEvents={'box-none'} style={{ width, height, left: 0, right: 0, top: 0, bottom: 0, backgroundColor: toastBackgroundColor, justifyContent: 'center', alignItems: 'center' }}>
4747
<View style={[{
4848
justifyContent: 'center',
4949
alignItems: 'center',

src/RRCTopView.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export default class RRCTopView extends Component {
267267
</Animated.View>
268268
{
269269
elements.length > 0 || toastElements.length > 0 ?
270-
<View style={styles.overlayContainer}>
270+
<View style={styles.overlayContainer} pointerEvents={'box-none'} >
271271
{
272272
elements.map((item, index) => {
273273
// 同一时刻只加载elements中最后一个element
@@ -287,7 +287,7 @@ export default class RRCTopView extends Component {
287287
// 同一时刻只加载elements中最后一个element
288288
if (index == toastElements.length - 1) {
289289
return (
290-
<View key={'RRCTopView_Toast' + item.key} style={styles.overlay} >
290+
<View key={'RRCTopView_Toast' + item.key} style={styles.overlay} pointerEvents={'box-none'} >
291291
{item.element}
292292
</View>
293293
);
@@ -297,7 +297,7 @@ export default class RRCTopView extends Component {
297297
})
298298
}
299299
</View>
300-
: null
300+
: null
301301
}
302302
</View>
303303
);

0 commit comments

Comments
 (0)